Finished migration of validation checks out of cmd_pipeline.c
authorTobin Ehlis <tobin@lunarg.com>
Thu, 17 Sep 2015 20:18:16 +0000 (14:18 -0600)
committerTobin Ehlis <tobin@lunarg.com>
Mon, 21 Sep 2015 17:42:02 +0000 (11:42 -0600)
Added check to DrawState layer for submission of Primary cmd buffer in vkCmdExecuteCommands() call. Added a test to verify the check.

Replaced some other checks in cmd_pipeline.c with asserts and the checks themselves are already handled in ParamChecker.

layers/draw_state.cpp
layers/draw_state.h
layers/vk_validation_layer_details.md

index cf101b73e408e72109425bfbd03d8010f60f9b29..10b56d88a9f4ff6b8bf7efb3547edad208341b8f 100644 (file)
@@ -3115,10 +3115,20 @@ VK_LAYER_EXPORT void VKAPI vkCmdExecuteCommands(VkCmdBuffer cmdBuffer, uint32_t
         if (!pCB->activeRenderPass) {
             skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_NO_ACTIVE_RENDERPASS, "DS",
                     "Incorrect call to vkCmdExecuteCommands() without an active RenderPass.");
-        } else {
-            updateCBTracking(cmdBuffer);
-            skipCall |= addCmd(pCB, CMD_EXECUTECOMMANDS);
         }
+        GLOBAL_CB_NODE* pSubCB = NULL;
+        for (uint32_t i=0; i<cmdBuffersCount; i++) {
+            pSubCB = getCBNode(pCmdBuffers[i]);
+            if (!pSubCB) {
+                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_SECONDARY_CMD_BUFFER, "DS",
+                    "vkCmdExecuteCommands() called w/ invalid Cmd Buffer %p in element %u of pCmdBuffers array.", (void*)pCmdBuffers[i], i);
+            } else if (VK_CMD_BUFFER_LEVEL_PRIMARY == pSubCB->createInfo.level) {
+                skipCall |= log_msg(mdd(pCB->cmdBuffer), VK_DBG_REPORT_ERROR_BIT, (VkDbgObjectType) 0, 0, 0, DRAWSTATE_INVALID_SECONDARY_CMD_BUFFER, "DS",
+                    "vkCmdExecuteCommands() called w/ Primary Cmd Buffer %p in element %u of pCmdBuffers array. All cmd buffers in pCmdBuffers array must be secondary.", (void*)pCmdBuffers[i], i);
+            }
+        }
+        updateCBTracking(cmdBuffer);
+        skipCall |= addCmd(pCB, CMD_EXECUTECOMMANDS);
     }
     if (VK_FALSE == skipCall)
         get_dispatch_table(draw_state_device_table_map, cmdBuffer)->CmdExecuteCommands(cmdBuffer, cmdBuffersCount, pCmdBuffers);
@@ -3407,6 +3417,8 @@ VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice dev, const
         return (PFN_vkVoidFunction) vkCmdNextSubpass;
     if (!strcmp(funcName, "vkCmdEndRenderPass"))
         return (PFN_vkVoidFunction) vkCmdEndRenderPass;
+    if (!strcmp(funcName, "vkCmdExecuteCommands"))
+        return (PFN_vkVoidFunction) vkCmdExecuteCommands;
 
     VkLayerDispatchTable* pTable = get_dispatch_table(draw_state_device_table_map, dev);
     if (deviceExtMap.size() == 0 || deviceExtMap[pTable].debug_marker_enabled)
index 5492cd7c0b2585659c40db6ea160d3c765f154bd..0b0ea2f1f1e68781d6696cbc27643cf4c654306f 100644 (file)
@@ -52,6 +52,7 @@ typedef enum _DRAW_STATE_ERROR
     DRAWSTATE_NO_END_CMD_BUFFER,                // Must call vkEndCommandBuffer() before QueueSubmit on that cmdBuffer
     DRAWSTATE_NO_BEGIN_CMD_BUFFER,              // Binding cmds or calling End on CB that never had vkBeginCommandBuffer() called on it
     DRAWSTATE_CMD_BUFFER_SINGLE_SUBMIT_VIOLATION, // Cmd Buffer created with VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT flag is submitted multiple times
