}
}
-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) {
"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;
}