layers: MR139, draw_state VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT checks
Added a set to track which secondary cmdBuffers are contained within a primary cmdBuffer.
Added new DRAWSTATE_INVALID_CB_SIMULTANEOUS_USE enum value for new error/warning
cases, along with line in documentation.
New validation issues and state updates are listed below.
While tracking cmdBuffers at QueueSubmit time:
1. Flag an error if a cmdBuffer is already in flight and does not have
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set
2. Account for tracking of secondary cmdBuffers (and their in_use resources)
that are submitted within a primary command buffer
When submitting secondary command buffers into primary command buffer at
CmdExecuteCommands time:
1. Flag an error if secondary cmdBuffer is in flight and doesn't have
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set.
2. Warn user if secondary cmdBuffer doesn't have
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT set but primary cmdBuffer does.
This causes primary cmdBuffer to be treated as if
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT isn't set.
3. Add secondary cmdBuffers to set off of primary cmdBuffer for tracking purposes
4. Add secondary cmdBuffers to inFlight set
diff --git a/layers/draw_state.h b/layers/draw_state.h
index 1ab4228..9f17bb9 100755
--- a/layers/draw_state.h
+++ b/layers/draw_state.h
@@ -86,6 +86,7 @@
DRAWSTATE_INVALID_DYNAMIC_OFFSET_COUNT, // DescriptorSets bound with different number of dynamic descriptors that were included in dynamicOffsetCount
DRAWSTATE_CLEAR_CMD_BEFORE_DRAW, // Clear cmd issued before any Draw in CommandBuffer, should use RenderPass Ops instead
DRAWSTATE_BEGIN_CB_INVALID_STATE, // CB state at Begin call is bad. Can be Primary/Secondary CB created with mismatched FB/RP information or CB in RECORDING state
+ DRAWSTATE_INVALID_CB_SIMULTANEOUS_USE, // CmdBuffer is being used in violation of VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT rules (i.e. simultaneous use w/o that bit set)
DRAWSTATE_INVALID_COMMAND_BUFFER_RESET, // Attempting to call Reset (or Begin on recorded cmdBuffer) that was allocated from Pool w/o VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT bit set
DRAWSTATE_VIEWPORT_SCISSOR_MISMATCH, // Count for viewports and scissors mismatch and/or state doesn't match count
DRAWSTATE_INVALID_IMAGE_ASPECT, // Image aspect is invalid for the current operation
@@ -524,6 +525,8 @@
unordered_map<VkImage, IMAGE_CMD_BUF_NODE> imageLayoutMap;
vector<DRAW_DATA> drawData;
DRAW_DATA currentDrawData;
+ // If cmd buffer is primary, track secondary command buffers pending execution
+ std::unordered_set<VkCommandBuffer> secondaryCommandBuffers;
} GLOBAL_CB_NODE;
typedef struct _SWAPCHAIN_NODE {