layers: LunarXChange #123 fix - Validate Update/FillBuffer outside RP
authorMark Lobodzinski <mark@lunarg.com>
Thu, 24 Sep 2015 15:51:47 +0000 (09:51 -0600)
committerMark Lobodzinski <mark@lunarg.com>
Fri, 25 Sep 2015 15:08:50 +0000 (09:08 -0600)
Validated that these are not called in an active RP, added validation tests
for these and some other renderpass-dependent APIs.

layers/draw_state.cpp
layers/vk_validation_layer_details.md

index 35f60357e9473716659c036e3d306768a2cfa630..915b940773035e64a1e6d53af62dbef41a3aa76f 100644 (file)
@@ -2570,6 +2570,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer des
         } else {
             skipCall |= report_error_no_cb_begin(cmdBuffer, "vkCmdBindIndexBuffer()");
         }
+        if (pCB->activeRenderPass) {
+            skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+                                (uint64_t)cmdBuffer, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
+                                "CmdUpdateBuffer cmd issued within an active RenderPass -- vkCmdUpdateBuffer "
+                                "may only be called outside of a RenderPass.");
+        }
     }
     if (VK_FALSE == skipCall)
         get_dispatch_table(draw_state_device_table_map, cmdBuffer)->CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
@@ -2586,6 +2592,12 @@ VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destB
         } else {
             skipCall |= report_error_no_cb_begin(cmdBuffer, "vkCmdBindIndexBuffer()");
         }
+        if (pCB->activeRenderPass) {
+            skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+                                (uint64_t)cmdBuffer, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
+                                "CmdFillBuffer cmd issued within an active RenderPass -- vkCmdFillBuffer "
+                                "may only be called outside of a RenderPass.");
+        }
     }
     if (VK_FALSE == skipCall)
         get_dispatch_table(draw_state_device_table_map, cmdBuffer)->CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
