mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-18 19:50:20 +01:00
panfrost: Convert to use nir_foreach_function_impl when possible
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23960>
This commit is contained in:
parent
9b6dbb2a2b
commit
d86bcc39d6
3 changed files with 16 additions and 25 deletions
|
|
@ -4811,19 +4811,16 @@ bi_compile_variant_nir(nir_shader *nir,
|
|||
|
||||
ctx->allocated_vec = _mesa_hash_table_u64_create(ctx);
|
||||
|
||||
nir_foreach_function(func, nir) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
|
||||
nir_index_blocks(func->impl);
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
nir_index_blocks(impl);
|
||||
|
||||
ctx->indexed_nir_blocks =
|
||||
rzalloc_array(ctx, bi_block *, func->impl->num_blocks);
|
||||
rzalloc_array(ctx, bi_block *, impl->num_blocks);
|
||||
|
||||
ctx->ssa_alloc += func->impl->ssa_alloc;
|
||||
ctx->reg_alloc += func->impl->reg_alloc;
|
||||
ctx->ssa_alloc += impl->ssa_alloc;
|
||||
ctx->reg_alloc += impl->reg_alloc;
|
||||
|
||||
emit_cf_list(ctx, &func->impl->body);
|
||||
emit_cf_list(ctx, &impl->body);
|
||||
bi_emit_phis_deferred(ctx);
|
||||
break; /* TODO: Multi-function shaders */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,11 +49,8 @@ nir_fuse_io_16(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -84,7 +81,7 @@ nir_fuse_io_16(nir_shader *shader)
|
|||
|
||||
intr->dest.ssa.bit_size = 16;
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
b.cursor = nir_after_instr(instr);
|
||||
|
||||
/* The f2f32(f2fmp(x)) will cancel by opt_algebraic */
|
||||
|
|
@ -96,7 +93,7 @@ nir_fuse_io_16(nir_shader *shader)
|
|||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index | nir_metadata_dominance);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,14 +85,11 @@ pan_nir_lower_zs_store(nir_shader *nir)
|
|||
if (nir->info.stage != MESA_SHADER_FRAGMENT)
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, nir) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
nir_intrinsic_instr *stores[3] = {NULL};
|
||||
unsigned writeout = 0;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -135,7 +132,7 @@ pan_nir_lower_zs_store(nir_shader *nir)
|
|||
|
||||
bool replaced = false;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -154,7 +151,7 @@ pan_nir_lower_zs_store(nir_shader *nir)
|
|||
|
||||
assert(nir_src_is_const(intr->src[1]) && "no indirect outputs");
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
b.cursor = nir_after_block_before_jump(instr->block);
|
||||
|
||||
/* Trying to write depth twice results in the
|
||||
|
|
@ -172,7 +169,7 @@ pan_nir_lower_zs_store(nir_shader *nir)
|
|||
|
||||
/* Insert a store to the depth RT (0xff) if needed */
|
||||
if (!replaced) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
b.cursor = nir_after_block_before_jump(common_block);
|
||||
|
||||
pan_nir_emit_combined_store(&b, NULL, writeout, stores);
|
||||
|
|
@ -183,7 +180,7 @@ pan_nir_lower_zs_store(nir_shader *nir)
|
|||
nir_instr_remove(&stores[i]->instr);
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index | nir_metadata_dominance);
|
||||
progress = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue