Mesa (master): vc4: Move scalarizing and some lowering to link time.

Eric Anholt anholt at kemper.freedesktop.org
Thu Aug 4 16:10:46 UTC 2016


Module: Mesa
Branch: master
Commit: c976e164d262d2d2bfd8087dcbb7bd91995ae887
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c976e164d262d2d2bfd8087dcbb7bd91995ae887

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug  3 14:01:03 2016 -0700

vc4: Move scalarizing and some lowering to link time.

This works out to be a wash in terms of memory usage: We use more memory
to store the separate ALU instructions, but we optimize out a lot of code
as well.  The main result, though, is that we do more of our work at link
time rather than draw time.

---

 src/gallium/drivers/vc4/vc4_program.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index d87caa7..406910d 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -2009,8 +2009,6 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
         }
 
         c->s = nir_shader_clone(c, key->shader_state->base.ir.nir);
-        NIR_PASS_V(c->s, nir_opt_global_to_local);
-        NIR_PASS_V(c->s, nir_convert_to_ssa);
 
         if (stage == QSTAGE_FRAG)
                 NIR_PASS_V(c->s, vc4_nir_lower_blend, c);
@@ -2054,7 +2052,6 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
                         tex_options.lower_srgb |= (1 << i);
         }
 
-        NIR_PASS_V(c->s, nir_normalize_cubemap_coords);
         NIR_PASS_V(c->s, nir_lower_tex, &tex_options);
 
         if (c->fs_key && c->fs_key->light_twoside)
@@ -2071,11 +2068,9 @@ vc4_shader_ntq(struct vc4_context *vc4, enum qstage stage,
         NIR_PASS_V(c->s, vc4_nir_lower_io, c);
         NIR_PASS_V(c->s, vc4_nir_lower_txf_ms, c);
         NIR_PASS_V(c->s, nir_lower_idiv);
-        NIR_PASS_V(c->s, nir_lower_load_const_to_scalar);
 
         vc4_optimize_nir(c->s);
 
-        NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_local);
         NIR_PASS_V(c->s, nir_convert_from_ssa, true);
 
         if (vc4_debug & VC4_DEBUG_SHADERDB) {
@@ -2170,6 +2165,18 @@ vc4_shader_state_create(struct pipe_context *pctx,
                 fprintf(stderr, "\n");
         }
 
+        NIR_PASS_V(s, nir_opt_global_to_local);
+        NIR_PASS_V(s, nir_convert_to_ssa);
+        NIR_PASS_V(s, nir_normalize_cubemap_coords);
+        NIR_PASS_V(s, nir_lower_load_const_to_scalar);
+
+        vc4_optimize_nir(s);
+
+        NIR_PASS_V(s, nir_remove_dead_variables, nir_var_local);
+
+        /* Garbage collect dead instructions */
+        nir_sweep(s);
+
         so->base.type = PIPE_SHADER_IR_NIR;
         so->base.ir.nir = s;
 




More information about the mesa-commit mailing list