@@ -2611,8 +2623,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorAttachment(
                         " It is recommended you use RenderPass LOAD_OP_CLEAR on Color Attachments prior to any Draw.", reinterpret_cast<uint64_t>(cmdBuffer));
             }
             if (!pCB->activeRenderPass) {
-                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS",
-                        "Clear*Attachment cmd issued without an active RenderPass. vkCmdClearColorAttachment() must only be called inside of a RenderPass."
+                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+                        (uint64_t)cmdBuffer, 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS",
+                        "CmdClearColorAttachment cmd issued outside of an active RenderPass. "
+                        "vkCmdClearColorAttachment() must only be called inside of a RenderPass."
                         " vkCmdClearColorImage() should be used outside of a RenderPass.");
             } else {
                 updateCBTracking(cmdBuffer);
@@ -2672,9 +2686,11 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(
     if (pCB) {
         if (pCB->state == CB_UPDATE_ACTIVE) {
             if (pCB->activeRenderPass) {
-                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
-                        "Clear*Image cmd issued with an active RenderPass. vkCmdClearColorImage() must only be called outside of a RenderPass."
-                        " vkCmdClearColorAttachment() should be used within a RenderPass.");
+                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+                            (uint64_t)cmdBuffer, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
+                        "CmdClearColorImage cmd issued within an active RenderPass. "
+                        "vkCmdClearColorImage() must only be called outside of a RenderPass. "
+                        "vkCmdClearColorAttachment() should be used within a RenderPass.");
             } else {
                 updateCBTracking(cmdBuffer);
                 skipCall |= addCmd(pCB, CMD_CLEARCOLORIMAGE);
@@ -2699,8 +2715,10 @@ VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencilImage(
     if (pCB) {
         if (pCB->state == CB_UPDATE_ACTIVE) {
             if (pCB->activeRenderPass) {
-                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
-                        "Clear*Image cmd issued with an active RenderPass. vkCmdClearDepthStencilImage() must only be called outside of a RenderPass."
+                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, VK_OBJECT_TYPE_COMMAND_BUFFER,
+                        (uint64_t)cmdBuffer, 0, DRAWSTATE_INVALID_RENDERPASS_CMD, "DS",
+                        "CmdClearDepthStencilImage cmd issued within an active RenderPass. "
+                        "vkCmdClearDepthStencilImage() must only be called outside of a RenderPass."
                         " vkCmdClearDepthStencilAttachment() should be used within a RenderPass.");
             } else {
                 updateCBTracking(cmdBuffer);
index 261117d2769fdbde86084e84346ab275307a8d4a..fa60fd28c0f3b0de3f6b5fca7265317c7a707059 100644 (file)
@@ -39,8 +39,8 @@ The DrawState layer tracks state leading into Draw cmds. This includes the Pipel
 | Dynamic Blend State Binding | Verify that blend dynamic state bound when color blend enabled | BLEND_NOT_BOUND |vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect | TODO | Verify this check and Write targeted test |
 | Dynamic Depth Bounds State Binding | Verify that depth bounds dynamic state bound when depth enabled | DEPTH_BOUNDS_NOT_BOUND |vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect | TODO | Verify this check and Write targeted test |
 | Dynamic Stencil State Binding | Verify that stencil dynamic state bound when depth enabled | STENCIL_NOT_BOUND |vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect | TODO | Verify this check and Write targeted test |
-| RenderPass misuse | Tests for the following: that BeginRenderPass, ResolveImage, ClearColorImage, ClearDepthStencilImage are not called during an active Renderpass, and that binding compute descriptior sets or pipelines does not take place during an active  | INVALID_RENDERPASS_CMD | vkCmdBindPipeline vkCmdBindDescriptorSets vkCmdBlitImage vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdBeginRenderPass | RenderPassWithinRenderPass | NA |
-| Correct use of RenderPass | Validates that rendering commands are issued inside an active RenderPass | NO_ACTIVE_RENDERPASS | vkCmdBindPipeline vkCmdSetViewport vkCmdSetLineWidth vkCmdSetDepthBias vkCmdSetBlendConstants vkCmdSetDepthBounds vkCmdSetStencilCompareMask vkCmdSetStencilWriteMask vkCmdSetStencilReference vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommands vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect | BindPipelineNoRenderPass VtxBufferNoRenderPass | NA |
+| RenderPass misuse | Tests for the following: that BeginRenderPass, ResolveImage, ClearColorImage, ClearDepthStencilImage, CmdUpdateBuffer, CmdFillBuffer, are not called during an active Renderpass, and that binding compute descriptor sets or pipelines does not take place during an active Renderpass  | INVALID_RENDERPASS_CMD | vkCmdBindPipeline vkCmdBindDescriptorSets vkCmdBlitImage vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdBeginRenderPass vkCmdUpdateBuffer vkCmdFillBuffer | RenderPassWithinRenderPass UpdateBufferWithinRenderPass ClearColorImageWithinRenderPass ClearDepthStencilImageWithinRenderPass FillBufferWithinRenderPass | NA |
+| Correct use of RenderPass | Validates that rendering commands are issued inside an active RenderPass | NO_ACTIVE_RENDERPASS | vkCmdBindPipeline vkCmdSetViewport vkCmdSetLineWidth vkCmdSetDepthBias vkCmdSetBlendConstants vkCmdSetDepthBounds vkCmdSetStencilCompareMask vkCmdSetStencilWriteMask vkCmdSetStencilReference vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdNextSubpass vkCmdEndRenderPass vkCmdExecuteCommands vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect | BindPipelineNoRenderPass VtxBufferNoRenderPass ClearColorAttachmentsOutsideRenderPass | NA |
 | Valid RenderPass | Flag error if attempt made to Begin/End/Continue a NULL or otherwise invalid RenderPass object | INVALID_RENDERPASS | vkCmdBeginRenderPass vkCmdEndRenderPass vkBeginCommandBuffer | NullRenderPass | NA |
 | DescriptorSet Updated | Warn user if DescriptorSet bound that was never updated | DESCRIPTOR_SET_NOT_UPDATED | vkCmdBindDescriptorSets | DescriptorSetNotUpdated | NA |
 | Correct Clear Use | Warn user if CmdClear for Color or DepthStencil issued to Cmd Buffer prior to a Draw Cmd. RenderPass LOAD_OP_CLEAR is preferred in this case. | CLEAR_CMD_BEFORE_DRAW | vkCmdClearColorImage vkCmdClearDepthStencilImage | ClearCmdNoDraw | NA |