From a77f3a7e17bfbedd606a640dc59bc914d2b35826 Mon Sep 17 00:00:00 2001 From: spencer-lunarg Date: Sat, 20 Jul 2024 23:35:51 -0400 Subject: [PATCH] bp: Move PreCallRecord to PostCallRecord --- .../best_practices_validation.h | 129 +++++------- layers/best_practices/bp_cmd_buffer.cpp | 24 +-- .../best_practices/bp_copy_blit_resolve.cpp | 72 +++---- layers/best_practices/bp_device_memory.cpp | 4 +- layers/best_practices/bp_drawdispatch.cpp | 110 +++++----- layers/best_practices/bp_pipeline.cpp | 88 ++++---- layers/best_practices/bp_render_pass.cpp | 192 +++++++++--------- 7 files changed, 287 insertions(+), 332 deletions(-) diff --git a/layers/best_practices/best_practices_validation.h b/layers/best_practices/best_practices_validation.h index 50ebbc8bf09..ec07f895d82 100644 --- a/layers/best_practices/best_practices_validation.h +++ b/layers/best_practices/best_practices_validation.h @@ -204,7 +204,7 @@ class BestPractices : public ValidationStateTracker { bool ValidatePushConstants(VkCommandBuffer cmd_buffer, const Location& loc) const; - void RecordCmdDrawType(VkCommandBuffer cmd_buffer, uint32_t draw_count); + void RecordCmdDrawType(bp_state::CommandBuffer& cb_state, uint32_t draw_count); bool ValidateDeprecatedExtensions(const Location& loc, vvl::Extension extension, APIVersion version) const; @@ -266,8 +266,8 @@ class BestPractices : public ValidationStateTracker { const ErrorObject& error_obj) const override; bool PreCallValidateBindImageMemory2KHR(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos, const ErrorObject& error_obj) const override; - void PreCallRecordSetDeviceMemoryPriorityEXT(VkDevice device, VkDeviceMemory memory, float priority, - const RecordObject& record_obj) override; + void PostCallRecordSetDeviceMemoryPriorityEXT(VkDevice device, VkDeviceMemory memory, float priority, + const RecordObject& record_obj) override; bool PreCallValidateGetVideoSessionMemoryRequirementsKHR(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pMemoryRequirementsCount, VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements, @@ -383,32 +383,24 @@ class BestPractices : public ValidationStateTracker { bool PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags, const ErrorObject& error_obj) const override; - void PreCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, - const RecordObject& record_obj) override; void PostCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, const RecordObject& record_obj) override; - void PreCallRecordCmdSetDepthCompareOp(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, - const RecordObject& record_obj) override; - void PreCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, - const RecordObject& record_obj) override; - void PreCallRecordCmdSetDepthTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + void PostCallRecordCmdSetDepthCompareOp(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, const RecordObject& record_obj) override; - void PreCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + void PostCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, const RecordObject& record_obj) override; + void PostCallRecordCmdSetDepthTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + const RecordObject& record_obj) override; + void PostCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + const RecordObject& record_obj) override; bool ValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const Location& loc) const; bool ValidateCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, const Location& loc) const; - void PreCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, - VkSubpassContents contents, const RecordObject& record_obj) override; - void PreCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, - const VkSubpassBeginInfo* pSubpassBeginInfo, const RecordObject& record_obj) override; - void PreCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, - const VkSubpassBeginInfo* pSubpassBeginInfo, const RecordObject& record_obj) override; - void PreCallRecordCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, - const RecordObject& record_obj) override; - void PreCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, - const RecordObject& record_obj) override; + void PostCallRecordCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, + const RecordObject& record_obj) override; + void PostCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, + const RecordObject& record_obj) override; void PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents, const RecordObject& record_obj) override; @@ -416,7 +408,7 @@ class BestPractices : public ValidationStateTracker { const VkSubpassEndInfo* pSubpassEndInfo, const RecordObject& record_obj) override; void PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo, const RecordObject& record_obj) override; - void RecordCmdNextSubpass(VkCommandBuffer commandBuffer); + void RecordCmdNextSubpass(bp_state::CommandBuffer& cb_state); void PostCallRecordCmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues, @@ -424,13 +416,13 @@ class BestPractices : public ValidationStateTracker { void PostCallRecordCmdPushConstants2KHR(VkCommandBuffer commandBuffer, const VkPushConstantsInfoKHR* pPushConstantsInfo, const RecordObject& record_obj) override; - void PreCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; - void PreCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo, - const RecordObject& record_obj) override; - void PreCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassEndInfo, - const RecordObject& record_obj) override; - void PreCallRecordCmdEndRendering(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; - void PreCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; + void PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; + void PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo, + const RecordObject& record_obj) override; + void PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassEndInfo, + const RecordObject& record_obj) override; + void PostCallRecordCmdEndRendering(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; + void PostCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer, const RecordObject& record_obj) override; bool PreCallValidateCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents, const ErrorObject& error_obj) const override; @@ -448,7 +440,7 @@ class BestPractices : public ValidationStateTracker { bool PreCallValidateCmdEndRendering(VkCommandBuffer commandBuffer, const ErrorObject& error_obj) const override; bool PreCallValidateCmdEndRenderingKHR(VkCommandBuffer commandBuffer, const ErrorObject& error_obj) const override; - void PostRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin); + void PostRecordCmdBeginRenderPass(bp_state::CommandBuffer& cb_state, const VkRenderPassBeginInfo* pRenderPassBegin); void PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents, const RecordObject& record_obj) override; void PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, @@ -464,9 +456,6 @@ class BestPractices : public ValidationStateTracker { const ErrorObject& error_obj) const override; bool ValidateIndexBufferArm(const bp_state::CommandBuffer& cb_state, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, const Location& loc) const; - void PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, - uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, - const RecordObject& record_obj) override; void PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, const RecordObject& record_obj) override; @@ -559,16 +548,10 @@ class BestPractices : public ValidationStateTracker { const ErrorObject& error_obj) const override; bool PreCallValidateCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo, const ErrorObject& error_obj) const override; - void PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, - uint32_t firstInstance, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, - uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) override; - void PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, - const RecordObject& record_obj) override; - void PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - const RecordObject& record_obj) override; + void PostCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, + const RecordObject& record_obj) override; + void PostCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + const RecordObject& record_obj) override; bool PreCallValidateEndCommandBuffer(VkCommandBuffer commandBuffer, const ErrorObject& error_obj) const override; bool ValidateGetPhysicalDeviceDisplayPlanePropertiesKHRQuery(VkPhysicalDevice physicalDevice, const Location& loc) const; bool PreCallValidateGetDisplayPlaneSupportedDisplaysKHR(VkPhysicalDevice physicalDevice, uint32_t planeIndex, @@ -631,31 +614,31 @@ class BestPractices : public ValidationStateTracker { void ValidateImageInQueueArmImg(Func command, const bp_state::Image& image, IMAGE_SUBRESOURCE_USAGE_BP last_usage, IMAGE_SUBRESOURCE_USAGE_BP usage, uint32_t array_layer, uint32_t mip_level); - void PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageResolve* pRegions, const RecordObject& record_obj) override; - void PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR* pResolveImageInfo, - const RecordObject& record_obj) override; - void PreCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, - const RecordObject& record_obj) override; - void PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, - const VkClearColorValue* pColor, uint32_t rangeCount, - const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) override; - void PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, - const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) override; - void PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions, - const RecordObject& record_obj) override; - void PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions, + void PostCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, + VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, + const VkImageResolve* pRegions, const RecordObject& record_obj) override; + void PostCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR* pResolveImageInfo, const RecordObject& record_obj) override; - void PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions, - const RecordObject& record_obj) override; - void PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter, - const RecordObject& record_obj) override; + void PostCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, + const RecordObject& record_obj) override; + void PostCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, + const VkClearColorValue* pColor, uint32_t rangeCount, + const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) override; + void PostCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, + const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) override; + void PostCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions, + const RecordObject& record_obj) override; + void PostCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions, + const RecordObject& record_obj) override; + void PostCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, + VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions, + const RecordObject& record_obj) override; + void PostCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, + VkFilter filter, const RecordObject& record_obj) override; template bool ValidateCmdBlitImage(VkCommandBuffer command_buffer, uint32_t region_count, const RegionType* regions, const Location& loc) const; @@ -811,9 +794,9 @@ class BestPractices : public ValidationStateTracker { void PreCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence, const RecordObject& record_obj) override; - void PreCallRecordCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, - const VkClearAttachment* pClearAttachments, uint32_t rectCount, const VkClearRect* pRects, - const RecordObject& record_obj) override; + void PostCallRecordCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, + const VkClearAttachment* pClearAttachments, uint32_t rectCount, + const VkClearRect* pRects, const RecordObject& record_obj) override; bool PreCallValidateCmdExecuteCommands(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers, const ErrorObject& error_obj) const override; @@ -908,7 +891,7 @@ class BestPractices : public ValidationStateTracker { VkImageAspectFlags aspects, const Location& loc) const; bool ValidateCmdEndRenderPass(VkCommandBuffer commandBuffer, const Location& loc) const; - void RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin); + void RecordCmdBeginRenderPass(bp_state::CommandBuffer& cb_state, const VkRenderPassBeginInfo* pRenderPassBegin); bool ValidateBuildAccelerationStructure(VkCommandBuffer commandBuffer, const Location& loc) const; @@ -916,8 +899,8 @@ class BestPractices : public ValidationStateTracker { void RecordSetDepthTestState(bp_state::CommandBuffer& cb_state, VkCompareOp new_depth_compare_op, bool new_depth_test_enable); - void RecordCmdBeginRenderingCommon(VkCommandBuffer commandBuffer); - void RecordCmdEndRenderingCommon(VkCommandBuffer commandBuffer); + void RecordCmdBeginRenderingCommon(bp_state::CommandBuffer& cb_state); + void RecordCmdEndRenderingCommon(bp_state::CommandBuffer& cb_state, const vvl::RenderPass& rp_state); void RecordBindZcullScope(bp_state::CommandBuffer& cb_state, VkImage depth_attachment, const VkImageSubresourceRange& subresource_range); diff --git a/layers/best_practices/bp_cmd_buffer.cpp b/layers/best_practices/bp_cmd_buffer.cpp index 7b626d5a86b..740b380655f 100644 --- a/layers/best_practices/bp_cmd_buffer.cpp +++ b/layers/best_practices/bp_cmd_buffer.cpp @@ -160,9 +160,9 @@ bool BestPractices::PreCallValidateGetQueryPoolResults(VkDevice device, VkQueryP return skip; } -void BestPractices::PreCallRecordCmdSetDepthCompareOp(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, - const RecordObject& record_obj) { - StateTracker::PreCallRecordCmdSetDepthCompareOp(commandBuffer, depthCompareOp, record_obj); +void BestPractices::PostCallRecordCmdSetDepthCompareOp(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, + const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdSetDepthCompareOp(commandBuffer, depthCompareOp, record_obj); auto cb_state = GetWrite(commandBuffer); @@ -171,14 +171,14 @@ void BestPractices::PreCallRecordCmdSetDepthCompareOp(VkCommandBuffer commandBuf } } -void BestPractices::PreCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, - const RecordObject& record_obj) { - PreCallRecordCmdSetDepthCompareOp(commandBuffer, depthCompareOp, record_obj); +void BestPractices::PostCallRecordCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp, + const RecordObject& record_obj) { + PostCallRecordCmdSetDepthCompareOp(commandBuffer, depthCompareOp, record_obj); } -void BestPractices::PreCallRecordCmdSetDepthTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, - const RecordObject& record_obj) { - StateTracker::PreCallRecordCmdSetDepthTestEnable(commandBuffer, depthTestEnable, record_obj); +void BestPractices::PostCallRecordCmdSetDepthTestEnable(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdSetDepthTestEnable(commandBuffer, depthTestEnable, record_obj); auto cb_state = GetWrite(commandBuffer); @@ -187,9 +187,9 @@ void BestPractices::PreCallRecordCmdSetDepthTestEnable(VkCommandBuffer commandBu } } -void BestPractices::PreCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, - const RecordObject& record_obj) { - PreCallRecordCmdSetDepthTestEnable(commandBuffer, depthTestEnable, record_obj); +void BestPractices::PostCallRecordCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable, + const RecordObject& record_obj) { + PostCallRecordCmdSetDepthTestEnable(commandBuffer, depthTestEnable, record_obj); } namespace { diff --git a/layers/best_practices/bp_copy_blit_resolve.cpp b/layers/best_practices/bp_copy_blit_resolve.cpp index da710dc4719..fff7af5ec1a 100644 --- a/layers/best_practices/bp_copy_blit_resolve.cpp +++ b/layers/best_practices/bp_copy_blit_resolve.cpp @@ -21,11 +21,11 @@ #include "best_practices/bp_state.h" #include "state_tracker/render_pass_state.h" -void BestPractices::PreCallRecordCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, - const VkClearAttachment* pClearAttachments, uint32_t rectCount, - const VkClearRect* pRects, const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdClearAttachments(commandBuffer, attachmentCount, pClearAttachments, rectCount, pRects, - record_obj); +void BestPractices::PostCallRecordCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, + const VkClearAttachment* pClearAttachments, uint32_t rectCount, + const VkClearRect* pRects, const RecordObject& record_obj) { + ValidationStateTracker::PostCallRecordCmdClearAttachments(commandBuffer, attachmentCount, pClearAttachments, rectCount, pRects, + record_obj); auto cb_state = GetWrite(commandBuffer); auto* rp_state = cb_state->activeRenderPass.get(); @@ -375,9 +375,9 @@ bool BestPractices::PreCallValidateCmdResolveImage2(VkCommandBuffer commandBuffe return skip; } -void BestPractices::PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageResolve* pRegions, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, + VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, + const VkImageResolve* pRegions, const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto src = Get(srcImage); @@ -391,13 +391,14 @@ void BestPractices::PreCallRecordCmdResolveImage(VkCommandBuffer commandBuffer, } } -void BestPractices::PreCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, const VkResolveImageInfo2KHR* pResolveImageInfo, - const RecordObject& record_obj) { - PreCallRecordCmdResolveImage2(commandBuffer, pResolveImageInfo, record_obj); +void BestPractices::PostCallRecordCmdResolveImage2KHR(VkCommandBuffer commandBuffer, + const VkResolveImageInfo2KHR* pResolveImageInfo, + const RecordObject& record_obj) { + PostCallRecordCmdResolveImage2(commandBuffer, pResolveImageInfo, record_obj); } -void BestPractices::PreCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, - const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo, + const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto src = Get(pResolveImageInfo->srcImage); @@ -412,9 +413,9 @@ void BestPractices::PreCallRecordCmdResolveImage2(VkCommandBuffer commandBuffer, } } -void BestPractices::PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, - const VkClearColorValue* pColor, uint32_t rangeCount, - const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdClearColorImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, + const VkClearColorValue* pColor, uint32_t rangeCount, + const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto dst = Get(image); @@ -428,11 +429,12 @@ void BestPractices::PreCallRecordCmdClearColorImage(VkCommandBuffer commandBuffe } } -void BestPractices::PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, - const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, - const VkImageSubresourceRange* pRanges, const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, - pRanges, record_obj); +void BestPractices::PostCallRecordCmdClearDepthStencilImage(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, + const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, + const VkImageSubresourceRange* pRanges, + const RecordObject& record_obj) { + ValidationStateTracker::PostCallRecordCmdClearDepthStencilImage(commandBuffer, image, imageLayout, pDepthStencil, rangeCount, + pRanges, record_obj); auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; @@ -448,11 +450,11 @@ void BestPractices::PreCallRecordCmdClearDepthStencilImage(VkCommandBuffer comma } } -void BestPractices::PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageCopy* pRegions, const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, - regionCount, pRegions, record_obj); +void BestPractices::PostCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, + VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, + const VkImageCopy* pRegions, const RecordObject& record_obj) { + ValidationStateTracker::PostCallRecordCmdCopyImage(commandBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, + regionCount, pRegions, record_obj); auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; @@ -467,9 +469,9 @@ void BestPractices::PreCallRecordCmdCopyImage(VkCommandBuffer commandBuffer, VkI } } -void BestPractices::PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, - VkImageLayout dstImageLayout, uint32_t regionCount, - const VkBufferImageCopy* pRegions, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, + VkImageLayout dstImageLayout, uint32_t regionCount, + const VkBufferImageCopy* pRegions, const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto dst = Get(dstImage); @@ -480,9 +482,9 @@ void BestPractices::PreCallRecordCmdCopyBufferToImage(VkCommandBuffer commandBuf } } -void BestPractices::PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions, - const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuffer, VkImage srcImage, + VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, + const VkBufferImageCopy* pRegions, const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto src = Get(srcImage); @@ -493,9 +495,9 @@ void BestPractices::PreCallRecordCmdCopyImageToBuffer(VkCommandBuffer commandBuf } } -void BestPractices::PreCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, - VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, - const VkImageBlit* pRegions, VkFilter filter, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, + VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, + const VkImageBlit* pRegions, VkFilter filter, const RecordObject& record_obj) { auto cb_state = GetWrite(commandBuffer); auto& funcs = cb_state->queue_submit_functions; auto src = Get(srcImage); diff --git a/layers/best_practices/bp_device_memory.cpp b/layers/best_practices/bp_device_memory.cpp index d707a5efdd4..552f48d0f77 100644 --- a/layers/best_practices/bp_device_memory.cpp +++ b/layers/best_practices/bp_device_memory.cpp @@ -280,8 +280,8 @@ bool BestPractices::PreCallValidateBindImageMemory2KHR(VkDevice device, uint32_t return PreCallValidateBindImageMemory2(device, bindInfoCount, pBindInfos, error_obj); } -void BestPractices::PreCallRecordSetDeviceMemoryPriorityEXT(VkDevice device, VkDeviceMemory memory, float priority, - const RecordObject& record_obj) { +void BestPractices::PostCallRecordSetDeviceMemoryPriorityEXT(VkDevice device, VkDeviceMemory memory, float priority, + const RecordObject& record_obj) { auto mem_info = std::static_pointer_cast(Get(memory)); mem_info->dynamic_priority.emplace(priority); } diff --git a/layers/best_practices/bp_drawdispatch.cpp b/layers/best_practices/bp_drawdispatch.cpp index 46071f4bf61..312c130745a 100644 --- a/layers/best_practices/bp_drawdispatch.cpp +++ b/layers/best_practices/bp_drawdispatch.cpp @@ -83,26 +83,25 @@ bool BestPractices::ValidatePushConstants(VkCommandBuffer cmd_buffer, const Loca return skip; } -void BestPractices::RecordCmdDrawType(VkCommandBuffer cmd_buffer, uint32_t draw_count) { - auto cb_state = GetWrite(cmd_buffer); +void BestPractices::RecordCmdDrawType(bp_state::CommandBuffer& cb_state, uint32_t draw_count) { if (VendorCheckEnabled(kBPVendorArm)) { - RecordCmdDrawTypeArm(*cb_state, draw_count); + RecordCmdDrawTypeArm(cb_state, draw_count); } if (VendorCheckEnabled(kBPVendorNVIDIA)) { - RecordCmdDrawTypeNVIDIA(*cb_state); + RecordCmdDrawTypeNVIDIA(cb_state); } - if (cb_state->render_pass_state.drawTouchAttachments) { - for (auto& touch : cb_state->render_pass_state.nextDrawTouchesAttachments) { - RecordAttachmentAccess(*cb_state, touch.framebufferAttachment, touch.aspects); + if (cb_state.render_pass_state.drawTouchAttachments) { + for (auto& touch : cb_state.render_pass_state.nextDrawTouchesAttachments) { + RecordAttachmentAccess(cb_state, touch.framebufferAttachment, touch.aspects); } // No need to touch the same attachments over and over. - cb_state->render_pass_state.drawTouchAttachments = false; + cb_state.render_pass_state.drawTouchAttachments = false; } - const auto* pipeline_state = cb_state->GetCurrentPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS); + const auto* pipeline_state = cb_state.GetCurrentPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS); if (pipeline_state && pipeline_state->vertex_input_state && !pipeline_state->vertex_input_state->binding_descriptions.empty()) { - cb_state->uses_vertex_buffer = true; + cb_state.uses_vertex_buffer = true; } } @@ -143,12 +142,6 @@ bool BestPractices::PreCallValidateCmdDraw(VkCommandBuffer commandBuffer, uint32 return skip; } -void BestPractices::PostCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, - uint32_t firstVertex, uint32_t firstInstance, const RecordObject& record_obj) { - StateTracker::PostCallRecordCmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance, record_obj); - RecordCmdDrawType(commandBuffer, vertexCount * instanceCount); -} - bool BestPractices::PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, const ErrorObject& error_obj) const { @@ -161,7 +154,7 @@ bool BestPractices::PreCallValidateCmdDrawIndexed(VkCommandBuffer commandBuffer, skip |= ValidateCmdDrawType(commandBuffer, error_obj.location); // Check if we reached the limit for small indexed draw calls. - // Note that we cannot update the draw call count here, so we do it in PreCallRecordCmdDrawIndexed. + // Note that we cannot update the draw call count here, so we do it in PostCallRecordCmdDrawIndexed. const auto cmd_state = GetRead(commandBuffer); if ((indexCount * instanceCount) <= kSmallIndexedDrawcallIndices && (cmd_state->small_indexed_draw_call_count == kMaxSmallIndexedDrawcalls - 1) && @@ -360,13 +353,14 @@ bool BestPractices::ValidateIndexBufferArm(const bp_state::CommandBuffer& cmd_st return skip; } -void BestPractices::PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, - uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, - const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, - firstInstance, record_obj); - +void BestPractices::PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, + uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, + const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance, + record_obj); auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, indexCount * instanceCount); + if ((indexCount * instanceCount) <= kSmallIndexedDrawcallIndices) { cb_state->small_indexed_draw_call_count++; } @@ -374,14 +368,6 @@ void BestPractices::PreCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, u ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location.function); } -void BestPractices::PostCallRecordCmdDrawIndexed(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, - uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance, - const RecordObject& record_obj) { - StateTracker::PostCallRecordCmdDrawIndexed(commandBuffer, indexCount, instanceCount, firstIndex, vertexOffset, firstInstance, - record_obj); - RecordCmdDrawType(commandBuffer, indexCount * instanceCount); -} - bool BestPractices::PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride, const ErrorObject& error_obj) const { bool skip = false; @@ -396,12 +382,6 @@ bool BestPractices::PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer return skip; } -void BestPractices::PostCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t count, uint32_t stride, const RecordObject& record_obj) { - StateTracker::PostCallRecordCmdDrawIndirect(commandBuffer, buffer, offset, count, stride, record_obj); - RecordCmdDrawType(commandBuffer, count); -} - bool BestPractices::PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride, const ErrorObject& error_obj) const { bool skip = false; @@ -416,12 +396,6 @@ bool BestPractices::PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer comman return skip; } -void BestPractices::PostCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t count, uint32_t stride, const RecordObject& record_obj) { - StateTracker::PostCallRecordCmdDrawIndexedIndirect(commandBuffer, buffer, offset, count, stride, record_obj); - RecordCmdDrawType(commandBuffer, count); -} - bool BestPractices::PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride, @@ -435,7 +409,8 @@ void BestPractices::PostCallRecordCmdDrawIndexedIndirectCount(VkCommandBuffer co const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawIndexedIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawIndexedIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, @@ -483,7 +458,8 @@ void BestPractices::PostCallRecordCmdDrawIndirectByteCountEXT(VkCommandBuffer co uint32_t vertexStride, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawIndirectByteCountEXT(commandBuffer, instanceCount, firstInstance, counterBuffer, counterBufferOffset, counterOffset, vertexStride, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -497,7 +473,8 @@ void BestPractices::PostCallRecordCmdDrawIndirectCount(VkCommandBuffer commandBu uint32_t stride, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawIndirectCount(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawIndirectCountAMD(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -543,7 +520,8 @@ void BestPractices::PostCallRecordCmdDrawMeshTasksIndirectCountNV(VkCommandBuffe uint32_t stride, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, @@ -555,7 +533,8 @@ bool BestPractices::PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer co void BestPractices::PostCallRecordCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask, @@ -566,7 +545,8 @@ bool BestPractices::PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuf void BestPractices::PostCallRecordCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdDrawMeshTasksNV(commandBuffer, taskCount, firstTask, record_obj); - RecordCmdDrawType(commandBuffer, 0); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, 0); } bool BestPractices::PreCallValidateCmdDrawMultiIndexedEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, @@ -586,7 +566,8 @@ void BestPractices::PostCallRecordCmdDrawMultiIndexedEXT(VkCommandBuffer command for (uint32_t i = 0; i < drawCount; ++i) { count += pIndexInfo[i].indexCount; } - RecordCmdDrawType(commandBuffer, count); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, count); } bool BestPractices::PreCallValidateCmdDrawMultiEXT(VkCommandBuffer commandBuffer, uint32_t drawCount, @@ -604,7 +585,8 @@ void BestPractices::PostCallRecordCmdDrawMultiEXT(VkCommandBuffer commandBuffer, for (uint32_t i = 0; i < drawCount; ++i) { count += pVertexInfo[i].vertexCount; } - RecordCmdDrawType(commandBuffer, count); + const auto cb_state = GetWrite(commandBuffer); + RecordCmdDrawType(*cb_state, count); } void BestPractices::ValidateBoundDescriptorSets(bp_state::CommandBuffer& cb_state, VkPipelineBindPoint bind_point, Func command) { @@ -657,22 +639,28 @@ void BestPractices::ValidateBoundDescriptorSets(bp_state::CommandBuffer& cb_stat } } -void BestPractices::PreCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, - uint32_t firstVertex, uint32_t firstInstance, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdDraw(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, + uint32_t firstVertex, uint32_t firstInstance, const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdDraw(commandBuffer, vertexCount, instanceCount, firstVertex, firstInstance, record_obj); const auto cb_state = GetWrite(commandBuffer); ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location.function); + RecordCmdDrawType(*cb_state, vertexCount * instanceCount); } -void BestPractices::PreCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdDrawIndirect(commandBuffer, buffer, offset, drawCount, stride, record_obj); const auto cb_state = GetWrite(commandBuffer); ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location.function); + RecordCmdDrawType(*cb_state, drawCount); } -void BestPractices::PreCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + uint32_t drawCount, uint32_t stride, const RecordObject& record_obj) { + StateTracker::PostCallRecordCmdDrawIndexedIndirect(commandBuffer, buffer, offset, drawCount, stride, record_obj); const auto cb_state = GetWrite(commandBuffer); ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, record_obj.location.function); + RecordCmdDrawType(*cb_state, drawCount); } bool BestPractices::PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, @@ -689,14 +677,14 @@ bool BestPractices::PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, ui return skip; } -void BestPractices::PreCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, - const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z, + const RecordObject& record_obj) { const auto cb_state = GetWrite(commandBuffer); ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location.function); } -void BestPractices::PreCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, - const RecordObject& record_obj) { +void BestPractices::PostCallRecordCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, + const RecordObject& record_obj) { const auto cb_state = GetWrite(commandBuffer); ValidateBoundDescriptorSets(*cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, record_obj.location.function); } diff --git a/layers/best_practices/bp_pipeline.cpp b/layers/best_practices/bp_pipeline.cpp index d4fe889a316..75ba08e7ee7 100644 --- a/layers/best_practices/bp_pipeline.cpp +++ b/layers/best_practices/bp_pipeline.cpp @@ -418,54 +418,6 @@ bool BestPractices::ValidateCreateComputePipelineAmd(const VkComputePipelineCrea return skip; } -void BestPractices::PreCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, - VkPipeline pipeline, const RecordObject& record_obj) { - StateTracker::PreCallRecordCmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline, record_obj); - - auto cb_state = GetWrite(commandBuffer); - - if (pipelineBindPoint == VK_PIPELINE_BIND_POINT_GRAPHICS && VendorCheckEnabled(kBPVendorNVIDIA)) { - auto pipeline_info = Get(pipeline); - ASSERT_AND_RETURN(pipeline_info); - using TessGeometryMeshState = bp_state::CommandBufferStateNV::TessGeometryMesh::State; - auto& tgm = cb_state->nv.tess_geometry_mesh; - - // Make sure the message is only signaled once per command buffer - tgm.threshold_signaled = tgm.num_switches >= kNumBindPipelineTessGeometryMeshSwitchesThresholdNVIDIA; - - // Track pipeline switches with tessellation, geometry, and/or mesh shaders enabled, and disabled - auto tgm_stages = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT | - VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_TASK_BIT_EXT | VK_SHADER_STAGE_MESH_BIT_EXT; - auto new_tgm_state = - (pipeline_info->active_shaders & tgm_stages) != 0 ? TessGeometryMeshState::Enabled : TessGeometryMeshState::Disabled; - if (tgm.state != new_tgm_state && tgm.state != TessGeometryMeshState::Unknown) { - tgm.num_switches++; - } - tgm.state = new_tgm_state; - - // Track depthTestEnable and depthCompareOp - auto& pipeline_create_info = pipeline_info->GraphicsCreateInfo(); - auto depth_stencil_state = pipeline_create_info.pDepthStencilState; - auto dynamic_state = pipeline_create_info.pDynamicState; - if (depth_stencil_state && dynamic_state) { - auto dynamic_state_begin = dynamic_state->pDynamicStates; - auto dynamic_state_end = dynamic_state->pDynamicStates + dynamic_state->dynamicStateCount; - - const bool dynamic_depth_test_enable = - std::find(dynamic_state_begin, dynamic_state_end, VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE) != dynamic_state_end; - const bool dynamic_depth_func = - std::find(dynamic_state_begin, dynamic_state_end, VK_DYNAMIC_STATE_DEPTH_COMPARE_OP) != dynamic_state_end; - - if (!dynamic_depth_test_enable) { - RecordSetDepthTestState(*cb_state, cb_state->nv.depth_compare_op, depth_stencil_state->depthTestEnable != VK_FALSE); - } - if (!dynamic_depth_func) { - RecordSetDepthTestState(*cb_state, depth_stencil_state->depthCompareOp, cb_state->nv.depth_test_enable); - } - } - } -} - void BestPractices::PostCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdBindPipeline(commandBuffer, pipelineBindPoint, pipeline, record_obj); @@ -509,6 +461,46 @@ void BestPractices::PostCallRecordCmdBindPipeline(VkCommandBuffer commandBuffer, break; } } + + if (VendorCheckEnabled(kBPVendorNVIDIA)) { + using TessGeometryMeshState = bp_state::CommandBufferStateNV::TessGeometryMesh::State; + auto& tgm = cb_state->nv.tess_geometry_mesh; + + // Make sure the message is only signaled once per command buffer + tgm.threshold_signaled = tgm.num_switches >= kNumBindPipelineTessGeometryMeshSwitchesThresholdNVIDIA; + + // Track pipeline switches with tessellation, geometry, and/or mesh shaders enabled, and disabled + auto tgm_stages = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT | VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT | + VK_SHADER_STAGE_GEOMETRY_BIT | VK_SHADER_STAGE_TASK_BIT_EXT | VK_SHADER_STAGE_MESH_BIT_EXT; + auto new_tgm_state = (pipeline_state->active_shaders & tgm_stages) != 0 ? TessGeometryMeshState::Enabled + : TessGeometryMeshState::Disabled; + if (tgm.state != new_tgm_state && tgm.state != TessGeometryMeshState::Unknown) { + tgm.num_switches++; + } + tgm.state = new_tgm_state; + + // Track depthTestEnable and depthCompareOp + auto& pipeline_create_info = pipeline_state->GraphicsCreateInfo(); + auto depth_stencil_state = pipeline_create_info.pDepthStencilState; + auto dynamic_state = pipeline_create_info.pDynamicState; + if (depth_stencil_state && dynamic_state) { + auto dynamic_state_begin = dynamic_state->pDynamicStates; + auto dynamic_state_end = dynamic_state->pDynamicStates + dynamic_state->dynamicStateCount; + + const bool dynamic_depth_test_enable = + std::find(dynamic_state_begin, dynamic_state_end, VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE) != dynamic_state_end; + const bool dynamic_depth_func = + std::find(dynamic_state_begin, dynamic_state_end, VK_DYNAMIC_STATE_DEPTH_COMPARE_OP) != dynamic_state_end; + + if (!dynamic_depth_test_enable) { + RecordSetDepthTestState(*cb_state, cb_state->nv.depth_compare_op, + depth_stencil_state->depthTestEnable != VK_FALSE); + } + if (!dynamic_depth_func) { + RecordSetDepthTestState(*cb_state, depth_stencil_state->depthCompareOp, cb_state->nv.depth_test_enable); + } + } + } } } } diff --git a/layers/best_practices/bp_render_pass.cpp b/layers/best_practices/bp_render_pass.cpp index f7a645fe893..1a1a61be5fd 100644 --- a/layers/best_practices/bp_render_pass.cpp +++ b/layers/best_practices/bp_render_pass.cpp @@ -300,88 +300,84 @@ bool BestPractices::ValidateCmdBeginRendering(VkCommandBuffer commandBuffer, con return skip; } -void BestPractices::PreCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { - RecordCmdEndRenderingCommon(commandBuffer); +void BestPractices::PostCallRecordCmdEndRenderPass(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { + { + auto cb_state = GetWrite(commandBuffer); + if (auto rp_state = cb_state->activeRenderPass.get()) { + RecordCmdEndRenderingCommon(*cb_state, *rp_state); + } - ValidationStateTracker::PreCallRecordCmdEndRenderPass(commandBuffer, record_obj); - auto cb_state = GetWrite(commandBuffer); - if (cb_state) { // Add Deferred Queue cb_state->queue_submit_functions.insert(cb_state->queue_submit_functions.end(), cb_state->queue_submit_functions_after_render_pass.begin(), cb_state->queue_submit_functions_after_render_pass.end()); cb_state->queue_submit_functions_after_render_pass.clear(); } + + // Above logic relies on render pass state not being destroyed yet + // But also can't have scope lock on command buffer state + ValidationStateTracker::PostCallRecordCmdEndRenderPass(commandBuffer, record_obj); } -void BestPractices::PreCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassInfo, - const RecordObject& record_obj) { - RecordCmdEndRenderingCommon(commandBuffer); +void BestPractices::PostCallRecordCmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassInfo, + const RecordObject& record_obj) { + { + auto cb_state = GetWrite(commandBuffer); + if (auto rp_state = cb_state->activeRenderPass.get()) { + RecordCmdEndRenderingCommon(*cb_state, *rp_state); + } - ValidationStateTracker::PreCallRecordCmdEndRenderPass2(commandBuffer, pSubpassInfo, record_obj); - auto cb_state = GetWrite(commandBuffer); - if (cb_state) { // Add Deferred Queue cb_state->queue_submit_functions.insert(cb_state->queue_submit_functions.end(), cb_state->queue_submit_functions_after_render_pass.begin(), cb_state->queue_submit_functions_after_render_pass.end()); cb_state->queue_submit_functions_after_render_pass.clear(); } -} - -void BestPractices::PreCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassInfo, - const RecordObject& record_obj) { - PreCallRecordCmdEndRenderPass2(commandBuffer, pSubpassInfo, record_obj); -} - -void BestPractices::PreCallRecordCmdEndRendering(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { - RecordCmdEndRenderingCommon(commandBuffer); - ValidationStateTracker::PreCallRecordCmdEndRendering(commandBuffer, record_obj); + // Above logic relies on render pass state not being destroyed yet + // But also can't have scope lock on command buffer state + ValidationStateTracker::PostCallRecordCmdEndRenderPass2(commandBuffer, pSubpassInfo, record_obj); } -void BestPractices::PreCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { - PreCallRecordCmdEndRendering(commandBuffer, record_obj); +void BestPractices::PostCallRecordCmdEndRenderPass2KHR(VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassInfo, + const RecordObject& record_obj) { + PostCallRecordCmdEndRenderPass2(commandBuffer, pSubpassInfo, record_obj); } -void BestPractices::PreCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, - VkSubpassContents contents, const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents, record_obj); - RecordCmdBeginRenderingCommon(commandBuffer); - RecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin); -} +void BestPractices::PostCallRecordCmdEndRendering(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { + { + auto cb_state = GetWrite(commandBuffer); + if (auto rp_state = cb_state->activeRenderPass.get()) { + RecordCmdEndRenderingCommon(*cb_state, *rp_state); + } + } -void BestPractices::PreCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, - const VkSubpassBeginInfo* pSubpassBeginInfo, const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdBeginRenderPass2(commandBuffer, pRenderPassBegin, pSubpassBeginInfo, record_obj); - RecordCmdBeginRenderingCommon(commandBuffer); - RecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin); + // Above logic relies on render pass state not being destroyed yet + // But also can't have scope lock on command buffer state + ValidationStateTracker::PostCallRecordCmdEndRendering(commandBuffer, record_obj); } -void BestPractices::PreCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer, - const VkRenderPassBeginInfo* pRenderPassBegin, - const VkSubpassBeginInfo* pSubpassBeginInfo, - const RecordObject& record_obj) { - PreCallRecordCmdBeginRenderPass2(commandBuffer, pRenderPassBegin, pSubpassBeginInfo, record_obj); +void BestPractices::PostCallRecordCmdEndRenderingKHR(VkCommandBuffer commandBuffer, const RecordObject& record_obj) { + PostCallRecordCmdEndRendering(commandBuffer, record_obj); } -void BestPractices::PreCallRecordCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, - const RecordObject& record_obj) { - ValidationStateTracker::PreCallRecordCmdBeginRendering(commandBuffer, pRenderingInfo, record_obj); - RecordCmdBeginRenderingCommon(commandBuffer); +void BestPractices::PostCallRecordCmdBeginRendering(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, + const RecordObject& record_obj) { + ValidationStateTracker::PostCallRecordCmdBeginRendering(commandBuffer, pRenderingInfo, record_obj); + auto cb_state = GetWrite(commandBuffer); + RecordCmdBeginRenderingCommon(*cb_state); } -void BestPractices::PreCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, - const RecordObject& record_obj) { - PreCallRecordCmdBeginRendering(commandBuffer, pRenderingInfo, record_obj); +void BestPractices::PostCallRecordCmdBeginRenderingKHR(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo, + const RecordObject& record_obj) { + PostCallRecordCmdBeginRendering(commandBuffer, pRenderingInfo, record_obj); } void BestPractices::PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents, const RecordObject& record_obj) { ValidationStateTracker::PostCallRecordCmdNextSubpass(commandBuffer, contents, record_obj); - RecordCmdNextSubpass(commandBuffer); - auto cb_state = GetWrite(commandBuffer); + RecordCmdNextSubpass(*cb_state); auto rp = cb_state->activeRenderPass.get(); ASSERT_AND_RETURN(rp); @@ -405,11 +401,9 @@ void BestPractices::PostCallRecordCmdNextSubpass(VkCommandBuffer commandBuffer, } } -void BestPractices::RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin) { +void BestPractices::RecordCmdBeginRenderPass(bp_state::CommandBuffer& cb_state, const VkRenderPassBeginInfo* pRenderPassBegin) { if (!pRenderPassBegin) return; - auto cb = GetWrite(commandBuffer); - auto rp_state = Get(pRenderPassBegin->renderPass); ASSERT_AND_RETURN(rp_state); @@ -453,7 +447,7 @@ void BestPractices::RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, cons } } - QueueValidateImageView(cb->queue_submit_functions, Func::vkCmdBeginRenderPass, image_view.get(), usage); + QueueValidateImageView(cb_state.queue_submit_functions, Func::vkCmdBeginRenderPass, image_view.get(), usage); } // Check store ops @@ -490,14 +484,13 @@ void BestPractices::RecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, cons } } - QueueValidateImageView(cb->queue_submit_functions_after_render_pass, Func::vkCmdEndRenderPass, image_view.get(), usage); + QueueValidateImageView(cb_state.queue_submit_functions_after_render_pass, Func::vkCmdEndRenderPass, image_view.get(), + usage); } } -void BestPractices::RecordCmdBeginRenderingCommon(VkCommandBuffer commandBuffer) { - auto cb_state = GetWrite(commandBuffer); - - auto rp = cb_state->activeRenderPass.get(); +void BestPractices::RecordCmdBeginRenderingCommon(bp_state::CommandBuffer& cb_state) { + auto rp = cb_state.activeRenderPass.get(); ASSERT_AND_RETURN(rp); if (VendorCheckEnabled(kBPVendorNVIDIA)) { @@ -532,14 +525,14 @@ void BestPractices::RecordCmdBeginRenderingCommon(VkCommandBuffer commandBuffer) const uint32_t attachment_index = depth_attachment->attachment; if (attachment_index != VK_ATTACHMENT_UNUSED) { load_op.emplace(rp->create_info.pAttachments[attachment_index].loadOp); - depth_image_view = cb_state->active_attachments[attachment_index].image_view; + depth_image_view = cb_state.active_attachments[attachment_index].image_view; } } } - for (uint32_t i = 0; i < cb_state->active_render_pass_begin_info.clearValueCount; ++i) { + for (uint32_t i = 0; i < cb_state.active_render_pass_begin_info.clearValueCount; ++i) { const auto& attachment = rp->create_info.pAttachments[i]; if (attachment.loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) { - const auto& clear_color = cb_state->active_render_pass_begin_info.pClearValues[i].color; + const auto& clear_color = cb_state.active_render_pass_begin_info.pClearValues[i].color; RecordClearColor(attachment.format, clear_color); } } @@ -548,46 +541,41 @@ void BestPractices::RecordCmdBeginRenderingCommon(VkCommandBuffer commandBuffer) if (depth_image_view && (depth_image_view->create_info.subresourceRange.aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) != 0U) { const VkImage depth_image = depth_image_view->image_state->VkHandle(); const VkImageSubresourceRange& subresource_range = depth_image_view->create_info.subresourceRange; - RecordBindZcullScope(*cb_state, depth_image, subresource_range); + RecordBindZcullScope(cb_state, depth_image, subresource_range); } else { - RecordUnbindZcullScope(*cb_state); + RecordUnbindZcullScope(cb_state); } if (load_op) { if (*load_op == VK_ATTACHMENT_LOAD_OP_CLEAR || *load_op == VK_ATTACHMENT_LOAD_OP_DONT_CARE) { - RecordResetScopeZcullDirection(*cb_state); + RecordResetScopeZcullDirection(cb_state); } } } - if (cb_state->activeRenderPass) { + if (cb_state.activeRenderPass) { // Spec states that after BeginRenderPass all resources should be rebound - if (cb_state->activeRenderPass->has_multiview_enabled) { - cb_state->UnbindResources(); + if (cb_state.activeRenderPass->has_multiview_enabled) { + cb_state.UnbindResources(); } } } -void BestPractices::RecordCmdEndRenderingCommon(VkCommandBuffer commandBuffer) { - auto cb_state = GetWrite(commandBuffer); - - auto rp = cb_state->activeRenderPass.get(); - ASSERT_AND_RETURN(rp); - +void BestPractices::RecordCmdEndRenderingCommon(bp_state::CommandBuffer& cb_state, const vvl::RenderPass& rp_state) { if (VendorCheckEnabled(kBPVendorNVIDIA)) { std::optional store_op; - if (rp->use_dynamic_rendering || rp->use_dynamic_rendering_inherited) { - const auto depth_attachment = rp->dynamic_rendering_begin_rendering_info.pDepthAttachment; + if (rp_state.use_dynamic_rendering || rp_state.use_dynamic_rendering_inherited) { + const auto depth_attachment = rp_state.dynamic_rendering_begin_rendering_info.pDepthAttachment; if (depth_attachment) { store_op.emplace(depth_attachment->storeOp); } } else { - if (rp->create_info.subpassCount > 0) { - const uint32_t last_subpass = rp->create_info.subpassCount - 1; - const auto depth_attachment = rp->create_info.pSubpasses[last_subpass].pDepthStencilAttachment; + if (rp_state.create_info.subpassCount > 0) { + const uint32_t last_subpass = rp_state.create_info.subpassCount - 1; + const auto depth_attachment = rp_state.create_info.pSubpasses[last_subpass].pDepthStencilAttachment; if (depth_attachment) { const uint32_t attachment = depth_attachment->attachment; if (attachment != VK_ATTACHMENT_UNUSED) { - store_op.emplace(rp->create_info.pAttachments[attachment].storeOp); + store_op.emplace(rp_state.create_info.pAttachments[attachment].storeOp); } } } @@ -595,11 +583,11 @@ void BestPractices::RecordCmdEndRenderingCommon(VkCommandBuffer commandBuffer) { if (store_op) { if (*store_op == VK_ATTACHMENT_STORE_OP_DONT_CARE || *store_op == VK_ATTACHMENT_STORE_OP_NONE) { - RecordResetScopeZcullDirection(*cb_state); + RecordResetScopeZcullDirection(cb_state); } } - RecordUnbindZcullScope(*cb_state); + RecordUnbindZcullScope(cb_state); } } @@ -639,24 +627,21 @@ bool BestPractices::PreCallValidateCmdBeginRenderingKHR(VkCommandBuffer commandB void BestPractices::PostCallRecordCmdNextSubpass2KHR(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo, const RecordObject& record_obj) { - StateTracker::PostCallRecordCmdNextSubpass2(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo, record_obj); - RecordCmdNextSubpass(commandBuffer); + PostCallRecordCmdNextSubpass2(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo, record_obj); } void BestPractices::PostCallRecordCmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdNextSubpass2(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo, record_obj); - RecordCmdNextSubpass(commandBuffer); + auto cb_state = GetWrite(commandBuffer); + RecordCmdNextSubpass(*cb_state); } -void BestPractices::RecordCmdNextSubpass(VkCommandBuffer commandBuffer) { - auto cb_state = GetWrite(commandBuffer); - if (cb_state) { - if (cb_state->activeRenderPass) { - // Spec states that after NextSubpass all resources should be rebound - if (cb_state->activeRenderPass->has_multiview_enabled) { - cb_state->UnbindResources(); - } +void BestPractices::RecordCmdNextSubpass(bp_state::CommandBuffer& cb_state) { + if (cb_state.activeRenderPass) { + // Spec states that after NextSubpass all resources should be rebound + if (cb_state.activeRenderPass->has_multiview_enabled) { + cb_state.UnbindResources(); } } } @@ -673,12 +658,11 @@ void BestPractices::PostCallRecordCmdPushConstants2KHR(VkCommandBuffer commandBu StateTracker::PostCallRecordCmdPushConstants2KHR(commandBuffer, pPushConstantsInfo, record_obj); } -void BestPractices::PostRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin) { +void BestPractices::PostRecordCmdBeginRenderPass(bp_state::CommandBuffer& cb_state, const VkRenderPassBeginInfo* pRenderPassBegin) { // Reset the renderpass state - auto cb_state = GetWrite(commandBuffer); // TODO - move this logic to the Render Pass state as cb->has_draw_cmd should stay true for lifetime of command buffer - cb_state->has_draw_cmd = false; - auto& render_pass_state = cb_state->render_pass_state; + cb_state.has_draw_cmd = false; + auto& render_pass_state = cb_state.render_pass_state; render_pass_state.touchesAttachments.clear(); render_pass_state.earlyClearAttachments.clear(); render_pass_state.numDrawCallsDepthOnly = 0; @@ -689,7 +673,7 @@ void BestPractices::PostRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, // Don't reset state related to pipeline state. // Reset NV state - cb_state->nv = {}; + cb_state.nv = {}; if (auto rp_state = Get(pRenderPassBegin->renderPass)) { // track depth / color attachment usage within the renderpass @@ -699,10 +683,10 @@ void BestPractices::PostRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, if (rp_state->create_info.pSubpasses[i].colorAttachmentCount > 0) render_pass_state.colorAttachment = true; } - if (cb_state->activeRenderPass) { + if (cb_state.activeRenderPass) { // Spec states that after BeginRenderPass all resources should be rebound - if (cb_state->activeRenderPass->has_multiview_enabled) { - cb_state->UnbindResources(); + if (cb_state.activeRenderPass->has_multiview_enabled) { + cb_state.UnbindResources(); } } } @@ -711,13 +695,19 @@ void BestPractices::PostRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, void BestPractices::PostCallRecordCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin, contents, record_obj); - PostRecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin); + auto cb_state = GetWrite(commandBuffer); + PostRecordCmdBeginRenderPass(*cb_state, pRenderPassBegin); + RecordCmdBeginRenderingCommon(*cb_state); + RecordCmdBeginRenderPass(*cb_state, pRenderPassBegin); } void BestPractices::PostCallRecordCmdBeginRenderPass2(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfo* pSubpassBeginInfo, const RecordObject& record_obj) { StateTracker::PostCallRecordCmdBeginRenderPass2(commandBuffer, pRenderPassBegin, pSubpassBeginInfo, record_obj); - PostRecordCmdBeginRenderPass(commandBuffer, pRenderPassBegin); + auto cb_state = GetWrite(commandBuffer); + PostRecordCmdBeginRenderPass(*cb_state, pRenderPassBegin); + RecordCmdBeginRenderingCommon(*cb_state); + RecordCmdBeginRenderPass(*cb_state, pRenderPassBegin); } void BestPractices::PostCallRecordCmdBeginRenderPass2KHR(VkCommandBuffer commandBuffer,