layer: Add in-use validation for imageView
authorTobin Ehlis <tobine@google.com>
Mon, 19 Sep 2016 20:02:58 +0000 (14:02 -0600)
committerTobin Ehlis <tobine@google.com>
Thu, 22 Sep 2016 13:21:24 +0000 (07:21 -0600)
Bind imageView from a descriptor to the command buffer at CmdBindDescriptorSets
time and check for an in-use imageView at DestroyImageView time.

Also use new AddCommandBufferBindingImageView() helper to bind children of
framebuffer in AddFrameBufferBinding().

layers/core_validation.cpp
layers/core_validation_types.h
layers/descriptor_sets.cpp

index 12bc8a0..485ccc5 100644 (file)
@@ -586,6 +586,19 @@ void AddCommandBufferBindingImage(const layer_data *dev_data, GLOBAL_CB_NODE *cb
     img_node->cb_bindings.insert(cb_node);
 }
 
+// Create binding link between given image view node and its image with command buffer node
+void AddCommandBufferBindingImageView(const layer_data *dev_data, GLOBAL_CB_NODE *cb_node, IMAGE_VIEW_STATE *view_state) {
+    // First add bindings for imageView
+    view_state->cb_bindings.insert(cb_node);
+    auto image_node = getImageNode(dev_data, view_state->create_info.image);
+    cb_node->object_bindings.insert(
+        {reinterpret_cast<uint64_t &>(view_state->image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT});
+    // Add bindings for image within imageView
+    if (image_node) {
+        AddCommandBufferBindingImage(dev_data, cb_node, image_node);
+    }
+}
+
 // Create binding link between given buffer node and command buffer node
 void AddCommandBufferBindingBuffer(const layer_data *dev_data, GLOBAL_CB_NODE *cb_node, BUFFER_NODE *buff_node) {
     // First update CB binding in MemObj mini CB list
@@ -6767,15 +6780,7 @@ static void AddFramebufferBinding(layer_data *dev_data, GLOBAL_CB_NODE *cb_state
     for (auto attachment : fb_state->attachments) {
         auto view_state = attachment.view_state;
         if (view_state) {
-            addCommandBufferBinding(
-                &view_state->cb_bindings,
-                {reinterpret_cast<uint64_t &>(view_state->image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT}, cb_state);
-        }
-        auto img_node = getImageNode(dev_data, attachment.image);
-        if (img_node) {
-            addCommandBufferBinding(&img_node->cb_bindings,
-                                    {reinterpret_cast<uint64_t &>(img_node->image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT},
-                                    cb_state);
+            AddCommandBufferBindingImageView(dev_data, cb_state, view_state);
         }
         auto rp_state = getRenderPass(dev_data, fb_state->createInfo.renderPass);
         if (rp_state) {
index 21f5510..ff2cdbf 100644 (file)
@@ -680,6 +680,7 @@ void invalidateCommandBuffers(std::unordered_set<GLOBAL_CB_NODE *>, VK_OBJECT);
 bool ValidateMemoryIsBoundToBuffer(const layer_data *, const BUFFER_NODE *, const char *);
 void AddCommandBufferBindingSampler(GLOBAL_CB_NODE *, SAMPLER_NODE *);
 void AddCommandBufferBindingImage(const layer_data *, GLOBAL_CB_NODE *, IMAGE_NODE *);
+void AddCommandBufferBindingImageView(const layer_data *, GLOBAL_CB_NODE *, IMAGE_VIEW_STATE *);
 void AddCommandBufferBindingBuffer(const layer_data *, GLOBAL_CB_NODE *, BUFFER_NODE *);
 }
 
index df5dac2..f02da6b 100644 (file)
@@ -880,9 +880,7 @@ void cvdescriptorset::ImageSamplerDescriptor::BindCommandBuffer(const core_valid
     // Add binding for image
     auto iv_state = getImageViewState(dev_data, image_view_);
     if (iv_state) {
-        auto image_node = getImageNode(dev_data, iv_state->create_info.image);
-        if (image_node)
-            core_validation::AddCommandBufferBindingImage(dev_data, cb_node, image_node);
+        core_validation::AddCommandBufferBindingImageView(dev_data, cb_node, iv_state);
     }
 }
 
@@ -913,9 +911,7 @@ void cvdescriptorset::ImageDescriptor::BindCommandBuffer(const core_validation::
     // Add binding for image
     auto iv_state = getImageViewState(dev_data, image_view_);
     if (iv_state) {
-        auto image_node = getImageNode(dev_data, iv_state->create_info.image);
-        if (image_node)
-            core_validation::AddCommandBufferBindingImage(dev_data, cb_node, image_node);
+        core_validation::AddCommandBufferBindingImageView(dev_data, cb_node, iv_state);
     }
 }