[Mesa-dev] [PATCH 08/11] nir/algebraic: Use the nir_pass framework internally

Jason Ekstrand jason at jlekstrand.net
Wed Oct 28 14:32:08 PDT 2015


---
 src/glsl/nir/nir_algebraic.py | 35 +++++++++++++++--------------------
 1 file changed, 15 insertions(+), 20 deletions(-)

diff --git a/src/glsl/nir/nir_algebraic.py b/src/glsl/nir/nir_algebraic.py
index bbf4f08..f0c2dcf 100644
--- a/src/glsl/nir/nir_algebraic.py
+++ b/src/glsl/nir/nir_algebraic.py
@@ -247,41 +247,36 @@ ${pass_name}_block(nir_block *block, void *void_state)
 }
 
 static bool
-${pass_name}_impl(nir_function_impl *impl, const bool *condition_flags)
+${pass_name}_impl(nir_function_impl *impl, void *unused)
 {
-   struct opt_state state;
+   nir_shader *shader = impl->overload->function->shader;
+   const nir_shader_compiler_options *options = shader->options;
+
+   bool condition_flags[${len(condition_list)}];
+   % for index, condition in enumerate(condition_list):
+   condition_flags[${index}] = ${condition};
+   % endfor
 
+   struct opt_state state;
    state.mem_ctx = ralloc_parent(impl);
    state.progress = false;
    state.condition_flags = condition_flags;
 
    nir_foreach_block(impl, ${pass_name}_block, &state);
 
-   if (state.progress)
-      nir_metadata_preserve(impl, nir_metadata_block_index |
-                                  nir_metadata_dominance);
-
    return state.progress;
 }
 
+static const nir_pass ${pass_name}_pass = {
+   NULL, /* shader_pass_func */
+   ${pass_name}_impl,
+   nir_metadata_block_index | nir_metadata_dominance,
+};
 
 bool
 ${pass_name}(nir_shader *shader)
 {
-   bool progress = false;
-   bool condition_flags[${len(condition_list)}];
-   const nir_shader_compiler_options *options = shader->options;
-
-   % for index, condition in enumerate(condition_list):
-   condition_flags[${index}] = ${condition};
-   % endfor
-
-   nir_foreach_overload(shader, overload) {
-      if (overload->impl)
-         progress |= ${pass_name}_impl(overload->impl, condition_flags);
-   }
-
-   return progress;
+   return nir_shader_run_pass(shader, &${pass_name}_pass);
 }
 """)
 
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list