Handle starting/ending RPs inside secondary cmd buffers. Closes #2740

This commit is contained in:
baldurk
2022-10-07 11:18:30 +01:00
parent 255fb82e7d
commit 5fa549ea8b
3 changed files with 26 additions and 13 deletions
+7 -5
View File
@@ -3821,7 +3821,7 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay
VkResult vkr = VK_SUCCESS;
bool rpWasActive = false;
bool rpWasActive[2] = {};
// we'll need our own command buffer if we're replaying just a subsection
// of events within a single command buffer record - always if it's only
@@ -3850,9 +3850,10 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay
m_RenderState.subpassContents = VK_SUBPASS_CONTENTS_INLINE;
m_RenderState.dynamicRendering.flags &= ~VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT;
rpWasActive = m_Partial[Primary].renderPassActive;
rpWasActive[Primary] = m_Partial[Primary].renderPassActive;
rpWasActive[Secondary] = m_Partial[Secondary].renderPassActive;
if(m_Partial[Primary].renderPassActive)
if(rpWasActive[Primary] || rpWasActive[Secondary])
{
const ActionDescription *action = GetAction(endEventID);
@@ -3928,13 +3929,14 @@ void WrappedVulkan::ReplayLog(uint32_t startEventID, uint32_t endEventID, Replay
// even if it wasn't before (if the above event was a CmdBeginRenderPass).
// If we began our own custom single-action loadrp, and it was ended by a CmdEndRenderPass,
// we need to reverse the virtual transitions we did above, as it won't happen otherwise
if(m_Partial[Primary].renderPassActive)
if(m_Partial[Primary].renderPassActive || m_Partial[Secondary].renderPassActive)
m_RenderState.EndRenderPass(cmd);
// we might have replayed a CmdBeginRenderPass or CmdEndRenderPass,
// but we want to keep the partial replay data state intact, so restore
// whether or not a render pass was active.
m_Partial[Primary].renderPassActive = rpWasActive;
m_Partial[Primary].renderPassActive = rpWasActive[Primary];
m_Partial[Secondary].renderPassActive = rpWasActive[Secondary];
ObjDisp(cmd)->EndCommandBuffer(Unwrap(cmd));
+2 -2
View File
@@ -726,9 +726,9 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, FloatVector clearCol, D
const VulkanCreationInfo::Pipeline &pipeInfo =
m_pDriver->m_CreationInfo.m_Pipeline[state.graphics.pipeline];
// Secondary commands can't have render passes
if((mainDraw && !(mainDraw->flags & ActionFlags::Drawcall)) ||
!m_pDriver->m_Partial[WrappedVulkan::Primary].renderPassActive)
(!m_pDriver->m_Partial[WrappedVulkan::Primary].renderPassActive &&
!m_pDriver->m_Partial[WrappedVulkan::Secondary].renderPassActive))
{
// don't do anything, no action capable of making overlays selected
float black[] = {0.0f, 0.0f, 0.0f, 0.0f};
@@ -1393,8 +1393,10 @@ bool WrappedVulkan::Serialise_vkEndCommandBuffer(SerialiserType &ser, VkCommandB
}
// finish any render pass that was still active in the primary partial parent
if(m_Partial[Primary].partialParent == BakedCommandBuffer &&
m_Partial[Primary].renderPassActive)
if((m_Partial[Primary].partialParent == BakedCommandBuffer &&
m_Partial[Primary].renderPassActive) ||
(m_Partial[Secondary].partialParent == BakedCommandBuffer &&
m_Partial[Secondary].renderPassActive))
{
if(m_BakedCmdBufferInfo[m_LastCmdBufferID].renderPassOpen)
{
@@ -6772,9 +6774,13 @@ bool WrappedVulkan::Serialise_vkCmdBeginRendering(SerialiserType &ser, VkCommand
commandBuffer = RerecordCmdBuf(m_LastCmdBufferID);
// only if we're partially recording do we update this state
if(ShouldUpdateRenderState(m_LastCmdBufferID, true))
if(ShouldUpdateRenderState(m_LastCmdBufferID))
{
m_Partial[Primary].renderPassActive = true;
if(m_Partial[Primary].partialParent == m_LastCmdBufferID)
m_Partial[Primary].renderPassActive = true;
else if(m_Partial[Secondary].partialParent == m_LastCmdBufferID)
m_Partial[Secondary].renderPassActive = true;
m_BakedCmdBufferInfo[m_LastCmdBufferID].renderPassOpen = true;
}
m_BakedCmdBufferInfo[m_LastCmdBufferID].activeSubpass = 0;
@@ -7136,13 +7142,18 @@ bool WrappedVulkan::Serialise_vkCmdEndRendering(SerialiserType &ser, VkCommandBu
bool suspending = (renderstate.dynamicRendering.flags & VK_RENDERING_SUSPENDING_BIT) != 0;
if(ShouldUpdateRenderState(m_LastCmdBufferID, true))
if(ShouldUpdateRenderState(m_LastCmdBufferID))
{
m_BakedCmdBufferInfo[m_LastCmdBufferID].renderPassOpen = false;
// if this rendering is just being suspended, the pass is still active
if(!suspending)
m_Partial[Primary].renderPassActive = false;
{
if(m_Partial[Primary].partialParent == m_LastCmdBufferID)
m_Partial[Primary].renderPassActive = false;
else if(m_Partial[Secondary].partialParent == m_LastCmdBufferID)
m_Partial[Secondary].renderPassActive = false;
}
}
ActionFlags drawFlags = ActionFlags::PassBoundary | ActionFlags::EndPass;