[Mesa-dev] [PATCH v2 06/10] nir/lower_vars_to_ssa: Use the nir_pass framework internally

Jason Ekstrand jason at jlekstrand.net
Tue Nov 3 13:41:12 PST 2015


Reviewed-by: Kristian Høgsberg <krh at bitplanet.net>
---
 src/glsl/nir/nir.h                   |  2 +-
 src/glsl/nir/nir_lower_vars_to_ssa.c | 17 +++++------------
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index a8ed3f8..517b7f8 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1601,6 +1601,7 @@ bool nir_function_impl_run_pass(nir_function_impl *impl, const nir_pass *pass,
 
 NIR_DECL_PASS(nir_lower_alu_to_scalar)
 NIR_DECL_PASS(nir_lower_phis_to_scalar)
+NIR_DECL_PASS(nir_lower_vars_to_ssa)
 
 nir_shader *nir_shader_create(void *mem_ctx,
                               gl_shader_stage stage,
@@ -1939,7 +1940,6 @@ void nir_assign_var_locations(struct exec_list *var_list,
 void nir_lower_io(nir_shader *shader,
                   nir_variable_mode mode,
                   int (*type_size)(const struct glsl_type *));
-void nir_lower_vars_to_ssa(nir_shader *shader);
 
 bool nir_remove_dead_variables(nir_shader *shader);
 
diff --git a/src/glsl/nir/nir_lower_vars_to_ssa.c b/src/glsl/nir/nir_lower_vars_to_ssa.c
index 5971507..146be49 100644
--- a/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -856,7 +856,7 @@ insert_phi_nodes(struct lower_variables_state *state)
  *     with SSA definitions and SSA uses.
  */
 static bool
-nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
+nir_lower_vars_to_ssa_impl(nir_function_impl *impl, void *unused)
 {
    struct lower_variables_state state;
 
@@ -935,19 +935,12 @@ nir_lower_vars_to_ssa_impl(nir_function_impl *impl)
    insert_phi_nodes(&state);
    rename_variables_block(nir_start_block(impl), &state);
 
-   nir_metadata_preserve(impl, nir_metadata_block_index |
-                               nir_metadata_dominance);
-
    ralloc_free(state.dead_ctx);
 
    return progress;
 }
 
-void
-nir_lower_vars_to_ssa(nir_shader *shader)
-{
-   nir_foreach_overload(shader, overload) {
-      if (overload->impl)
-         nir_lower_vars_to_ssa_impl(overload->impl);
-   }
-}
+const nir_pass nir_lower_vars_to_ssa_pass = {
+   .impl_pass_func = nir_lower_vars_to_ssa_impl,
+   .metadata_preserved = nir_metadata_block_index | nir_metadata_dominance,
+};
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list