aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2020-05-12 19:07:48 -0400
committerMarge Bot <[email protected]>2020-06-01 15:46:23 +0000
commitc495c6c2957c7c30cedeaa218c2caf443ac04797 (patch)
treeb03856178ca011c89e3214030edc2892707dc651 /src
parent551d990a7c85d2b3cba567b00e6f2aceef6e2e87 (diff)
pan/mdg: Add pack_unorm_4x8 via 8-bit
More efficient than the 32-bit version in NIR. Signed-off-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5265>
Diffstat (limited to 'src')
-rw-r--r--src/panfrost/midgard/midgard_compile.c2
-rw-r--r--src/panfrost/midgard/midgard_nir.h1
-rw-r--r--src/panfrost/midgard/midgard_nir_algebraic.py7
3 files changed, 10 insertions, 0 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 68af4859da2..59341feba9b 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -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;
diff --git a/src/panfrost/midgard/midgard_nir.h b/src/panfrost/midgard/midgard_nir.h
index 4efd3c5c9f1..e31949c0c2b 100644
--- a/src/panfrost/midgard/midgard_nir.h
+++ b/src/panfrost/midgard/midgard_nir.h
@@ -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);
diff --git a/src/panfrost/midgard/midgard_nir_algebraic.py b/src/panfrost/midgard/midgard_nir_algebraic.py
index 11d2a91fed7..b611ba5a94c 100644
--- a/src/panfrost/midgard/midgard_nir_algebraic.py
+++ b/src/panfrost/midgard/midgard_nir_algebraic.py
@@ -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())