Reviewed-by: Kristian Høgsberg <k...@bitplanet.net> --- src/glsl/nir/nir.h | 3 +-- src/glsl/nir/nir_lower_phis_to_scalar.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index b18f1d6..a8ed3f8 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -1600,6 +1600,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_shader *nir_shader_create(void *mem_ctx, gl_shader_stage stage, @@ -1946,8 +1947,6 @@ void nir_move_vec_src_uses_to_dest(nir_shader *shader); bool nir_lower_vec_to_movs(nir_shader *shader); void nir_lower_load_const_to_scalar(nir_shader *shader); -void nir_lower_phis_to_scalar(nir_shader *shader); - void nir_lower_samplers(nir_shader *shader, const struct gl_shader_program *shader_program); diff --git a/src/glsl/nir/nir_lower_phis_to_scalar.c b/src/glsl/nir/nir_lower_phis_to_scalar.c index aa124d9..902d8cd 100644 --- a/src/glsl/nir/nir_lower_phis_to_scalar.c +++ b/src/glsl/nir/nir_lower_phis_to_scalar.c @@ -41,6 +41,8 @@ struct lower_phis_to_scalar_state { * scalarizable or non-null for scalarizable. */ struct hash_table *phi_table; + + bool progress; }; static bool @@ -192,6 +194,8 @@ lower_phis_to_scalar_block(nir_block *block, void *void_state) if (!should_lower_phi(phi, state)) continue; + state->progress = true; + /* Create a vecN operation to combine the results. Most of these * will be redundant, but copy propagation should clean them up for * us. No need to add the complexity here. @@ -262,8 +266,8 @@ lower_phis_to_scalar_block(nir_block *block, void *void_state) return true; } -static void -lower_phis_to_scalar_impl(nir_function_impl *impl) +static bool +lower_phis_to_scalar_impl(nir_function_impl *impl, void *unused) { struct lower_phis_to_scalar_state state; @@ -271,13 +275,13 @@ lower_phis_to_scalar_impl(nir_function_impl *impl) state.dead_ctx = ralloc_context(NULL); state.phi_table = _mesa_hash_table_create(state.dead_ctx, _mesa_hash_pointer, _mesa_key_pointer_equal); + state.progress = false; nir_foreach_block(impl, lower_phis_to_scalar_block, &state); - nir_metadata_preserve(impl, nir_metadata_block_index | - nir_metadata_dominance); - ralloc_free(state.dead_ctx); + + return state.progress; } /** A pass that lowers vector phi nodes to scalar @@ -287,11 +291,7 @@ lower_phis_to_scalar_impl(nir_function_impl *impl) * instance, if one of the sources is a non-scalarizable vector, then we * don't bother lowering because that would generate hard-to-coalesce movs. */ -void -nir_lower_phis_to_scalar(nir_shader *shader) -{ - nir_foreach_overload(shader, overload) { - if (overload->impl) - lower_phis_to_scalar_impl(overload->impl); - } -} +const nir_pass nir_lower_phis_to_scalar_pass = { + .impl_pass_func = lower_phis_to_scalar_impl, + .metadata_preserved = nir_metadata_block_index | nir_metadata_dominance, +}; -- 2.5.0.400.gff86faf _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev