zink: use nir_shader_instructions_pass in lower_discard_if
Changes: - nir_metadata_preserve(..., nir_metadata_dominance) is called only when pass makes progress - nir_metadata_preserve(..., nir_metadata_all) is called when pass doesn't make progress Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
This commit is contained in:
parent
65f9234f96
commit
50cb70d38a
|
@ -76,8 +76,13 @@ reads_work_dim(nir_shader *shader)
|
|||
}
|
||||
|
||||
static bool
|
||||
lower_discard_if_instr(nir_intrinsic_instr *instr, nir_builder *b)
|
||||
lower_discard_if_instr(nir_builder *b, nir_instr *instr_, UNUSED void *cb_data)
|
||||
{
|
||||
if (instr_->type != nir_instr_type_intrinsic)
|
||||
return false;
|
||||
|
||||
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(instr_);
|
||||
|
||||
if (instr->intrinsic == nir_intrinsic_discard_if) {
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
|
@ -137,26 +142,10 @@ lower_discard_if_instr(nir_intrinsic_instr *instr, nir_builder *b)
|
|||
static bool
|
||||
lower_discard_if(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder builder;
|
||||
nir_builder_init(&builder, function->impl);
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic)
|
||||
progress |= lower_discard_if_instr(
|
||||
nir_instr_as_intrinsic(instr),
|
||||
&builder);
|
||||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_dominance);
|
||||
}
|
||||
}
|
||||
|
||||
return progress;
|
||||
return nir_shader_instructions_pass(shader,
|
||||
lower_discard_if_instr,
|
||||
nir_metadata_dominance,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
Loading…
Reference in New Issue