Module: Mesa
Branch: staging/22.2
Commit: 123ece43a429f3edf9d1550c326797a74a1dca70
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=123ece43a429f3edf9d1550c326797a74a1dca70

Author: Lionel Landwerlin <[email protected]>
Date:   Sun Aug 14 21:41:04 2022 +0300

anv: fixup assertions on lowered storage formats

With VK_FORMAT_B10G11R11_UFLOAT_PACK32 in particular, we're seeing
applications create image views with swizzle = R,G,B,0

But since the format has no alpha channel, the swizzle value for it
does not matter for the equivalence we're trying to verify.

Signed-off-by: Lionel Landwerlin <[email protected]>
Fixes: a9edc268b9b1 ("anv: validate image view lowered storage formats for 
storage")
Reviewed-by: José Roberto de Souza <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18081>
(cherry picked from commit 4ab38112f36ec25afe98a1636909bb8bde4ad7a1)

---

 .pick_status.json            |  2 +-
 src/intel/isl/isl.h          | 16 ++++++++++++++++
 src/intel/vulkan/anv_image.c |  2 +-
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 1d523c50576..9024bea6a94 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -12010,7 +12010,7 @@
         "description": "anv: fixup assertions on lowered storage formats",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": "a9edc268b9b12db49a3fef599cf13443224dca7e"
     },
diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
index 715a089cb8c..2073c58154a 100644
--- a/src/intel/isl/isl.h
+++ b/src/intel/isl/isl.h
@@ -2357,6 +2357,22 @@ isl_swizzle_is_identity(struct isl_swizzle swizzle)
           swizzle.a == ISL_CHANNEL_SELECT_ALPHA;
 }
 
+static inline bool
+isl_swizzle_is_identity_for_format(enum isl_format format,
+                                   struct isl_swizzle swizzle)
+{
+   const struct isl_format_layout *layout = isl_format_get_layout(format);
+
+#define channel_id_or_zero(name, ID)                 \
+   (swizzle.name == ISL_CHANNEL_SELECT_##ID ||       \
+    layout->channels.name.bits == 0)
+   return channel_id_or_zero(r, RED) &&
+          channel_id_or_zero(g, GREEN) &&
+          channel_id_or_zero(b, BLUE) &&
+          channel_id_or_zero(a, ALPHA);
+#undef channel_id_or_zero
+}
+
 bool
 isl_swizzle_supports_rendering(const struct intel_device_info *devinfo,
                                struct isl_swizzle swizzle);
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 93d530f0a09..e0024b50017 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2566,7 +2566,7 @@ anv_image_fill_surface_state(struct anv_device *device,
           */
          assert(isl_formats_have_same_bits_per_channel(lower_format,
                                                        view.format) ||
-                isl_swizzle_is_identity(view.swizzle));
+                isl_swizzle_is_identity_for_format(view.format, view.swizzle));
 
          view.format = lower_format;
       }

Reply via email to