layers: LX250 Verify color and depth/stencil are different.
authorMark Young <marky@lunarg.com>
Wed, 30 Mar 2016 08:23:18 +0000 (02:23 -0600)
committerTobin Ehlis <tobine@google.com>
Fri, 1 Apr 2016 20:34:12 +0000 (14:34 -0600)
Validate that the color and depth/stencil attachments in a
subpass are different.

Change-Id: I0010270e50334cd1dc5b275c29c76265f570b186

layers/core_validation.cpp

index c400b43..3ea8a56 100644 (file)
@@ -9109,8 +9109,10 @@ VkBool32 ValidateDependencies(const layer_data *my_data, const VkRenderPassBegin
         }
     }
     // Find for each attachment the subpasses that use them.
+    unordered_set<uint32_t> attachmentIndices;
     for (uint32_t i = 0; i < pCreateInfo->subpassCount; ++i) {
         const VkSubpassDescription &subpass = pCreateInfo->pSubpasses[i];
+        attachmentIndices.clear();
         for (uint32_t j = 0; j < subpass.inputAttachmentCount; ++j) {
             uint32_t attachment = subpass.pInputAttachments[j].attachment;
             input_attachment_to_subpass[attachment].push_back(i);
@@ -9124,6 +9126,7 @@ VkBool32 ValidateDependencies(const layer_data *my_data, const VkRenderPassBegin
             for (auto overlapping_attachment : overlapping_attachments[attachment]) {
                 output_attachment_to_subpass[overlapping_attachment].push_back(i);
             }
+            attachmentIndices.insert(attachment);
         }
         if (subpass.pDepthStencilAttachment && subpass.pDepthStencilAttachment->attachment != VK_ATTACHMENT_UNUSED) {
             uint32_t attachment = subpass.pDepthStencilAttachment->attachment;
@@ -9131,6 +9134,14 @@ VkBool32 ValidateDependencies(const layer_data *my_data, const VkRenderPassBegin
             for (auto overlapping_attachment : overlapping_attachments[attachment]) {
                 output_attachment_to_subpass[overlapping_attachment].push_back(i);
             }
+
+            if (attachmentIndices.count(attachment)) {
+                skip_call |=
+                    log_msg(my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, (VkDebugReportObjectTypeEXT)0,
+                            0, __LINE__, DRAWSTATE_INVALID_RENDERPASS, "DS",
+                            "Cannot use same attachment (%u) as both color and depth output in same subpass (%u).",
+                            attachment, i);
+            }
         }
     }
     // If there is a dependency needed make sure one exists