Add last present queue and semaphores to swapchain info

This is used for queue family tracking of presented images.

Change-Id: I64ac88a8e4b379bd947f56f5cf2c1db929e8c620
This commit is contained in:
Benson Joeris
2020-01-27 20:44:54 +00:00
committed by Baldur Karlsson
parent 8ccff3de48
commit c84fcc2aae
3 changed files with 27 additions and 7 deletions
+7 -3
View File
@@ -1711,6 +1711,7 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
RDCLOG("Finished capture, Frame %u", m_CapturedFrames.back().frameNumber);
VkImage backbuffer = VK_NULL_HANDLE;
const PresentInfo *presentInfo = NULL;
VkResourceRecord *swaprecord = NULL;
if(swap != VK_NULL_HANDLE)
@@ -1722,7 +1723,8 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
const SwapchainInfo &swapInfo = *swaprecord->swapInfo;
backbuffer = swapInfo.images[swapInfo.lastPresent].im;
presentInfo = &swapInfo.lastPresent;
backbuffer = swapInfo.images[presentInfo->imageIndex].im;
// mark all images referenced as well
for(size_t i = 0; i < swapInfo.images.size(); i++)
@@ -1741,7 +1743,8 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
const SwapchainInfo &swapInfo = *swaprecord->swapInfo;
backbuffer = swapInfo.images[swapInfo.lastPresent].im;
presentInfo = &swapInfo.lastPresent;
backbuffer = swapInfo.images[presentInfo->imageIndex].im;
// mark all images referenced as well
for(size_t i = 0; i < swapInfo.images.size(); i++)
@@ -1833,7 +1836,8 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
{swapInfo.imageInfo.extent.width, swapInfo.imageInfo.extent.height, 1},
};
uint32_t swapQueueIndex = m_ImageLayouts[GetResID(backbuffer)].queueFamilyIndex;
VkResourceRecord *queueRecord = GetRecord(swapInfo.lastPresent.presentQueue);
uint32_t swapQueueIndex = queueRecord->queueFamilyIndex;
VkImageMemoryBarrier bbBarrier = {
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
+8 -1
View File
@@ -929,6 +929,13 @@ struct ImageInfo
DECLARE_REFLECTION_STRUCT(ImageInfo);
struct PresentInfo
{
VkQueue presentQueue;
rdcarray<VkSemaphore> waitSemaphores;
uint32_t imageIndex;
};
struct SwapchainInfo
{
ImageInfo imageInfo;
@@ -947,7 +954,7 @@ struct SwapchainInfo
VkFramebuffer fb;
};
rdcarray<SwapImage> images;
uint32_t lastPresent;
PresentInfo lastPresent;
};
// these structs are allocated for images and buffers, then pointed to (non-owning) by views
@@ -553,7 +553,10 @@ void WrappedVulkan::WrapAndProcessCreatedSwapchain(VkDevice device,
vkr = vt->GetSwapchainImagesKHR(Unwrap(device), Unwrap(*pSwapChain), &numSwapImages, NULL);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
swapInfo.lastPresent = 0;
swapInfo.lastPresent.imageIndex = 0;
swapInfo.lastPresent.presentQueue = VK_NULL_HANDLE;
swapInfo.lastPresent.waitSemaphores.clear();
swapInfo.images.resize(numSwapImages);
for(uint32_t i = 0; i < numSwapImages; i++)
{
@@ -758,7 +761,12 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR
// need to record which image was last flipped so we can get the correct backbuffer
// for a thumbnail in EndFrameCapture
swapInfo.lastPresent = pPresentInfo->pImageIndices[0];
swapInfo.lastPresent.imageIndex = pPresentInfo->pImageIndices[0];
swapInfo.lastPresent.presentQueue = queue;
swapInfo.lastPresent.waitSemaphores.resize(pPresentInfo->waitSemaphoreCount);
for(size_t i = 0; i < swapInfo.lastPresent.waitSemaphores.size(); ++i)
swapInfo.lastPresent.waitSemaphores[i] = pPresentInfo->pWaitSemaphores[i];
m_LastSwap = swaprecord->GetResourceID();
if(IsBackgroundCapturing(m_State))
@@ -774,7 +782,8 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR
VkImage im = swapInfo.images[pPresentInfo->pImageIndices[0]].im;
VkFramebuffer fb = swapInfo.images[pPresentInfo->pImageIndices[0]].fb;
uint32_t swapQueueIndex = m_ImageLayouts[GetResID(im)].queueFamilyIndex;
VkResourceRecord *queueRecord = GetRecord(queue);
uint32_t swapQueueIndex = queueRecord->queueFamilyIndex;
VkDevDispatchTable *vt = ObjDisp(GetDev());