X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fcompiler%2Fnir%2Fnir_normalize_cubemap_coords.c;h=cb25e311d769277042f40c8cc4c46174e60a061c;hb=a3a8322dcd7aaede8dedff131c7d73bdbe3f06f9;hp=9c15eb8c15ccfe774834913dde952026f916ca5c;hpb=a39a8fbbaa129f4e52f2a3ad2747182e9a74d910;p=mesa.git diff --git a/src/compiler/nir/nir_normalize_cubemap_coords.c b/src/compiler/nir/nir_normalize_cubemap_coords.c index 9c15eb8c15c..cb25e311d76 100644 --- a/src/compiler/nir/nir_normalize_cubemap_coords.c +++ b/src/compiler/nir/nir_normalize_cubemap_coords.c @@ -33,18 +33,12 @@ * or 1.0. This is based on the old GLSL IR based pass by Eric. */ -struct normalize_cubemap_state { - nir_builder b; - bool progress; -}; - static bool -normalize_cubemap_coords_block(nir_block *block, void *void_state) +normalize_cubemap_coords_block(nir_block *block, nir_builder *b) { - struct normalize_cubemap_state *state = void_state; - nir_builder *b = &state->b; + bool progress = false; - nir_foreach_instr(block, instr) { + nir_foreach_instr(instr, block) { if (instr->type != nir_instr_type_tex) continue; @@ -84,26 +78,28 @@ normalize_cubemap_coords_block(nir_block *block, void *void_state) &tex->src[i].src, nir_src_for_ssa(normalized)); - state->progress = true; + progress = true; } } - return true; + return progress; } static bool normalize_cubemap_coords_impl(nir_function_impl *impl) { - struct normalize_cubemap_state state; - nir_builder_init(&state.b, impl); - state.progress = false; + nir_builder b; + nir_builder_init(&b, impl); + bool progress = false; - nir_foreach_block(impl, normalize_cubemap_coords_block, &state); + nir_foreach_block(block, impl) { + progress |= normalize_cubemap_coords_block(block, &b); + } nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); - return state.progress; + return progress; } bool @@ -111,7 +107,7 @@ nir_normalize_cubemap_coords(nir_shader *shader) { bool progress = false; - nir_foreach_function(shader, function) { + nir_foreach_function(function, shader) { if (function->impl) progress = normalize_cubemap_coords_impl(function->impl) || progress; }