diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-10-12 08:51:35 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-10-13 19:13:33 -0600 |
| commit | 63fa7b9509263fe55ade23f04ae7d4836a5bc60f (patch) | |
| tree | cfa14d22df0189c81e7af30cf813b6b21c07bc9e /layers/core_validation.cpp | |
| parent | 11e41f855d0367271e4d61375d11c0d4d967051e (diff) | |
| download | usermoji-63fa7b9509263fe55ade23f04ae7d4836a5bc60f.tar.xz | |
layers:Refactor DestroyPipeline
Add validation flag for DestroyPipeline and update it to follow the
Pre/Post pattern.
Diffstat (limited to 'layers/core_validation.cpp')
| -rw-r--r-- | layers/core_validation.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 0207df0d..60c77c4f 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -6017,22 +6017,38 @@ DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAlloca my_data->dispatch_table.DestroyShaderModule(device, shaderModule, pAllocator); } +static bool PreCallValidateDestroyPipeline(layer_data *dev_data, VkPipeline pipeline, PIPELINE_NODE **pipeline_state, + VK_OBJECT *obj_struct) { + if (dev_data->instance_state->disabled.destroy_pipeline) + return false; + bool skip = false; + *pipeline_state = getPipeline(dev_data, pipeline); + if (*pipeline_state) { + *obj_struct = {reinterpret_cast<uint64_t &>(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}; + skip |= ValidateObjectNotInUse(dev_data, *pipeline_state, *obj_struct); + } + return skip; +} + +static void PostCallRecordDestroyPipeline(layer_data *dev_data, VkPipeline pipeline, PIPELINE_NODE *pipeline_state, + VK_OBJECT obj_struct) { + // Any bound cmd buffers are now invalid + invalidateCommandBuffers(pipeline_state->cb_bindings, obj_struct); + dev_data->pipelineMap.erase(pipeline); +} + VKAPI_ATTR void VKAPI_CALL DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator) { layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - bool skip = false; + PIPELINE_NODE *pipeline_state = nullptr; + VK_OBJECT obj_struct; std::unique_lock<std::mutex> lock(global_lock); - auto pipe_node = getPipeline(dev_data, pipeline); - if (pipe_node) { - VK_OBJECT obj_struct = {reinterpret_cast<uint64_t &>(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}; - skip |= ValidateObjectNotInUse(dev_data, pipe_node, obj_struct); - // Any bound cmd buffers are now invalid - invalidateCommandBuffers(pipe_node->cb_bindings, obj_struct); - } + bool skip = PreCallValidateDestroyPipeline(dev_data, pipeline, &pipeline_state, &obj_struct); if (!skip) { - dev_data->pipelineMap.erase(pipeline); lock.unlock(); dev_data->dispatch_table.DestroyPipeline(device, pipeline, pAllocator); + lock.lock(); + PostCallRecordDestroyPipeline(dev_data, pipeline, pipeline_state, obj_struct); } } |
