mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 15:20:10 +01:00
nir/nir_lower_wpos_center: Use the nir_shader_instructions_pass() helper
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Emma Anholt <emma@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11683>
This commit is contained in:
parent
133e7ba571
commit
ecab220c50
1 changed files with 13 additions and 29 deletions
|
|
@ -67,43 +67,27 @@ update_fragcoord(nir_builder *b, nir_intrinsic_instr *intr)
|
|||
}
|
||||
|
||||
static bool
|
||||
lower_wpos_center_block(nir_builder *b, nir_block *block)
|
||||
lower_wpos_center_instr(nir_builder *b, nir_instr *instr, void *data)
|
||||
{
|
||||
bool progress = false;
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
return false;
|
||||
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic) {
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
if (intr->intrinsic == nir_intrinsic_load_frag_coord) {
|
||||
update_fragcoord(b, intr);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
if (intr->intrinsic != nir_intrinsic_load_frag_coord)
|
||||
return false;
|
||||
|
||||
return progress;
|
||||
update_fragcoord(b, intr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
nir_lower_wpos_center(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
nir_builder b;
|
||||
|
||||
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder_init(&b, function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
progress = lower_wpos_center_block(&b, block) ||
|
||||
progress;
|
||||
}
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
}
|
||||
|
||||
return progress;
|
||||
return nir_shader_instructions_pass(shader,
|
||||
lower_wpos_center_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue