layers:RenderPass depth/stencil layout transition
authorTobin Ehlis <tobine@google.com>
Thu, 16 Feb 2017 20:21:20 +0000 (13:21 -0700)
committerTobin Ehlis <tobine@google.com>
Thu, 16 Feb 2017 23:25:56 +0000 (16:25 -0700)
Fixes #1454

For image views into depth/stencil images we need to make sure that
both the depth and stencil aspects have their layouts transitioned to
the initialLayout setting for the first subpass.

layers/buffer_validation.cpp

index ef1d04b..118df5e 100644 (file)
@@ -274,6 +274,7 @@ bool VerifyFramebufferAndRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NO
         IMAGE_CMD_BUF_LAYOUT_NODE newNode = {pRenderPassInfo->pAttachments[i].initialLayout,
                                              pRenderPassInfo->pAttachments[i].initialLayout};
         // TODO: Do not iterate over every possibility - consolidate where possible
+        // TODO: Consolidate this with SetImageViewLayout() function above
         for (uint32_t j = 0; j < subRange.levelCount; j++) {
             uint32_t level = subRange.baseMipLevel + j;
             for (uint32_t k = 0; k < subRange.layerCount; k++) {
@@ -281,6 +282,12 @@ bool VerifyFramebufferAndRenderPassLayouts(layer_data *device_data, GLOBAL_CB_NO
                 VkImageSubresource sub = {subRange.aspectMask, level, layer};
                 IMAGE_CMD_BUF_LAYOUT_NODE node;
                 if (!FindCmdBufLayout(device_data, pCB, image, sub, node)) {
+                    // If ImageView was created with depth or stencil, transition both aspects if it's a DS image
+                    if (subRange.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
+                        if (vk_format_is_depth_and_stencil(view_state->create_info.format)) {
+                            sub.aspectMask |= (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT);
+                        }
+                    }
                     SetLayout(device_data, pCB, image, sub, newNode);
                     continue;
                 }