From 9f0787da3387fac502bff8fcc27019efcd7b0935 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 29 May 2020 14:10:48 +0100 Subject: [PATCH] Keep subpass self-dependencies when making loadRPs. --- renderdoc/common/common.h | 2 +- .../driver/vulkan/wrappers/vk_misc_funcs.cpp | 46 ++++++++++++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/renderdoc/common/common.h b/renderdoc/common/common.h index 71ccc4f14..e5fcd59e9 100644 --- a/renderdoc/common/common.h +++ b/renderdoc/common/common.h @@ -139,7 +139,7 @@ bool DebuggerPresent(); #define CONCAT(a, b) CONCAT2(a, b) #define RDCEraseMem(a, b) memset(a, 0, b) -#define RDCEraseEl(a) memset(&a, 0, sizeof(a)) +#define RDCEraseEl(a) memset((void *)&a, 0, sizeof(a)) template T RDCCLAMP(const T &val, const T &mn, const T &mx) diff --git a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp index cfefbc01f..61cb9f789 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_misc_funcs.cpp @@ -53,8 +53,28 @@ static void MakeSubpassLoadRP(RPCreateInfo &info, const RPCreateInfo *origInfo, info.subpassCount = 1; info.pSubpasses = origInfo->pSubpasses + s; - // remove any dependencies + // remove any non-self dependencies info.dependencyCount = 0; + for(uint32_t i = 0; i < origInfo->dependencyCount; i++) + { + // if this dependency is a self-dependency for the target subpass, keep it + if(origInfo->pDependencies[i].srcSubpass == origInfo->pDependencies[i].dstSubpass && + origInfo->pDependencies[i].srcSubpass == s) + { + uint32_t d = info.dependencyCount; + info.dependencyCount++; + + // copy the dependency + memcpy((void *)&info.pDependencies[d], &origInfo->pDependencies[i], + sizeof(origInfo->pDependencies[i])); + + // set the srcSubpass/dstSubpass to 0 since we're rewriting this renderpass to contain one + // subpass only + RDCEraseEl(info.pDependencies[d].srcSubpass); + RDCEraseEl(info.pDependencies[d].dstSubpass); + break; + } + } // we use decltype here because this is templated to work for regular and create_renderpass2 // structs @@ -1013,8 +1033,8 @@ VkResult WrappedVulkan::vkCreateRenderPass(VkDevice device, const VkRenderPassCr VkRenderPassCreateInfo info = *pCreateInfo; - VkAttachmentDescription atts[16]; - RDCASSERT(ARRAY_COUNT(atts) >= (size_t)info.attachmentCount); + rdcarray atts; + atts.resize(info.attachmentCount); // make a version of the render pass that loads from its attachments, // so it can be used for replaying a single draw after a render pass @@ -1026,7 +1046,13 @@ VkResult WrappedVulkan::vkCreateRenderPass(VkDevice device, const VkRenderPassCr atts[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; } - info.pAttachments = atts; + info.pAttachments = atts.data(); + + // copy the dependencies so we can mutate them + rdcarray deps; + deps.assign(info.pDependencies, info.dependencyCount); + + info.pDependencies = deps.data(); rpinfo.loadRPs.resize(pCreateInfo->subpassCount); @@ -1263,8 +1289,8 @@ VkResult WrappedVulkan::vkCreateRenderPass2(VkDevice device, VkRenderPassCreateInfo2 info = *pCreateInfo; - VkAttachmentDescription2 atts[16]; - RDCASSERT(ARRAY_COUNT(atts) >= (size_t)info.attachmentCount); + rdcarray atts; + atts.resize(info.attachmentCount); // make a version of the render pass that loads from its attachments, // so it can be used for replaying a single draw after a render pass @@ -1276,7 +1302,13 @@ VkResult WrappedVulkan::vkCreateRenderPass2(VkDevice device, atts[i].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; } - info.pAttachments = atts; + info.pAttachments = atts.data(); + + // copy the dependencies so we can mutate them + rdcarray deps; + deps.assign(info.pDependencies, info.dependencyCount); + + info.pDependencies = deps.data(); rpinfo.loadRPs.resize(pCreateInfo->subpassCount);