diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-12-21 12:26:38 -0700 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-12-23 10:09:14 -0700 |
| commit | 9c7b7c983d1028f6ce46e8cda21c62715908f564 (patch) | |
| tree | 1dbd62095fc9407da88ee2af9bc76fffc2f30ed4 /layers/core_validation.cpp | |
| parent | 292069a077d6ff4db4a90a9c6a227b9caefd3e78 (diff) | |
| download | usermoji-9c7b7c983d1028f6ce46e8cda21c62715908f564.tar.xz | |
layers:Refactor CmdDispatch()
Refactor CmdDispatch() to use pre/post pattern. Updated the DrawType
helper functions for use with Dispatch functions as well. For the
update helper, broke that out into a separate DrawDispatch helper
that does common work, and then a Draw helper that calls the
DrawDispatch helper and then does some extra work only relevant
for draw calls.
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index fe7a8098..f1e982e5 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -8040,21 +8040,31 @@ static bool ValidateCmdDrawType( if (*cb_state) { skip |= ValidateCmd(dev_data, *cb_state, cmd_type, caller); skip |= ValidateDrawState(dev_data, *cb_state, indexed, bind_point, active_set_bindings_pairs, active_bindings, caller); - skip |= outsideRenderPass(dev_data, *cb_state, caller, msg_code); + skip |= (VK_PIPELINE_BIND_POINT_GRAPHICS == bind_point) ? outsideRenderPass(dev_data, *cb_state, caller, msg_code) + : insideRenderPass(dev_data, *cb_state, caller, msg_code); } return skip; } +// Generic function to handle state update for all CmdDraw* and CmdDispatch* type functions +static void UpdateStateCmdDrawDispatchType( + layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point, CMD_TYPE cmd_type, + 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) { + MarkStoreImagesAndBuffersAsWritten(dev_data, cb_state); + UpdateDrawState(dev_data, cb_state, bind_point, active_set_bindings_pairs, active_bindings); + UpdateCmdBufferLastCmd(dev_data, cb_state, cmd_type); +} + // Generic function to handle state update for all CmdDraw* type functions static void UpdateStateCmdDrawType( layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point, CMD_TYPE cmd_type, DRAW_TYPE draw_type, 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) { - MarkStoreImagesAndBuffersAsWritten(dev_data, cb_state); + UpdateStateCmdDrawDispatchType(dev_data, cb_state, bind_point, cmd_type, active_set_bindings_pairs, active_bindings); updateResourceTrackingOnDraw(cb_state); - UpdateDrawState(dev_data, cb_state, bind_point, active_set_bindings_pairs, active_bindings); - UpdateCmdBufferLastCmd(dev_data, cb_state, cmd_type); cb_state->drawCount[draw_type]++; } @@ -8223,26 +8233,39 @@ CmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceS } } +static bool PreCallValidateCmdDispatch( + layer_data *dev_data, VkCommandBuffer cmd_buffer, bool indexed, VkPipelineBindPoint bind_point, GLOBAL_CB_NODE **cb_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) { + return ValidateCmdDrawType(dev_data, cmd_buffer, indexed, bind_point, CMD_DISPATCH, cb_state, active_set_bindings_pairs, + active_bindings, caller, VALIDATION_ERROR_01365); +} + +static void PostCallRecordCmdDispatch( + layer_data *dev_data, GLOBAL_CB_NODE *cb_state, VkPipelineBindPoint bind_point, + 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) { + UpdateStateCmdDrawDispatchType(dev_data, cb_state, bind_point, CMD_DISPATCH, active_set_bindings_pairs, active_bindings); +} + VKAPI_ATTR void VKAPI_CALL CmdDispatch(VkCommandBuffer commandBuffer, uint32_t x, uint32_t y, uint32_t z) { - 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; std::unique_lock<std::mutex> lock(global_lock); - GLOBAL_CB_NODE *pCB = getCBNode(dev_data, commandBuffer); - if (pCB) { - skip_call |= ValidateDrawState(dev_data, pCB, false, VK_PIPELINE_BIND_POINT_COMPUTE, &active_set_bindings_pairs, - &active_bindings, "vkCmdDispatch"); - UpdateDrawState(dev_data, pCB, VK_PIPELINE_BIND_POINT_COMPUTE, &active_set_bindings_pairs, &active_bindings); - MarkStoreImagesAndBuffersAsWritten(dev_data, pCB); - skip_call |= ValidateCmd(dev_data, pCB, CMD_DISPATCH, "vkCmdDispatch()"); - UpdateCmdBufferLastCmd(dev_data, pCB, CMD_DISPATCH); - skip_call |= insideRenderPass(dev_data, pCB, "vkCmdDispatch()", VALIDATION_ERROR_01562); - } + bool skip = PreCallValidateCmdDispatch(dev_data, commandBuffer, false, VK_PIPELINE_BIND_POINT_COMPUTE, &cb_state, + &active_set_bindings_pairs, &active_bindings, "vkCmdDispatch()"); lock.unlock(); - if (!skip_call) + if (!skip) { dev_data->dispatch_table.CmdDispatch(commandBuffer, x, y, z); + lock.lock(); + PostCallRecordCmdDraw(dev_data, cb_state, VK_PIPELINE_BIND_POINT_COMPUTE, &active_set_bindings_pairs, &active_bindings); + lock.unlock(); + } } VKAPI_ATTR void VKAPI_CALL |