+    DRAWSTATE_INVALID_SECONDARY_CMD_BUFFER,     // vkCmdExecuteCommands() called with a primary cmdBuffer in pCmdBuffers array
     DRAWSTATE_VIEWPORT_NOT_BOUND,               // Draw submitted with no viewport state object bound
     DRAWSTATE_LINE_WIDTH_NOT_BOUND,             // Draw submitted with no line width state object bound
     DRAWSTATE_DEPTH_BIAS_NOT_BOUND,             // Draw submitted with no depth bias state object bound
index 8dd8b411ef3b158ffe63c9550415c32315acf07d..3c7f521404a5217b34a4ad811fec369bc5ca3194 100644 (file)
@@ -28,6 +28,7 @@ The DrawState layer tracks state leading into Draw cmds. This includes the Pipel
 | Cmd Buffer End | Verifies that EndCommandBuffer was called for this cmdBuffer at QueueSubmit time | NO_END_CMD_BUFFER | vkQueueSubmit | NoEndCmdBuffer | NA |
 | Cmd Buffer Begin | Check that BeginCommandBuffer was called for this command buffer when binding commands or calling end | NO_BEGIN_CMD_BUFFER | vkEndCommandBuffer vkCmdBindPipeline vkCmdBindDynamicViewportState vkCmdBindDynamicLineWidthState vkCmdBindDynamicDepthBiasState vkCmdBindDynamicBlendState vkCmdBindDynamicDepthBoundsState vkCmdBindDynamicStencilState vkCmdBindDescriptorSets vkCmdBindIndexBuffer vkCmdBindVertexBuffers vkCmdDraw vkCmdDrawIndexed vkCmdDrawIndirect vkCmdDrawIndexedIndirect vkCmdDispatch vkCmdDispatchIndirect vkCmdCopyBuffer vkCmdCopyImage vkCmdBlitImage vkCmdCopyBufferToImage vkCmdCopyImageToBuffer vkCmdUpdateBuffer vkCmdFillBuffer vkCmdClearColorAttachment vkCmdClearDepthStencilAttachment vkCmdClearColorImage vkCmdClearDepthStencilImage vkCmdResolveImage vkCmdSetEvent vkCmdResetEvent vkCmdWaitEvents vkCmdPipelineBarrier vkCmdBeginQuery vkCmdEndQuery vkCmdResetQueryPool vkCmdWriteTimestamp | NoBeginCmdBuffer | NA |
 | Cmd Buffer Submit Count | Verify that ONE_TIME submit cmdbuffer is not submitted multiple times | CMD_BUFFER_SINGLE_SUBMIT_VIOLATION | vkBeginCommandBuffer, vkQueueSubmit | CmdBufferTwoSubmits | NA |
+| Valid Secondary CmdBuffer | Validates that no primary command buffers are sent to vkCmdExecuteCommands() are | INVALID_SECONDARY_CMD_BUFFER | vkCmdExecuteCommands | ExecuteCommandsPrimaryCB | NA |
 | Descriptor Type | Verify Descriptor type in bound descriptor set layout matches descriptor type specified in update | DESCRIPTOR_TYPE_MISMATCH | vkUpdateDescriptorSets | DSTypeMismatch | With various DS API updates, need to revisit this code |
 | DS Update Size | DS update out of bounds for given layout section | DESCRIPTOR_UPDATE_OUT_OF_BOUNDS | vkUpdateDescriptorSets | DSUpdateOutOfBounds | NA |
 | DS Update Index | DS update binding too large for layout count | INVALID_UPDATE_INDEX | vkUpdateDescriptorSets | InvalidDSUpdateIndex | NA |
@@ -101,6 +102,7 @@ Additional work to be done
  6. VkImageViewCreateInfo.format must be set
  7. For vkCreateGraphicsPipelines, correctly handle array of pCreateInfos and array of pStages within each element of pCreatInfos
  8. Check for valid VkIndexType in vkCmdBindIndexBuffer() should be in PreCmdBindIndexBuffer() call
+ 9. Check for valid VkPipelineBindPoint in vkCmdBindPipeline() & vkCmdBindDescriptorSets() should be in PreCmdBindPipeline() & PreCmdBindDescriptorSets() calls respectively.
 
 ## Image