mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-24 15:36:33 +00:00
add support for VR end of frame markers in vulkan
This commit is contained in:
@@ -1785,6 +1785,35 @@ bool WrappedVulkan::EndFrameCapture(void *dev, void *wnd)
|
||||
return true;
|
||||
}
|
||||
|
||||
void WrappedVulkan::AdvanceFrame()
|
||||
{
|
||||
if(IsBackgroundCapturing(m_State))
|
||||
{
|
||||
RenderDoc::Inst().Tick();
|
||||
GetResourceManager()->FlushPendingDirty();
|
||||
}
|
||||
m_FrameCounter++; // first present becomes frame #1, this function is at the end of the frame
|
||||
}
|
||||
|
||||
void WrappedVulkan::Present(void *dev, void *wnd)
|
||||
{
|
||||
bool activeWindow = wnd == NULL || RenderDoc::Inst().IsActiveWindow(dev, wnd);
|
||||
|
||||
RenderDoc::Inst().AddActiveDriver(RDCDriver::Vulkan, true);
|
||||
if(!activeWindow)
|
||||
return;
|
||||
|
||||
if(IsActiveCapturing(m_State) && !m_AppControlledCapture)
|
||||
RenderDoc::Inst().EndFrameCapture(dev, wnd);
|
||||
|
||||
if(RenderDoc::Inst().ShouldTriggerCapture(m_FrameCounter) && IsBackgroundCapturing(m_State))
|
||||
{
|
||||
RenderDoc::Inst().StartFrameCapture(dev, wnd);
|
||||
|
||||
m_AppControlledCapture = false;
|
||||
}
|
||||
}
|
||||
|
||||
void WrappedVulkan::AddResource(ResourceId id, ResourceType type, const char *defaultNamePrefix)
|
||||
{
|
||||
ResourceDescription &descr = GetReplay()->GetResourceDesc(id);
|
||||
|
||||
@@ -770,6 +770,11 @@ private:
|
||||
void StartFrameCapture(void *dev, void *wnd);
|
||||
bool EndFrameCapture(void *dev, void *wnd);
|
||||
|
||||
void AdvanceFrame();
|
||||
void Present(void *dev, void *wnd);
|
||||
|
||||
void HandleVRFrameMarkers(const char *marker, VkCommandBuffer commandBuffer);
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_SetShaderDebugPath(SerialiserType &ser, VkShaderModule ShaderObject,
|
||||
std::string DebugPath);
|
||||
|
||||
@@ -929,6 +929,9 @@ struct CmdBufferRecordingInfo
|
||||
set<VkDescriptorSet> boundDescSets;
|
||||
|
||||
vector<VkResourceRecord *> subcmds;
|
||||
|
||||
// AdvanceFrame/Present should be called after this buffer is submitted
|
||||
bool present;
|
||||
};
|
||||
|
||||
struct DescSetLayout;
|
||||
|
||||
@@ -555,6 +555,7 @@ VkResult WrappedVulkan::vkAllocateCommandBuffers(VkDevice device,
|
||||
record->cmdInfo->allocInfo = *pAllocateInfo;
|
||||
record->cmdInfo->allocInfo.commandBufferCount = 1;
|
||||
record->cmdInfo->allocRecord = allocRecord;
|
||||
record->cmdInfo->present = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -852,6 +853,7 @@ VkResult WrappedVulkan::vkBeginCommandBuffer(VkCommandBuffer commandBuffer,
|
||||
|
||||
record->bakedCommands->cmdInfo->device = record->cmdInfo->device;
|
||||
record->bakedCommands->cmdInfo->allocInfo = record->cmdInfo->allocInfo;
|
||||
record->bakedCommands->cmdInfo->present = false;
|
||||
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
@@ -3326,6 +3328,15 @@ void WrappedVulkan::vkCmdDebugMarkerEndEXT(VkCommandBuffer commandBuffer)
|
||||
}
|
||||
}
|
||||
|
||||
void WrappedVulkan::HandleVRFrameMarkers(const char *marker, VkCommandBuffer commandBuffer)
|
||||
{
|
||||
if(strstr(marker, "vr-marker,frame_end,type,application") != NULL)
|
||||
{
|
||||
VkResourceRecord *record = GetRecord(commandBuffer);
|
||||
record->bakedCommands->cmdInfo->present = true;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
bool WrappedVulkan::Serialise_vkCmdDebugMarkerInsertEXT(SerialiserType &ser,
|
||||
VkCommandBuffer commandBuffer,
|
||||
@@ -3381,6 +3392,7 @@ void WrappedVulkan::vkCmdDebugMarkerInsertEXT(VkCommandBuffer commandBuffer,
|
||||
ObjDisp(commandBuffer)->CmdDebugMarkerInsertEXT(Unwrap(commandBuffer), pMarker));
|
||||
}
|
||||
|
||||
HandleVRFrameMarkers(pMarker->pMarkerName, commandBuffer);
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
VkResourceRecord *record = GetRecord(commandBuffer);
|
||||
|
||||
@@ -779,6 +779,8 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
unwrappedSubmits, Unwrap(fence)));
|
||||
|
||||
bool capframe = false;
|
||||
bool present = false;
|
||||
|
||||
set<ResourceId> refdIDs;
|
||||
|
||||
VkResourceRecord *queueRecord = GetRecord(queue);
|
||||
@@ -790,6 +792,7 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
ResourceId cmd = GetResID(pSubmits[s].pCommandBuffers[i]);
|
||||
|
||||
VkResourceRecord *record = GetRecord(pSubmits[s].pCommandBuffers[i]);
|
||||
present |= record->bakedCommands->cmdInfo->present;
|
||||
|
||||
{
|
||||
SCOPED_LOCK(m_ImageLayoutsLock);
|
||||
@@ -1005,6 +1008,12 @@ VkResult WrappedVulkan::vkQueueSubmit(VkQueue queue, uint32_t submitCount,
|
||||
}
|
||||
}
|
||||
|
||||
if(present)
|
||||
{
|
||||
AdvanceFrame();
|
||||
Present(LayerDisp(m_Instance), NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -621,14 +621,7 @@ VkResult WrappedVulkan::vkCreateSwapchainKHR(VkDevice device,
|
||||
|
||||
VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo)
|
||||
{
|
||||
if(IsBackgroundCapturing(m_State))
|
||||
{
|
||||
RenderDoc::Inst().Tick();
|
||||
|
||||
GetResourceManager()->FlushPendingDirty();
|
||||
}
|
||||
|
||||
m_FrameCounter++; // first present becomes frame #1, this function is at the end of the frame
|
||||
AdvanceFrame();
|
||||
|
||||
if(pPresentInfo->swapchainCount > 1 && (m_FrameCounter % 100) == 0)
|
||||
{
|
||||
@@ -787,21 +780,7 @@ VkResult WrappedVulkan::vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR
|
||||
|
||||
VkResult vkr = ObjDisp(queue)->QueuePresentKHR(Unwrap(queue), &unwrappedInfo);
|
||||
|
||||
RenderDoc::Inst().AddActiveDriver(RDCDriver::Vulkan, true);
|
||||
|
||||
if(!activeWindow)
|
||||
return vkr;
|
||||
|
||||
// kill any current capture that isn't application defined
|
||||
if(IsActiveCapturing(m_State) && !m_AppControlledCapture)
|
||||
RenderDoc::Inst().EndFrameCapture(LayerDisp(m_Instance), swapInfo.wndHandle);
|
||||
|
||||
if(RenderDoc::Inst().ShouldTriggerCapture(m_FrameCounter) && IsBackgroundCapturing(m_State))
|
||||
{
|
||||
RenderDoc::Inst().StartFrameCapture(LayerDisp(m_Instance), swapInfo.wndHandle);
|
||||
|
||||
m_AppControlledCapture = false;
|
||||
}
|
||||
Present(LayerDisp(m_Instance), swapInfo.wndHandle);
|
||||
|
||||
return vkr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user