intel/compiler: use nir_shader_instructions_pass in brw_nir_apply_attribute_workarounds
Changes: - removal of attr_wa_state (it's passed directly) - 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: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12324>
This commit is contained in:
parent
e1b325f587
commit
7810ca596c
|
@ -30,28 +30,21 @@
|
|||
* to produce the correct values.
|
||||
*/
|
||||
|
||||
struct attr_wa_state {
|
||||
nir_builder builder;
|
||||
bool impl_progress;
|
||||
const uint8_t *wa_flags;
|
||||
};
|
||||
|
||||
static bool
|
||||
apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
|
||||
apply_attr_wa_instr(nir_builder *b, nir_instr *instr, void *cb_data)
|
||||
{
|
||||
nir_builder *b = &state->builder;
|
||||
const uint8_t *attrib_wa_flags = cb_data;
|
||||
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
return false;
|
||||
|
||||
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
|
||||
if (intrin->intrinsic != nir_intrinsic_load_input)
|
||||
continue;
|
||||
return false;
|
||||
|
||||
uint8_t wa_flags = state->wa_flags[intrin->const_index[0]];
|
||||
uint8_t wa_flags = attrib_wa_flags[intrin->const_index[0]];
|
||||
if (wa_flags == 0)
|
||||
continue;
|
||||
return false;
|
||||
|
||||
b->cursor = nir_after_instr(instr);
|
||||
|
||||
|
@ -124,8 +117,6 @@ apply_attr_wa_block(nir_block *block, struct attr_wa_state *state)
|
|||
|
||||
nir_ssa_def_rewrite_uses_after(&intrin->dest.ssa, val,
|
||||
val->parent_instr);
|
||||
state->impl_progress = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -134,28 +125,8 @@ bool
|
|||
brw_nir_apply_attribute_workarounds(nir_shader *shader,
|
||||
const uint8_t *attrib_wa_flags)
|
||||
{
|
||||
bool progress = false;
|
||||
struct attr_wa_state state = {
|
||||
.wa_flags = attrib_wa_flags,
|
||||
};
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
|
||||
nir_builder_init(&state.builder, func->impl);
|
||||
state.impl_progress = false;
|
||||
|
||||
nir_foreach_block(block, func->impl) {
|
||||
apply_attr_wa_block(block, &state);
|
||||
}
|
||||
|
||||
if (state.impl_progress) {
|
||||
nir_metadata_preserve(func->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
return progress;
|
||||
return nir_shader_instructions_pass(shader, apply_attr_wa_instr,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance,
|
||||
(void *)attrib_wa_flags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue