<p dir="ltr"><br>
On Sep 18, 2015 10:37 AM, "Kenneth Graunke" <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>> wrote:<br>
><br>
> This also required adding a struct.<br>
><br>
> Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> ---<br>
> src/glsl/nir/nir.h | 2 +-<br>
> src/glsl/nir/nir_normalize_cubemap_coords.c | 28 +++++++++++++++++++++-------<br>
> 2 files changed, 22 insertions(+), 8 deletions(-)<br>
><br>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h<br>
> index 8a6a75f..1452b4c 100644<br>
> --- a/src/glsl/nir/nir.h<br>
> +++ b/src/glsl/nir/nir.h<br>
> @@ -1845,7 +1845,7 @@ void nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);<br>
> void nir_lower_atomics(nir_shader *shader);<br>
> void nir_lower_to_source_mods(nir_shader *shader);<br>
><br>
> -void nir_normalize_cubemap_coords(nir_shader *shader);<br>
> +bool nir_normalize_cubemap_coords(nir_shader *shader);<br>
><br>
> void nir_live_variables_impl(nir_function_impl *impl);<br>
> bool nir_ssa_defs_interfere(nir_ssa_def *a, nir_ssa_def *b);<br>
> diff --git a/src/glsl/nir/nir_normalize_cubemap_coords.c b/src/glsl/nir/nir_normalize_cubemap_coords.c<br>
> index dd6de40..1dfe3d5 100644<br>
> --- a/src/glsl/nir/nir_normalize_cubemap_coords.c<br>
> +++ b/src/glsl/nir/nir_normalize_cubemap_coords.c<br>
> @@ -33,10 +33,16 @@<br>
> * or 1.0. This is based on the old GLSL IR based pass by Eric.<br>
> */<br>
><br>
> +struct normcube_state {</p>
<p dir="ltr">Normally, we would name this "normalize_cubemap_state".</p>
<p dir="ltr">> + nir_builder b;<br>
> + bool progress;<br>
> +};<br>
> +<br>
> static bool<br>
> normalize_cubemap_coords_block(nir_block *block, void *void_state)<br>
> {<br>
> - nir_builder *b = void_state;<br>
> + struct normcube_state *state = void_state;<br>
> + nir_builder *b = &state->b;<br>
><br>
> nir_foreach_instr(block, instr) {<br>
> if (instr->type != nir_instr_type_tex)<br>
> @@ -77,29 +83,37 @@ normalize_cubemap_coords_block(nir_block *block, void *void_state)<br>
> nir_instr_rewrite_src(&tex->instr,<br>
> &tex->src[i].src,<br>
> nir_src_for_ssa(normalized));<br>
> +<br>
> + state->progress = true;<br>
> }<br>
> }<br>
><br>
> return true;<br>
> }<br>
><br>
> -static void<br>
> +static bool<br>
> normalize_cubemap_coords_impl(nir_function_impl *impl)<br>
> {<br>
> - nir_builder b;<br>
> - nir_builder_init(&b, impl);<br>
> + struct normcube_state state;<br>
> + nir_builder_init(&state.b, impl);<br>
> + state.progress = false;<br>
><br>
> - nir_foreach_block(impl, normalize_cubemap_coords_block, &b);<br>
> + nir_foreach_block(impl, normalize_cubemap_coords_block, &state);<br>
><br>
> nir_metadata_preserve(impl, nir_metadata_block_index |<br>
> nir_metadata_dominance);</p>
<p dir="ltr">Newline here?</p>
<p dir="ltr">> + return state.progress;<br>
> }<br>
><br>
> -void<br>
> +bool<br>
> nir_normalize_cubemap_coords(nir_shader *shader)<br>
> {<br>
> + bool progress = false;<br>
> +<br>
> nir_foreach_overload(shader, overload) {<br>
> if (overload->impl)<br>
> - normalize_cubemap_coords_impl(overload->impl);<br>
> + progress = normalize_cubemap_coords_impl(overload->impl) || progress;<br>
> }<br>
> +<br>
> + return progress;<br>
> }<br>
> --<br>
> 2.5.1<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>