glsl: use nir_shader_instructions_pass in gl_nir_lower_atomics
Changes: - nir_metadata_preserve(..., nir_metadata_all) is called when pass doesn't make progress 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
e9dc98ed87
commit
1829fde212
@@ -139,40 +139,40 @@ lower_deref_instr(nir_builder *b, nir_intrinsic_instr *instr,
|
||||
return true;
|
||||
}
|
||||
|
||||
struct lower_atomics_data {
|
||||
bool use_binding_as_idx;
|
||||
nir_shader *shader;
|
||||
const struct gl_shader_program *shader_program;
|
||||
};
|
||||
|
||||
static bool
|
||||
gl_nir_lower_atomics_instr(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||
{
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
return false;
|
||||
|
||||
struct lower_atomics_data *data = cb_data;
|
||||
|
||||
return lower_deref_instr(b,
|
||||
nir_instr_as_intrinsic(instr),
|
||||
data->shader_program,
|
||||
data->shader,
|
||||
data->use_binding_as_idx);
|
||||
}
|
||||
|
||||
bool
|
||||
gl_nir_lower_atomics(nir_shader *shader,
|
||||
const struct gl_shader_program *shader_program,
|
||||
bool use_binding_as_idx)
|
||||
{
|
||||
bool progress = false;
|
||||
struct lower_atomics_data data = {
|
||||
.use_binding_as_idx = use_binding_as_idx,
|
||||
.shader = shader,
|
||||
.shader_program = shader_program,
|
||||
};
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
bool impl_progress = false;
|
||||
|
||||
nir_builder build;
|
||||
nir_builder_init(&build, function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
impl_progress |= lower_deref_instr(&build,
|
||||
nir_instr_as_intrinsic(instr),
|
||||
shader_program, shader,
|
||||
use_binding_as_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (impl_progress) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
return progress;
|
||||
return nir_shader_instructions_pass(shader, gl_nir_lower_atomics_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
&data);
|
||||
}
|
||||
|
Reference in New Issue
Block a user