From 63fa7b9509263fe55ade23f04ae7d4836a5bc60f Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 12 Oct 2016 08:51:35 -0600 Subject: layers:Refactor DestroyPipeline Add validation flag for DestroyPipeline and update it to follow the Pre/Post pattern. --- layers/core_validation.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'layers/core_validation.cpp') 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(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 lock(global_lock); - auto pipe_node = getPipeline(dev_data, pipeline); - if (pipe_node) { - VK_OBJECT obj_struct = {reinterpret_cast(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); } } -- cgit v1.2.3