From cc9aaf2690a806c4610251840a9358f8cdd5f07e Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Tue, 6 Sep 2016 20:37:01 -0600 Subject: layers: Add cmd buffer binding for fb images Fixes #915 When binding framebuffer to command buffer, we need to also bind the underlying images. Then, if images are destroyed, the cmd buffer will correctly be marked as invalid and an error will be flagged if an attempt to submit the cmd buffer is made. --- layers/core_validation.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'layers/core_validation.cpp') diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 55d5c334..24190dac 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -4924,6 +4924,9 @@ QueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, V pCBNode->submitCount++; // increment submit count skip_call |= validatePrimaryCommandBufferState(dev_data, pCBNode); skip_call |= validateQueueFamilyIndices(dev_data, pCBNode, queue); + // Potential early exit here as bad object state may crash in delayed function calls + if (skip_call) + return result; // Call submit-time functions to validate/update state for (auto &function : pCBNode->validate_functions) { skip_call |= function(); @@ -6722,6 +6725,14 @@ BeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo } // Connect this framebuffer to this cmdBuffer framebuffer->cb_bindings.insert(pCB); + for (auto attach : framebuffer->attachments) { + auto img_node = getImageNode(dev_data, attach.image); + if (img_node) { + addCommandBufferBinding( + &img_node->cb_bindings, + {reinterpret_cast(attach.image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT}, pCB); + } + } } } } @@ -10046,7 +10057,14 @@ CmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo *p pCB->framebuffers.insert(pRenderPassBegin->framebuffer); // Connect this framebuffer to this cmdBuffer framebuffer->cb_bindings.insert(pCB); - + for (auto attach : framebuffer->attachments) { + auto img_node = getImageNode(dev_data, attach.image); + if (img_node) { + addCommandBufferBinding(&img_node->cb_bindings, + {reinterpret_cast(attach.image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT}, + pCB); + } + } // transition attachments to the correct layouts for the first subpass TransitionSubpassLayouts(dev_data, pCB, &pCB->activeRenderPassBeginInfo, pCB->activeSubpass); } else { -- cgit v1.2.3