pan/mdg: Add pack_unorm_4x8 via 8-bit

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>
This commit is contained in:
Alyssa Rosenzweig
2020-05-12 19:07:48 -04:00
committed by Marge Bot
parent 551d990a7c
commit c495c6c295
3 changed files with 10 additions and 0 deletions
+2
View 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;
+1
View 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);
@@ -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())