radv: simplify view format override for emulated formats
authorChia-I Wu <olvaffe@gmail.com>
Wed, 13 Sep 2023 23:23:45 +0000 (16:23 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 6 Oct 2023 00:55:18 +0000 (00:55 +0000)
Override the view format to the format of plane 1 when the view format
is also emulated.  There is no functional change.

v2: check iview->vk.format directly (@yogeshmohan)

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

src/amd/vulkan/radv_image.c

index 88aa4c0..5a45d09 100644 (file)
@@ -2168,14 +2168,12 @@ radv_image_view_init(struct radv_image_view *iview, struct radv_device *device,
       plane_count = vk_format_get_plane_count(iview->vk.format);
    }
 
-   if (radv_is_format_emulated(device->physical_device, image->vk.format)) {
-      const struct util_format_description *desc = vk_format_description(iview->vk.format);
-      if (desc->layout == UTIL_FORMAT_LAYOUT_ETC) {
-         iview->plane_id = 1;
-         iview->vk.view_format = vk_texcompress_etc2_emulation_format(iview->vk.format);
-         iview->vk.format = vk_texcompress_etc2_emulation_format(iview->vk.format);
-      }
-
+   /* when the view format is emulated, redirect the view to the hidden plane 1 */
+   if (radv_is_format_emulated(device->physical_device, iview->vk.format)) {
+      assert(radv_is_format_emulated(device->physical_device, image->vk.format));
+      iview->plane_id = 1;
+      iview->vk.view_format = image->planes[iview->plane_id].format;
+      iview->vk.format = image->planes[iview->plane_id].format;
       plane_count = 1;
    }