layers: Flag error on destroyed pipeline in-use
authorTobin Ehlis <tobine@google.com>
Thu, 18 Aug 2016 13:58:33 +0000 (07:58 -0600)
committerTobin Ehlis <tobine@google.com>
Thu, 8 Sep 2016 15:21:49 +0000 (09:21 -0600)
layers/core_validation.cpp
layers/core_validation_types.h

index 8d4e492..b8c61a3 100644 (file)
@@ -5733,10 +5733,14 @@ DestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAlloca
 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);
-    // TODO : Add detection for in-flight pipeline
     std::unique_lock<std::mutex> lock(global_lock);
     auto pipe_node = getPipeline(dev_data, pipeline);
     if (pipe_node) {
+        if (pipe_node->in_use.load()) {
+            log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
+                    reinterpret_cast<uint64_t &>(pipeline), __LINE__, DRAWSTATE_OBJECT_INUSE, "DS",
+                    "Pipeline 0x%" PRIx64 " being destroyed while in use.", reinterpret_cast<uint64_t &>(pipeline));
+        }
         // Any bound cmd buffers are now invalid
         invalidateCommandBuffers(pipe_node->cb_bindings,
                                  {reinterpret_cast<uint64_t &>(pipeline), VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT});
index f36e3b2..3e5d833 100644 (file)
@@ -507,7 +507,7 @@ class PIPELINE_NODE : public BASE_NODE {
     PIPELINE_NODE()
         : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), duplicate_shaders(0), active_slots(),
           vertexBindingDescriptions(), vertexAttributeDescriptions(), attachments(), blendConstantsEnabled(false), render_pass_ci(),
-          pipeline_layout() {}
+          pipeline_layout() { in_use.store(0); }
 
     void initGraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo) {
         graphicsPipelineCI.initialize(pCreateInfo);