From b3ad3a20316cb93e49a8b4ab632186830c028850 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 13 Jul 2022 12:11:35 +0100 Subject: [PATCH] Don't overwrite secondary command buffer renderpass state if inactive * With dynamic rendering, secondary command buffers don't always inherit renderpass state from the primary, they can start their own. --- .../driver/vulkan/wrappers/vk_cmd_funcs.cpp | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp index 01f70a775..38884190b 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_cmd_funcs.cpp @@ -4660,15 +4660,20 @@ bool WrappedVulkan::Serialise_vkCmdExecuteCommands(SerialiserType &ser, VkComman { ResourceId cmd = GetResourceManager()->GetOriginalID(GetResID(pCommandBuffers[c])); - // propagate renderpass state - m_BakedCmdBufferInfo[cmd].state.SetRenderPass(parentCmdBufInfo.state.GetRenderPass()); - m_BakedCmdBufferInfo[cmd].state.subpass = parentCmdBufInfo.state.subpass; - m_BakedCmdBufferInfo[cmd].state.dynamicRendering = parentCmdBufInfo.state.dynamicRendering; - m_BakedCmdBufferInfo[cmd].state.SetFramebuffer( - parentCmdBufInfo.state.GetFramebuffer(), - parentCmdBufInfo.state.GetFramebufferAttachments()); - m_BakedCmdBufferInfo[cmd].state.renderArea = parentCmdBufInfo.state.renderArea; - m_BakedCmdBufferInfo[cmd].state.subpassContents = parentCmdBufInfo.state.subpassContents; + // propagate renderpass state if active. If it's inactive the renderpass might be + // activated inside the secondary which we should not overwrite. + if(parentCmdBufInfo.state.ActiveRenderPass()) + { + m_BakedCmdBufferInfo[cmd].state.SetRenderPass(parentCmdBufInfo.state.GetRenderPass()); + m_BakedCmdBufferInfo[cmd].state.subpass = parentCmdBufInfo.state.subpass; + m_BakedCmdBufferInfo[cmd].state.dynamicRendering = + parentCmdBufInfo.state.dynamicRendering; + m_BakedCmdBufferInfo[cmd].state.SetFramebuffer( + parentCmdBufInfo.state.GetFramebuffer(), + parentCmdBufInfo.state.GetFramebufferAttachments()); + m_BakedCmdBufferInfo[cmd].state.renderArea = parentCmdBufInfo.state.renderArea; + m_BakedCmdBufferInfo[cmd].state.subpassContents = parentCmdBufInfo.state.subpassContents; + } // 2 extra for the virtual labels around the command buffer parentCmdBufInfo.curEventID += 2 + m_BakedCmdBufferInfo[cmd].eventCount;