mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-27 00:10:40 +02:00
lima: Convert to use nir_foreach_function_impl when possible
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Erico Nunes <nunes.erico@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24316>
This commit is contained in:
parent
29f4e7b215
commit
d45f846946
5 changed files with 29 additions and 45 deletions
|
|
@ -117,9 +117,7 @@ lima_nir_duplicate_load_consts_impl(nir_shader *shader, nir_function_impl *impl)
|
|||
void
|
||||
lima_nir_duplicate_load_consts(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
lima_nir_duplicate_load_consts_impl(shader, function->impl);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
lima_nir_duplicate_load_consts_impl(shader, impl);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,10 +139,8 @@ lima_nir_duplicate_intrinsic_impl(nir_shader *shader, nir_function_impl *impl,
|
|||
void
|
||||
lima_nir_duplicate_load_uniforms(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
lima_nir_duplicate_intrinsic_impl(shader, function->impl, nir_intrinsic_load_uniform);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
lima_nir_duplicate_intrinsic_impl(shader, impl, nir_intrinsic_load_uniform);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -152,9 +150,7 @@ lima_nir_duplicate_load_uniforms(nir_shader *shader)
|
|||
void
|
||||
lima_nir_duplicate_load_inputs(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
lima_nir_duplicate_intrinsic_impl(shader, function->impl, nir_intrinsic_load_input);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
lima_nir_duplicate_intrinsic_impl(shader, impl, nir_intrinsic_load_input);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,22 +59,20 @@ lower_load_uniform_to_scalar(nir_builder *b, nir_intrinsic_instr *intr)
|
|||
void
|
||||
lima_nir_lower_uniform_to_scalar(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
if (intr->intrinsic != nir_intrinsic_load_uniform)
|
||||
continue;
|
||||
if (intr->intrinsic != nir_intrinsic_load_uniform)
|
||||
continue;
|
||||
|
||||
lower_load_uniform_to_scalar(&b, intr);
|
||||
}
|
||||
lower_load_uniform_to_scalar(&b, intr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,18 +126,16 @@ lima_nir_split_loads(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block_reverse(block, function->impl) {
|
||||
nir_foreach_instr_reverse_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_load_const) {
|
||||
replace_load_const(&b, nir_instr_as_load_const(instr));
|
||||
progress = true;
|
||||
} else if (instr->type == nir_instr_type_intrinsic) {
|
||||
progress |= replace_intrinsic(&b, nir_instr_as_intrinsic(instr));
|
||||
}
|
||||
nir_foreach_block_reverse(block, impl) {
|
||||
nir_foreach_instr_reverse_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_load_const) {
|
||||
replace_load_const(&b, nir_instr_as_load_const(instr));
|
||||
progress = true;
|
||||
} else if (instr->type == nir_instr_type_intrinsic) {
|
||||
progress |= replace_intrinsic(&b, nir_instr_as_intrinsic(instr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -919,11 +919,8 @@ bool ppir_compile_nir(struct lima_fs_compiled_shader *prog, struct nir_shader *n
|
|||
comp->dual_source_blend = nir->info.fs.color_is_dual_source;
|
||||
|
||||
/* 1st pass: create ppir blocks */
|
||||
nir_foreach_function(function, nir) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(nblock, function->impl) {
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
nir_foreach_block(nblock, impl) {
|
||||
ppir_block *block = ppir_block_create(comp);
|
||||
if (!block)
|
||||
return false;
|
||||
|
|
@ -933,11 +930,8 @@ bool ppir_compile_nir(struct lima_fs_compiled_shader *prog, struct nir_shader *n
|
|||
}
|
||||
|
||||
/* 2nd pass: populate successors */
|
||||
nir_foreach_function(function, nir) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(nblock, function->impl) {
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
nir_foreach_block(nblock, impl) {
|
||||
ppir_block *block = ppir_get_block(comp, nblock);
|
||||
assert(block);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue