aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorTobin Ehlis <tobine@google.com>2016-12-21 12:22:11 -0700
committerTobin Ehlis <tobine@google.com>2016-12-23 10:09:14 -0700
commit292069a077d6ff4db4a90a9c6a227b9caefd3e78 (patch)
tree9ecc2ea5417fa96ac05e691dc37a8a45be1eb249 /layers/core_validation.cpp
parent2b800f9c3d3dce98b18922f9dff6eaecfe8de695 (diff)
downloadusermoji-292069a077d6ff4db4a90a9c6a227b9caefd3e78.tar.xz
layers:Refactor CmdDrawIndexedIndirect()
Refactor CmdDrawIndexedIndirect() to use pre/post pattern.
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 6538b61a..fe7a8098 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -8178,37 +8178,49 @@ CmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize off
}
}
+static bool PreCallValidateCmdDrawIndexedIndirect(
+ layer_data *dev_data, VkCommandBuffer cmd_buffer, VkBuffer buffer, bool indexed, VkPipelineBindPoint bind_point,
+ GLOBAL_CB_NODE **cb_state, BUFFER_STATE **buffer_state,
+ vector<std::tuple<cvdescriptorset::DescriptorSet *, std::map<uint32_t, descriptor_req>, std::vector<uint32_t> const *>>
+ *active_set_bindings_pairs,
+ std::unordered_set<uint32_t> *active_bindings, const char *caller) {
+ bool skip = ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DRAWINDEXEDINDIRECT, cb_state,
+ active_set_bindings_pairs, active_bindings, caller, VALIDATION_ERROR_01393);
+ *buffer_state = getBufferState(dev_data, buffer);
+ skip |= ValidateMemoryIsBoundToBuffer(dev_data, *buffer_state, caller);
+ return skip;
+}
+
+static void PostCallRecordCmdDrawIndexedIndirect(
+ layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point, BUFFER_STATE *buffer_state,
+ vector<std::tuple<cvdescriptorset::DescriptorSet *, std::map<uint32_t, descriptor_req>, std::vector<uint32_t> const *>>
+ *active_set_bindings_pairs,
+ std::unordered_set<uint32_t> *active_bindings) {
+ UpdateStateCmdDrawType(dev_data, cb_state, bind_point, CMD_DRAWINDEXEDINDIRECT, DRAW_INDEXED_INDIRECT,
+ active_set_bindings_pairs, active_bindings);
+ AddCommandBufferBindingBuffer(dev_data, cb_state, buffer_state);
+}
+
VKAPI_ATTR void VKAPI_CALL
CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t count, uint32_t stride) {
- bool skip_call = false;
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(commandBuffer), layer_data_map);
vector<std::tuple<cvdescriptorset::DescriptorSet *, std::map<uint32_t, descriptor_req>, std::vector<uint32_t> const *>>
active_set_bindings_pairs;
std::unordered_set<uint32_t> active_bindings;
+ GLOBAL_CB_NODE *cb_state = nullptr;
+ BUFFER_STATE *buffer_state = nullptr;
std::unique_lock<std::mutex> lock(global_lock);
-
- auto cb_node = getCBNode(dev_data, commandBuffer);
- auto buffer_state = getBufferState(dev_data, buffer);
- if (cb_node && buffer_state) {
- skip_call |= ValidateMemoryIsBoundToBuffer(dev_data, buffer_state, "vkCmdDrawIndexedIndirect()");
- AddCommandBufferBindingBuffer(dev_data, cb_node, buffer_state);
- skip_call |= ValidateCmd(dev_data, cb_node, CMD_DRAWINDEXEDINDIRECT, "vkCmdDrawIndexedIndirect()");
- UpdateCmdBufferLastCmd(dev_data, cb_node, CMD_DRAWINDEXEDINDIRECT);
- cb_node->drawCount[DRAW_INDEXED_INDIRECT]++;
- skip_call |= ValidateDrawState(dev_data, cb_node, false, VK_PIPELINE_BIND_POINT_GRAPHICS, &active_set_bindings_pairs,
- &active_bindings, "vkCmdDrawIndexedIndirect");
- UpdateDrawState(dev_data, cb_node, VK_PIPELINE_BIND_POINT_GRAPHICS, &active_set_bindings_pairs, &active_bindings);
- MarkStoreImagesAndBuffersAsWritten(dev_data, cb_node);
- if (!skip_call) {
- updateResourceTrackingOnDraw(cb_node);
- }
- skip_call |= outsideRenderPass(dev_data, cb_node, "vkCmdDrawIndexedIndirect()", VALIDATION_ERROR_01393);
- } else {
- assert(0);
- }
+ bool skip = PreCallValidateCmdDrawIndexedIndirect(dev_data, commandBuffer, buffer, true, VK_PIPELINE_BIND_POINT_GRAPHICS,
+ &cb_state, &buffer_state, &active_set_bindings_pairs, &active_bindings,
+ "vkCmdDrawIndexedIndirect()");
lock.unlock();
- if (!skip_call)
+ if (!skip) {
dev_data->dispatch_table.CmdDrawIndexedIndirect(commandBuffer, buffer, offset, count, stride);
+ lock.lock();
+ PostCallRecordCmdDrawIndexedIndirect(dev_data, cb_state, VK_PIPELINE_BIND_POINT_GRAPHICS, buffer_state,
+ &active_set_bindings_pairs, &active_bindings);
+ lock.unlock();
+ }
}
VKAPI_ATTR void VKAPI_CALL CmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) {