diff options
| author | Michael Lentine <mlentine@google.com> | 2016-02-03 09:20:33 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-02-04 12:20:17 -0700 |
| commit | 6bf4edeedb88a59d3d319f1d8bc2eb93ea3b0bdd (patch) | |
| tree | 3e292a7c20869fc1c13fc663cd6c767862360436 | |
| parent | 54090e4c4095666ee28be5aabcb72217ce3631f4 (diff) | |
| download | usermoji-6bf4edeedb88a59d3d319f1d8bc2eb93ea3b0bdd.tar.xz | |
layers: Validate command buffer is not being used simultaneously unless specified.
| -rw-r--r-- | layers/draw_state.cpp | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/layers/draw_state.cpp b/layers/draw_state.cpp index 909bb0d7..ee343dbd 100644 --- a/layers/draw_state.cpp +++ b/layers/draw_state.cpp @@ -3428,19 +3428,45 @@ void trackCommandBuffers(layer_data* my_data, VkQueue queue, uint32_t cmdBufferC } } -static VkBool32 validateCommandBufferState(layer_data* dev_data, GLOBAL_CB_NODE* pCB) -{ +bool validateCommandBufferSimultaneousUse(layer_data *dev_data, + GLOBAL_CB_NODE *pCB) { + bool skip_call = false; + if (dev_data->globalInFlightCmdBuffers.count(pCB->commandBuffer) && + !(pCB->beginInfo.flags & + VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) { + skip_call |= log_msg( + dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, 0, __LINE__, + DRAWSTATE_INVALID_FENCE, "DS", + "Command Buffer %#" PRIx64 " is already in use and is not marked " + "for simultaneous use.", + reinterpret_cast<uint64_t>(pCB->commandBuffer)); + } + return skip_call; +} + +static VkBool32 validateCommandBufferState(layer_data *dev_data, + GLOBAL_CB_NODE *pCB) { // Track in-use for resources off of primary and any secondary CBs VkBool32 skipCall = validateAndIncrementResources(dev_data, pCB); if (!pCB->secondaryCommandBuffers.empty()) { for (auto secondaryCmdBuffer : pCB->secondaryCommandBuffers) { - skipCall |= validateAndIncrementResources(dev_data, dev_data->commandBufferMap[secondaryCmdBuffer]); - } - } - if ((pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) && (pCB->submitCount > 1)) { - skipCall |= 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 begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted %#" PRIxLEAST64 " times.", - (uint64_t)(pCB->commandBuffer), pCB->submitCount); + skipCall |= validateAndIncrementResources( + dev_data, dev_data->commandBufferMap[secondaryCmdBuffer]); + GLOBAL_CB_NODE* pSubCB = getCBNode(dev_data, secondaryCmdBuffer); + skipCall |= validateCommandBufferSimultaneousUse(dev_data, pSubCB); + } + } + if ((pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT) && + (pCB->submitCount > 1)) { + skipCall |= + 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 begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT " + "set, but has been submitted %#" PRIxLEAST64 " times.", + (uint64_t)(pCB->commandBuffer), pCB->submitCount); } // Validate that cmd buffers have been updated if (CB_RECORDED != pCB->state) { @@ -3467,13 +3493,9 @@ static VkBool32 validateCommandBufferState(layer_data* dev_data, GLOBAL_CB_NODE* "You must call vkEndCommandBuffer() on CB %#" PRIxLEAST64 " before this call to vkQueueSubmit()!", (uint64_t)(pCB->commandBuffer)); } } - // If USAGE_SIMULTANEOUS_USE_BIT not set then CB cannot already be executing on device - if (!(pCB->beginInfo.flags & VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)) { - if (dev_data->globalInFlightCmdBuffers.find(pCB->commandBuffer) != dev_data->globalInFlightCmdBuffers.end()) { - skipCall |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)(pCB->commandBuffer), __LINE__, DRAWSTATE_INVALID_CB_SIMULTANEOUS_USE, "DS", - "Attempt to simultaneously execute CB %#" PRIxLEAST64 " w/o VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set!", (uint64_t)(pCB->commandBuffer)); - } - } + // If USAGE_SIMULTANEOUS_USE_BIT not set then CB cannot already be executing + // on device + skipCall |= validateCommandBufferSimultaneousUse(dev_data, pCB); return skipCall; } |
