pan/mdg: Add pack_unorm_4x8 via 8-bit
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 12 May 2020 23:07:48 +0000 (19:07 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 1 Jun 2020 15:46:23 +0000 (15:46 +0000)
More efficient than the 32-bit version in NIR.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>

src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_nir.h
src/panfrost/midgard/midgard_nir_algebraic.py

index 68af4859da27e00620015b70ac7064d404bf99a3..59341feba9bfeaf8d1ea6989997425786a6f5785 100644 (file)
@@ -383,6 +383,8 @@ optimise_nir(nir_shader *nir, unsigned quirks)
         if (quirks & MIDGARD_BROKEN_LOD)
                 NIR_PASS_V(nir, midgard_nir_lod_errata);
 
+        NIR_PASS(progress, nir, midgard_nir_lower_algebraic_early);
+
         do {
                 progress = false;
 
index 4efd3c5c9f11c0b54e19b83311df747d950e55cf..e31949c0c2bdff8dbbc5d28060e3e334b13881cc 100644 (file)
@@ -1,6 +1,7 @@
 #include <stdbool.h>
 #include "nir.h"
 
+bool midgard_nir_lower_algebraic_early(nir_shader *shader);
 bool midgard_nir_lower_algebraic_late(nir_shader *shader);
 bool midgard_nir_scale_trig(nir_shader *shader);
 bool midgard_nir_cancel_inot(nir_shader *shader);
index 11d2a91fed7904c22eff4ca3d7532177100bae88..b611ba5a94c9ba8ab6ad4287f3e4f3eb4c2e3761 100644 (file)
@@ -30,6 +30,10 @@ a = 'a'
 b = 'b'
 c = 'c'
 
+algebraic = [
+   (('pack_unorm_4x8', a), ('pack_32_4x8', ('f2u8', ('fround_even', ('fmul', ('fsat', a), 255.0)))))
+]
+
 algebraic_late = [
     # ineg must be lowered late, but only for integers; floats will try to
     # have modifiers attached... hence why this has to be here rather than
@@ -141,6 +145,9 @@ def run():
 
     print('#include "midgard_nir.h"')
 
+    print(nir_algebraic.AlgebraicPass("midgard_nir_lower_algebraic_early",
+                                      algebraic).render())
+
     print(nir_algebraic.AlgebraicPass("midgard_nir_lower_algebraic_late",
                                       algebraic_late + converts + constant_switch).render())