From 685d5140674aca747386a6fdf974280e557d895a Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Fri, 8 Jul 2016 15:42:38 -0600 Subject: layers: Add binding between cmd buffer and pipeline Track all pipelines bound to a cmd buffer and if any of them are destroyed set the cmd buffer as invalid. --- layers/core_validation.cpp | 22 ++++++++++++++++++++-- layers/core_validation.h | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 126345a8..98cab913 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -658,6 +658,8 @@ static const char *object_type_to_string(VkDebugReportObjectTypeEXT type) { return "event"; case VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT: return "query pool"; + case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: + return "pipeline"; default: return "unknown"; } @@ -3761,6 +3763,12 @@ static void removeCommandBufferBinding(layer_data *dev_data, VK_OBJECT const *ob qp_node->cb_bindings.erase(cb_node); break; } + case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT: { + auto pipe_node = getPipeline(dev_data, reinterpret_cast(object->handle)); + if (pipe_node) + pipe_node->cb_bindings.erase(cb_node); + break; + } default: assert(0); // unhandled object type } @@ -5403,8 +5411,16 @@ DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAlloca VKAPI_ATTR void VKAPI_CALL DestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator) { - get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroyPipeline(device, pipeline, pAllocator); - // TODO : Clean up any internal data structures using this obj. + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + dev_data->device_dispatch_table->DestroyPipeline(device, pipeline, pAllocator); + + auto pipe_node = getPipeline(dev_data, pipeline); + if (pipe_node) { + // Any bound cmd buffers are now invalid + invalidateCommandBuffers(pipe_node->cb_bindings, + {reinterpret_cast(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}); + dev_data->pipelineMap.erase(pipeline); + } } VKAPI_ATTR void VKAPI_CALL @@ -6577,6 +6593,8 @@ CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindP (uint64_t)pipeline, __LINE__, DRAWSTATE_INVALID_PIPELINE, "DS", "Attempt to bind Pipeline 0x%" PRIxLEAST64 " that doesn't exist!", (uint64_t)(pipeline)); } + addCommandBufferBinding(&getPipeline(dev_data, pipeline)->cb_bindings, + {reinterpret_cast(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT}, pCB); } lock.unlock(); if (!skip_call) diff --git a/layers/core_validation.h b/layers/core_validation.h index 9a004414..6a5a0a4d 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -125,7 +125,7 @@ struct IMAGE_LAYOUT_NODE { VkFormat format; }; -class PIPELINE_NODE { +class PIPELINE_NODE : public BASE_NODE { public: VkPipeline pipeline; safe_VkGraphicsPipelineCreateInfo graphicsPipelineCI; -- cgit v1.2.3