diff options
| author | Chris Forbes <chrisforbes@google.com> | 2017-02-28 18:59:20 +1300 |
|---|---|---|
| committer | Chris Forbes <chrisf@ijw.co.nz> | 2017-03-01 09:52:04 +1300 |
| commit | a9ba746a78e4e0025f04ca9f4ebcbf1282a93145 (patch) | |
| tree | 97258e4f77b66916e48b0eb828d8f39b94d3d066 | |
| parent | 3e40c3b4c5148834ba7763a991bbe26b3b45a8a9 (diff) | |
| download | usermoji-a9ba746a78e4e0025f04ca9f4ebcbf1282a93145.tar.xz | |
layers: Factor out marking of first use as read or write...
.. and make the handling of VK_ATTACHMENT_UNUSED consistent across all
cases. Previously we could end up with useless tracking of
VK_ATTACHMENT_UNUSED.
Signed-off-by: Chris Forbes <chrisforbes@google.com>
| -rw-r--r-- | layers/core_validation.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 7ea68475..c7327f7e 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -9225,6 +9225,16 @@ static bool ValidateRenderpassAttachmentUsage(layer_data *dev_data, const VkRend return skip_call; } +static void MarkAttachmentFirstUse(RENDER_PASS_STATE *render_pass, + uint32_t index, + bool is_read) { + if (index == VK_ATTACHMENT_UNUSED) + return; + + if (!render_pass->attachment_first_read.count(index)) + render_pass->attachment_first_read[index] = is_read; +} + VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass) { bool skip_call = false; @@ -9263,35 +9273,21 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateRenderPass(VkDevice device, const VkRenderP render_pass->hasSelfDependency = has_self_dependency; render_pass->subpassToNode = subpass_to_node; - // TODO: Maybe fill list and then copy instead of locking - std::unordered_map<uint32_t, bool> &attachment_first_read = render_pass->attachment_first_read; for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) { const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i]; for (uint32_t j = 0; j < subpass.colorAttachmentCount; ++j) { - uint32_t attachment = subpass.pColorAttachments[j].attachment; - if (!attachment_first_read.count(attachment)) { - attachment_first_read.insert(std::make_pair(attachment, false)); - } + MarkAttachmentFirstUse(render_pass.get(), subpass.pColorAttachments[j].attachment, false); - if (subpass.pResolveAttachments && subpass.pResolveAttachments[j].attachment != VK_ATTACHMENT_UNUSED) { - // resolve attachments are considered to be written - attachment = subpass.pResolveAttachments[j].attachment; - if (!attachment_first_read.count(attachment)) { - attachment_first_read.insert(std::make_pair(attachment, false)); - } + // resolve attachments are considered to be written + if (subpass.pResolveAttachments) { + MarkAttachmentFirstUse(render_pass.get(), subpass.pResolveAttachments[j].attachment, false); } } - if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) { - uint32_t attachment = subpass.pDepthStencilAttachment->attachment; - if (!attachment_first_read.count(attachment)) { - attachment_first_read.insert(std::make_pair(attachment, false)); - } + if (subpass.pDepthStencilAttachment) { + MarkAttachmentFirstUse(render_pass.get(), subpass.pDepthStencilAttachment->attachment, false); } for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) { - uint32_t attachment = subpass.pInputAttachments[j].attachment; - if (!attachment_first_read.count(attachment)) { - attachment_first_read.insert(std::make_pair(attachment, true)); - } + MarkAttachmentFirstUse(render_pass.get(), subpass.pInputAttachments[j].attachment, true); } } |
