Keep subpass self-dependencies when making loadRPs.

This commit is contained in:
baldurk
2020-05-29 14:11:03 +01:00
parent 86e0ed1d26
commit 9f0787da33
2 changed files with 40 additions and 8 deletions
+1 -1
View File
@@ -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 <typename T>
T RDCCLAMP(const T &val, const T &mn, const T &mx)
@@ -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<VkAttachmentDescription> 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<VkSubpassDependency> 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<VkAttachmentDescription2> 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<VkSubpassDependency2> deps;
deps.assign(info.pDependencies, info.dependencyCount);
info.pDependencies = deps.data();
rpinfo.loadRPs.resize(pCreateInfo->subpassCount);