anv: Use layerCount for clears and transitions in BeginRendering
authorJason Ekstrand <jason.ekstrand@collabora.com>
Thu, 17 Mar 2022 22:35:27 +0000 (17:35 -0500)
committerJason Ekstrand <jason.ekstrand@collabora.com>
Fri, 18 Mar 2022 14:27:15 +0000 (09:27 -0500)
The Vulkan spec was recently clerified to say that transitions only
happen to the bound layers:

    "Automatic layout transitions apply to the entire image subresource
    attached to the framebuffer. If multiview is not enabled and the
    attachment is a view of a 1D or 2D image, the automatic layout
    transitions apply to the number of layers specified by
    VkFramebufferCreateInfo::layers. If multiview is enabled and the
    attachment is a view of a 1D or 2D image, the automatic layout
    transitions apply to the layers corresponding to views which are
    used by some subpass in the render pass, even if that subpass does
    not reference the given attachment."

This is in the context of render passes but it applies to dynamic
rendering because the implicit layout transition stuff is a Mesa pseudo-
extension and inherits those rules.

For clears, the Vulkan spec says:

    "renderArea is the render area that is affected by the render pass
    instance. The effects of attachment load, store and multisample
    resolve operations are restricted to the pixels whose x and y
    coordinates fall within the render area on all attachments. The
    render area extends to all layers of framebuffer."

Again, this is in the context of render passes but the same principals
apply to dynamic rendering where the layerCount and renderArea are
specified as part of the vkCmdBeginRendering() call.

Fixes: 3501a3f9ed92 ("anv: Convert to 100% dynamic rendering")
Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15441>

src/intel/vulkan/genX_cmd_buffer.c

index 9aa0ab2..2f88ed8 100644 (file)
@@ -6595,7 +6595,7 @@ void genX(CmdBeginRendering)(
                                        VK_IMAGE_ASPECT_COLOR_BIT,
                                        iview->vk.base_mip_level, 1,
                                        iview->vk.base_array_layer,
-                                       iview->vk.layer_count,
+                                       gfx->layer_count,
                                        initial_layout, att->imageLayout,
                                        VK_QUEUE_FAMILY_IGNORED,
                                        VK_QUEUE_FAMILY_IGNORED,
@@ -6605,7 +6605,7 @@ void genX(CmdBeginRendering)(
 
          uint32_t clear_view_mask = pRenderingInfo->viewMask;
          uint32_t base_clear_layer = iview->vk.base_array_layer;
-         uint32_t clear_layer_count = iview->vk.layer_count;
+         uint32_t clear_layer_count = gfx->layer_count;
          if (fast_clear) {
             /* We only support fast-clears on the first layer */
             assert(iview->vk.base_mip_level == 0 &&
@@ -6812,7 +6812,7 @@ void genX(CmdBeginRendering)(
             } else {
                transition_depth_buffer(cmd_buffer, d_iview->image,
                                        d_iview->vk.base_array_layer,
-                                       d_iview->vk.layer_count,
+                                       gfx->layer_count,
                                        initial_depth_layout, depth_layout,
                                        hiz_clear);
             }
@@ -6837,7 +6837,7 @@ void genX(CmdBeginRendering)(
                transition_stencil_buffer(cmd_buffer, s_iview->image,
                                          s_iview->vk.base_mip_level, 1,
                                          s_iview->vk.base_array_layer,
-                                         s_iview->vk.layer_count,
+                                         gfx->layer_count,
                                          initial_stencil_layout,
                                          stencil_layout,
                                          hiz_clear);
@@ -6871,7 +6871,7 @@ void genX(CmdBeginRendering)(
          } else {
             uint32_t level = ds_iview->vk.base_mip_level;
             uint32_t base_layer = ds_iview->vk.base_array_layer;
-            uint32_t layer_count = ds_iview->vk.layer_count;
+            uint32_t layer_count = gfx->layer_count;
 
             if (hiz_clear) {
                anv_image_hiz_clear(cmd_buffer, ds_iview->image,