[Mesa-dev] [PATCH 07/11] nir/lower_vec_to_movs: Handle partially SSA shaders

Jason Ekstrand jason at jlekstrand.net
Wed Sep 9 17:50:10 PDT 2015


---
 src/glsl/nir/nir_lower_vec_to_movs.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/glsl/nir/nir_lower_vec_to_movs.c b/src/glsl/nir/nir_lower_vec_to_movs.c
index e297cb8..7d31e36 100644
--- a/src/glsl/nir/nir_lower_vec_to_movs.c
+++ b/src/glsl/nir/nir_lower_vec_to_movs.c
@@ -34,6 +34,7 @@
 
 struct vec_to_movs_state {
    nir_shader *shader;
+   nir_function_impl *impl;
 };
 
 static bool
@@ -107,8 +108,20 @@ lower_vec_to_movs_block(nir_block *block, void *void_state)
          continue; /* The loop */
       }
 
-      /* Since we insert multiple MOVs, we have to be non-SSA. */
-      assert(!vec->dest.dest.is_ssa);
+      if (vec->dest.dest.is_ssa) {
+         /* Since we insert multiple MOVs, we have a register destination. */
+         nir_register *reg = nir_local_reg_create(state->impl);
+         reg->num_components = vec->dest.dest.ssa.num_components;
+
+         nir_ssa_def_rewrite_uses(&vec->dest.dest.ssa, nir_src_for_reg(reg));
+
+         assert(list_empty(&vec->dest.dest.ssa.uses));
+         assert(list_empty(&vec->dest.dest.ssa.if_uses));
+
+         vec->dest.dest = nir_dest_for_reg(reg);
+         vec->dest.dest.reg.parent_instr = &vec->instr;
+         list_addtail(&vec->dest.dest.reg.def_link, &reg->defs);
+      }
 
       unsigned finished_write_mask = 0;
 
@@ -151,6 +164,7 @@ nir_lower_vec_to_movs_impl(nir_function_impl *impl)
    struct vec_to_movs_state state;
 
    state.shader = impl->overload->function->shader;
+   state.impl = impl;
 
    nir_foreach_block(impl, lower_vec_to_movs_block, &state);
 }
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list