zink: use nir_shader_instructions_pass for draw params pass

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9090>
This commit is contained in:
Mike Blumenkrantz 2020-09-14 14:45:06 -04:00
parent f95afdd606
commit d550c5780f

View file

@ -219,8 +219,11 @@ lower_64bit_vertex_attribs(nir_shader *shader)
} }
static bool static bool
lower_basevertex_instr(nir_intrinsic_instr *instr, nir_builder *b) lower_basevertex_instr(nir_builder *b, nir_instr *in, void *data)
{ {
if (in->type != nir_instr_type_intrinsic)
return false;
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(in);
if (instr->intrinsic != nir_intrinsic_load_base_vertex) if (instr->intrinsic != nir_intrinsic_load_base_vertex)
return false; return false;
@ -253,29 +256,18 @@ lower_basevertex(nir_shader *shader)
if (!BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX)) if (!BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_BASE_VERTEX))
return false; return false;
nir_foreach_function(function, shader) { return nir_shader_instructions_pass(shader, lower_basevertex_instr, nir_metadata_dominance, NULL);
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_basevertex_instr(nir_instr_as_intrinsic(instr),
&builder);
}
}
nir_metadata_preserve(function->impl, nir_metadata_dominance);
}
}
return progress; return progress;
} }
static bool static bool
lower_drawid_instr(nir_intrinsic_instr *instr, nir_builder *b) lower_drawid_instr(nir_builder *b, nir_instr *in, void *data)
{ {
if (in->type != nir_instr_type_intrinsic)
return false;
nir_intrinsic_instr *instr = nir_instr_as_intrinsic(in);
if (instr->intrinsic != nir_intrinsic_load_draw_id) if (instr->intrinsic != nir_intrinsic_load_draw_id)
return false; return false;
@ -295,31 +287,13 @@ lower_drawid_instr(nir_intrinsic_instr *instr, nir_builder *b)
static bool static bool
lower_drawid(nir_shader *shader) lower_drawid(nir_shader *shader)
{ {
bool progress = false;
if (shader->info.stage != MESA_SHADER_VERTEX) if (shader->info.stage != MESA_SHADER_VERTEX)
return false; return false;
if (!BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_DRAW_ID)) if (!BITSET_TEST(shader->info.system_values_read, SYSTEM_VALUE_DRAW_ID))
return false; return false;
nir_foreach_function(function, shader) { return nir_shader_instructions_pass(shader, lower_drawid_instr, nir_metadata_dominance, NULL);
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_drawid_instr(nir_instr_as_intrinsic(instr),
&builder);
}
}
nir_metadata_preserve(function->impl, nir_metadata_dominance);
}
}
return progress;
} }
void void