Module: Mesa
Branch: main
Commit: 7a1a9fb287384a7a130fcb63b029fe383dc17a6f
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7a1a9fb287384a7a130fcb63b029fe383dc17a6f

Author: Ian Romanick <ian.d.roman...@intel.com>
Date:   Fri Nov 17 11:09:06 2023 -0800

nir/lower_packing: Don't generate nir_pack_32_4x8_split on drivers that can't 
handle it

It should not be possible for this to happen now as the nir_pack_32_4x8
instruction that is being lowered shouldn't exist. A later commit will
change this.

Reviewed-by: Jesse Natalie <jenat...@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24741>

---

 src/compiler/nir/nir_lower_packing.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/compiler/nir/nir_lower_packing.c 
b/src/compiler/nir/nir_lower_packing.c
index 24493deef25..f112d4b5995 100644
--- a/src/compiler/nir/nir_lower_packing.c
+++ b/src/compiler/nir/nir_lower_packing.c
@@ -89,10 +89,23 @@ lower_unpack_64_to_16(nir_builder *b, nir_def *src)
 static nir_def *
 lower_pack_32_from_8(nir_builder *b, nir_def *src)
 {
-   return nir_pack_32_4x8_split(b, nir_channel(b, src, 0),
-                                nir_channel(b, src, 1),
-                                nir_channel(b, src, 2),
-                                nir_channel(b, src, 3));
+   if (b->shader->options->has_pack_32_4x8) {
+      return nir_pack_32_4x8_split(b,
+                                   nir_channel(b, src, 0),
+                                   nir_channel(b, src, 1),
+                                   nir_channel(b, src, 2),
+                                   nir_channel(b, src, 3));
+   } else {
+      nir_def *src32 = nir_u2u32(b, src);
+
+      return nir_ior(b,
+                     nir_ior(b,
+                                             nir_channel(b, src32, 0)     ,
+                             nir_ishl_imm(b, nir_channel(b, src32, 1), 8)),
+                     nir_ior(b,
+                             nir_ishl_imm(b, nir_channel(b, src32, 2), 16),
+                             nir_ishl_imm(b, nir_channel(b, src32, 3), 24)));
+   }
 }
 
 static bool

Reply via email to