Skip to content

Commit

Permalink
Dynamically allocate Vulkan output window swapchain arrays
Browse files Browse the repository at this point in the history
Vivo X90 devices provide 11 swapchain images. Dynamically
allocate output window arrays to handle this.
  • Loading branch information
MartynJacques-Arm committed Jan 28, 2025
1 parent da6a31d commit 6baaba1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions renderdoc/driver/vulkan/vk_outputwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ VulkanReplay::OutputWindow::OutputWindow()
{
surface = VK_NULL_HANDLE;
swap = VK_NULL_HANDLE;
for(size_t i = 0; i < ARRAY_COUNT(colimg); i++)
for(size_t i = 0; i < colimg.size(); i++)
colimg[i] = VK_NULL_HANDLE;

WINDOW_HANDLE_INIT;
Expand Down Expand Up @@ -75,7 +75,7 @@ VulkanReplay::OutputWindow::OutputWindow()
VK_NULL_HANDLE,
{VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1},
};
for(size_t i = 0; i < ARRAY_COUNT(colBarrier); i++)
for(size_t i = 0; i < colBarrier.size(); i++)
colBarrier[i] = t;

bbBarrier = t;
Expand Down Expand Up @@ -118,7 +118,7 @@ void VulkanReplay::OutputWindow::Destroy(WrappedVulkan *driver, VkDevice device)
}

// not owned - freed with the swapchain
for(size_t i = 0; i < ARRAY_COUNT(colimg); i++)
for(size_t i = 0; i < colimg.size(); i++)
{
if(colimg[i] != VK_NULL_HANDLE)
GetResourceManager()->ReleaseWrappedResource(colimg[i]);
Expand Down Expand Up @@ -404,12 +404,15 @@ void VulkanReplay::OutputWindow::Create(WrappedVulkan *driver, VkDevice device,
vkr = vt->GetSwapchainImagesKHR(Unwrap(device), Unwrap(swap), &numImgs, NULL);
CHECK_VKR(driver, vkr);

RDCASSERT(numImgs <= 8, numImgs);
RDCASSERT(numImgs <= 12, numImgs);

VkImage *imgs = new VkImage[numImgs];
vkr = vt->GetSwapchainImagesKHR(Unwrap(device), Unwrap(swap), &numImgs, imgs);
CHECK_VKR(driver, vkr);

colimg.resize(numImgs);
colBarrier.resize(numImgs);

for(size_t i = 0; i < numImgs; i++)
{
colimg[i] = imgs[i];
Expand Down
4 changes: 2 additions & 2 deletions renderdoc/driver/vulkan/vk_replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ class VulkanReplay : public IReplayDriver
VkSurfaceKHR surface;
VkSwapchainKHR swap;
uint32_t numImgs;
VkImage colimg[8];
VkImageMemoryBarrier colBarrier[8];
rdcarray<VkImage> colimg;
rdcarray<VkImageMemoryBarrier> colBarrier;

VkImage bb;
VkImageView bbview;
Expand Down

0 comments on commit 6baaba1

Please sign in to comment.