glsl: use nir_shader_instructions_pass in gl_nir_lower_samplers_as_deref
No functional changes. Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12282>
This commit is contained in:

committed by
Marge Bot

parent
d3708d6cf5
commit
cb201e92ac
@@ -353,36 +353,23 @@ lower_intrinsic(nir_intrinsic_instr *instr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
lower_impl(nir_function_impl *impl, struct lower_samplers_as_deref_state *state)
|
lower_instr(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||||
{
|
{
|
||||||
nir_builder b;
|
struct lower_samplers_as_deref_state *state = cb_data;
|
||||||
nir_builder_init(&b, impl);
|
|
||||||
bool progress = false;
|
|
||||||
|
|
||||||
nir_foreach_block(block, impl) {
|
|
||||||
nir_foreach_instr(instr, block) {
|
|
||||||
if (instr->type == nir_instr_type_tex)
|
if (instr->type == nir_instr_type_tex)
|
||||||
progress |= lower_sampler(nir_instr_as_tex(instr), state, &b);
|
return lower_sampler(nir_instr_as_tex(instr), state, b);
|
||||||
else if (instr->type == nir_instr_type_intrinsic)
|
|
||||||
progress |= lower_intrinsic(nir_instr_as_intrinsic(instr), state, &b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (progress) {
|
if (instr->type == nir_instr_type_intrinsic)
|
||||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
return lower_intrinsic(nir_instr_as_intrinsic(instr), state, b);
|
||||||
nir_metadata_dominance);
|
|
||||||
} else {
|
|
||||||
nir_metadata_preserve(impl, nir_metadata_all);
|
|
||||||
}
|
|
||||||
|
|
||||||
return progress;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
gl_nir_lower_samplers_as_deref(nir_shader *shader,
|
gl_nir_lower_samplers_as_deref(nir_shader *shader,
|
||||||
const struct gl_shader_program *shader_program)
|
const struct gl_shader_program *shader_program)
|
||||||
{
|
{
|
||||||
bool progress = false;
|
|
||||||
struct lower_samplers_as_deref_state state;
|
struct lower_samplers_as_deref_state state;
|
||||||
|
|
||||||
state.shader = shader;
|
state.shader = shader;
|
||||||
@@ -390,10 +377,10 @@ gl_nir_lower_samplers_as_deref(nir_shader *shader,
|
|||||||
state.remap_table = _mesa_hash_table_create(NULL, _mesa_hash_string,
|
state.remap_table = _mesa_hash_table_create(NULL, _mesa_hash_string,
|
||||||
_mesa_key_string_equal);
|
_mesa_key_string_equal);
|
||||||
|
|
||||||
nir_foreach_function(function, shader) {
|
bool progress = nir_shader_instructions_pass(shader, lower_instr,
|
||||||
if (function->impl)
|
nir_metadata_block_index |
|
||||||
progress |= lower_impl(function->impl, &state);
|
nir_metadata_dominance,
|
||||||
}
|
&state);
|
||||||
|
|
||||||
/* keys are freed automatically by ralloc */
|
/* keys are freed automatically by ralloc */
|
||||||
_mesa_hash_table_destroy(state.remap_table, NULL);
|
_mesa_hash_table_destroy(state.remap_table, NULL);
|
||||||
|
Reference in New Issue
Block a user