From 43a11ea407557a359bdb1afb16aa231fe908f2da Mon Sep 17 00:00:00 2001 From: Michael Lentine Date: Wed, 3 Feb 2016 10:55:23 -0600 Subject: layers: Validate secondary command buffers are most recently bound. Secondary cmd buffer bound to new primary cmd buffer cannot be submitted under the first primary cmd buffer. This is based on spec valid usage restriction in vkQueueSubmit: Any given element of pCommandBuffers must not contain commands that execute a secondary command buffer, if that secondary command buffer has been recorded in another primary command buffer after it was recorded into this VkCommandBuffer --- layers/draw_state.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'layers/draw_state.cpp') diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index ee343dbd..01879524 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -2805,6 +2805,7 @@ static void resetCB(layer_data* my_data, const VkCommandBuffer cb) pCB->imageLayoutMap.clear(); pCB->drawData.clear(); pCB->currentDrawData.buffers.clear(); + pCB->primaryCommandBuffer = VK_NULL_HANDLE; pCB->secondaryCommandBuffers.clear(); pCB->dynamicOffsets.clear(); } @@ -3455,6 +3456,20 @@ static VkBool32 validateCommandBufferState(layer_data *dev_data, dev_data, dev_data->commandBufferMap[secondaryCmdBuffer]); GLOBAL_CB_NODE* pSubCB = getCBNode(dev_data, secondaryCmdBuffer); skipCall |= validateCommandBufferSimultaneousUse(dev_data, pSubCB); + if (pSubCB->primaryCommandBuffer != pCB->commandBuffer) { + log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, + __LINE__, + DRAWSTATE_COMMAND_BUFFER_SINGLE_SUBMIT_VIOLATION, "DS", + "CB %#" PRIxLEAST64 + " was submitted with secondary buffer %#" PRIxLEAST64 + " but that buffer has subsequently been bound to " + "primary cmd buffer %#" PRIxLEAST64 ".", + reinterpret_cast(pCB->commandBuffer), + reinterpret_cast(secondaryCmdBuffer), + reinterpret_cast( + pSubCB->primaryCommandBuffer)); + } } } if ((pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) && @@ -6593,6 +6608,7 @@ VK_LAYER_EXPORT VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(VkCommandBuffer pCB->beginInfo.flags &= ~VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; } } + pSubCB->primaryCommandBuffer = pCB->commandBuffer; pCB->secondaryCommandBuffers.insert(pSubCB->commandBuffer); dev_data->globalInFlightCmdBuffers.insert(pSubCB->commandBuffer); } -- cgit v1.2.3