nir/legalize_16bit_sampler_srcs: Use instr_pass

Fixes the pass with multiple functions.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25625>
This commit is contained in:
Alyssa Rosenzweig
2023-09-05 17:27:17 -04:00
committed by Marge Bot
parent b1b7616418
commit 6d0efa8701

View File

@@ -653,20 +653,14 @@ is_i32_to_i16_conversion(nir_instr *instr)
* coordinates and the type of the texture bias must be 32-bit, there * coordinates and the type of the texture bias must be 32-bit, there
* will be 2 constraints describing that. * will be 2 constraints describing that.
*/ */
bool static bool
nir_legalize_16bit_sampler_srcs(nir_shader *nir, legalize_16bit_sampler_srcs(nir_builder *b, nir_instr *instr, void *data)
nir_tex_src_type_constraints constraints)
{ {
bool changed = false; bool progress = false;
nir_function_impl *impl = nir_shader_get_entrypoint(nir); nir_tex_src_type_constraint *constraints = data;
assert(impl);
nir_builder b = nir_builder_create(impl);
nir_foreach_block_safe(block, impl) {
nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_tex) if (instr->type != nir_instr_type_tex)
continue; return false;
nir_tex_instr *tex = nir_instr_as_tex(instr); nir_tex_instr *tex = nir_instr_as_tex(instr);
int8_t map[nir_num_tex_src_types]; int8_t map[nir_num_tex_src_types];
@@ -717,23 +711,22 @@ nir_legalize_16bit_sampler_srcs(nir_shader *nir,
continue; continue;
} }
b.cursor = nir_before_instr(&tex->instr); b->cursor = nir_before_instr(&tex->instr);
nir_def *conv = nir_src_rewrite(&tex->src[i].src, convert(b, tex->src[i].src.ssa));
convert(&b, tex->src[i].src.ssa); progress = true;
nir_src_rewrite(&tex->src[i].src, conv);
changed = true;
}
}
} }
if (changed) { return progress;
nir_metadata_preserve(impl, nir_metadata_dominance |
nir_metadata_block_index);
} else {
nir_metadata_preserve(impl, nir_metadata_all);
} }
return changed; bool
nir_legalize_16bit_sampler_srcs(nir_shader *nir,
nir_tex_src_type_constraints constraints)
{
return nir_shader_instructions_pass(nir, legalize_16bit_sampler_srcs,
nir_metadata_dominance |
nir_metadata_block_index,
constraints);
} }
static bool static bool