tu: Always initialize image_view fields for blit sources
authorConnor Abbott <cwabbott0@gmail.com>
Mon, 18 May 2020 17:11:30 +0000 (19:11 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 19 May 2020 19:55:11 +0000 (19:55 +0000)
Previously we only supported BLIT_SRC_BIT and BLIT_DEST_BIT together, so
we didn't have to worry about initializing blit-related fields for
texture-only formats, but it turns out that 2d blits work out just fine
with these formats and we'll need to enable BLIT_SRC_BIT for
texture-only formats due to a Vulkan requirement on compressed formats.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5098>

src/freedreno/vulkan/tu_image.c

index 52585a85c8dd6ba276bed75c706c8cf3613b20f6..f21d6da01e6f1e40593d079ebce60b404622e1da 100644 (file)
@@ -351,7 +351,34 @@ tu_image_view_init(struct tu_image_view *iview,
          A6XX_TEX_CONST_3_MIN_LAYERSZ(image->layout.slices[image->level_count - 1].size0);
    }
 
-   /* only texture descriptor is valid for TEXTURE-only formats */
+   iview->SP_PS_2D_SRC_INFO = A6XX_SP_PS_2D_SRC_INFO(
+      .color_format = fmt.fmt,
+      .tile_mode = fmt.tile_mode,
+      .color_swap = fmt.swap,
+      .flags = ubwc_enabled,
+      .srgb = vk_format_is_srgb(format),
+      .samples = tu_msaa_samples(image->samples),
+      .samples_average = image->samples > 1 &&
+                           !vk_format_is_int(format) &&
+                           !vk_format_is_depth_or_stencil(format),
+      .unk20 = 1,
+      .unk22 = 1).value;
+   iview->SP_PS_2D_SRC_SIZE =
+      A6XX_SP_PS_2D_SRC_SIZE(.width = width, .height = height).value;
+
+   /* note: these have same encoding for MRT and 2D (except 2D PITCH src) */
+   iview->PITCH = A6XX_RB_DEPTH_BUFFER_PITCH(pitch).value;
+   iview->FLAG_BUFFER_PITCH = A6XX_RB_DEPTH_FLAG_BUFFER_PITCH(
+      .pitch = ubwc_pitch, .array_pitch = layout->ubwc_layer_size >> 2).value;
+
+   iview->base_addr = base_addr;
+   iview->ubwc_addr = ubwc_addr;
+   iview->layer_size = layer_size;
+   iview->ubwc_layer_size = layout->ubwc_layer_size;
+
+   /* Don't set fields that are only used for attachments/blit dest if COLOR
+    * is unsupported.
+    */
    if (!(fmt.supported & FMT_COLOR))
       return;
 
@@ -385,11 +412,6 @@ tu_image_view_init(struct tu_image_view *iview,
       }
    }
 
-   iview->base_addr = base_addr;
-   iview->ubwc_addr = ubwc_addr;
-   iview->layer_size = layer_size;
-   iview->ubwc_layer_size = layout->ubwc_layer_size;
-
    iview->extent.width = width;
    iview->extent.height = height;
    iview->need_y2_align =
@@ -397,11 +419,6 @@ tu_image_view_init(struct tu_image_view *iview,
 
    iview->ubwc_enabled = ubwc_enabled;
 
-   /* note: these have same encoding for MRT and 2D (except 2D PITCH src) */
-   iview->PITCH = A6XX_RB_DEPTH_BUFFER_PITCH(pitch).value;
-   iview->FLAG_BUFFER_PITCH = A6XX_RB_DEPTH_FLAG_BUFFER_PITCH(
-      .pitch = ubwc_pitch, .array_pitch = layout->ubwc_layer_size >> 2).value;
-
    iview->RB_MRT_BUF_INFO = A6XX_RB_MRT_BUF_INFO(0,
                               .color_tile_mode = cfmt.tile_mode,
                               .color_format = cfmt.fmt,
@@ -411,21 +428,6 @@ tu_image_view_init(struct tu_image_view *iview,
                               .color_sint = vk_format_is_sint(format),
                               .color_uint = vk_format_is_uint(format)).value;
 
-   iview->SP_PS_2D_SRC_INFO = A6XX_SP_PS_2D_SRC_INFO(
-      .color_format = fmt.fmt,
-      .tile_mode = fmt.tile_mode,
-      .color_swap = fmt.swap,
-      .flags = ubwc_enabled,
-      .srgb = vk_format_is_srgb(format),
-      .samples = tu_msaa_samples(image->samples),
-      .samples_average = image->samples > 1 &&
-                           !vk_format_is_int(format) &&
-                           !vk_format_is_depth_or_stencil(format),
-      .unk20 = 1,
-      .unk22 = 1).value;
-   iview->SP_PS_2D_SRC_SIZE =
-      A6XX_SP_PS_2D_SRC_SIZE(.width = width, .height = height).value;
-
    iview->RB_2D_DST_INFO = A6XX_RB_2D_DST_INFO(
       .color_format = cfmt.fmt,
       .tile_mode = cfmt.tile_mode,