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:

committed by
Marge Bot

parent
b1b7616418
commit
6d0efa8701
@@ -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
|
||||
* will be 2 constraints describing that.
|
||||
*/
|
||||
bool
|
||||
nir_legalize_16bit_sampler_srcs(nir_shader *nir,
|
||||
nir_tex_src_type_constraints constraints)
|
||||
static bool
|
||||
legalize_16bit_sampler_srcs(nir_builder *b, nir_instr *instr, void *data)
|
||||
{
|
||||
bool changed = false;
|
||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||
assert(impl);
|
||||
bool progress = false;
|
||||
nir_tex_src_type_constraint *constraints = data;
|
||||
|
||||
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)
|
||||
continue;
|
||||
return false;
|
||||
|
||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||
int8_t map[nir_num_tex_src_types];
|
||||
@@ -717,23 +711,22 @@ nir_legalize_16bit_sampler_srcs(nir_shader *nir,
|
||||
continue;
|
||||
}
|
||||
|
||||
b.cursor = nir_before_instr(&tex->instr);
|
||||
nir_def *conv =
|
||||
convert(&b, tex->src[i].src.ssa);
|
||||
nir_src_rewrite(&tex->src[i].src, conv);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
b->cursor = nir_before_instr(&tex->instr);
|
||||
nir_src_rewrite(&tex->src[i].src, convert(b, tex->src[i].src.ssa));
|
||||
progress = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
nir_metadata_preserve(impl, nir_metadata_dominance |
|
||||
nir_metadata_block_index);
|
||||
} else {
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
return progress;
|
||||
}
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user