From 8a6850d33cfc1e6c62c13a6198f2afb5fad7986b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 9 Jan 2024 15:49:53 -0400 Subject: [PATCH] agx: return progress from passes so we can be smarter about validation Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.h | 2 +- src/asahi/compiler/agx_nir.h | 6 +++--- src/asahi/compiler/agx_nir_lower_cull_distance.c | 8 ++++++-- src/asahi/compiler/agx_nir_lower_layer.c | 3 ++- src/asahi/compiler/agx_nir_lower_subgroups.c | 8 +++++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/asahi/compiler/agx_compile.h b/src/asahi/compiler/agx_compile.h index 2437536dd20..af5f08840ea 100644 --- a/src/asahi/compiler/agx_compile.h +++ b/src/asahi/compiler/agx_compile.h @@ -244,7 +244,7 @@ void agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, bool agx_nir_lower_discard_zs_emit(nir_shader *s); -void agx_nir_lower_cull_distance_fs(struct nir_shader *s, +bool agx_nir_lower_cull_distance_fs(struct nir_shader *s, unsigned nr_distances); bool agx_nir_needs_texture_crawl(nir_instr *instr); diff --git a/src/asahi/compiler/agx_nir.h b/src/asahi/compiler/agx_nir.h index b622cb6bf8e..b52a77c01fe 100644 --- a/src/asahi/compiler/agx_nir.h +++ b/src/asahi/compiler/agx_nir.h @@ -15,8 +15,8 @@ bool agx_nir_lower_algebraic_late(struct nir_shader *shader); bool agx_nir_fuse_algebraic_late(struct nir_shader *shader); bool agx_nir_fence_images(struct nir_shader *shader); bool agx_nir_lower_multisampled_image_store(struct nir_shader *s); -void agx_nir_lower_layer(struct nir_shader *s); -void agx_nir_lower_cull_distance_vs(struct nir_shader *s); -void agx_nir_lower_subgroups(struct nir_shader *s); +bool agx_nir_lower_layer(struct nir_shader *s); +bool agx_nir_lower_cull_distance_vs(struct nir_shader *s); +bool agx_nir_lower_subgroups(struct nir_shader *s); #endif diff --git a/src/asahi/compiler/agx_nir_lower_cull_distance.c b/src/asahi/compiler/agx_nir_lower_cull_distance.c index c53f420e960..8c7734e3342 100644 --- a/src/asahi/compiler/agx_nir_lower_cull_distance.c +++ b/src/asahi/compiler/agx_nir_lower_cull_distance.c @@ -58,7 +58,7 @@ lower_write(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) return true; } -void +bool agx_nir_lower_cull_distance_vs(nir_shader *s) { assert(s->info.stage == MESA_SHADER_VERTEX); @@ -70,9 +70,10 @@ agx_nir_lower_cull_distance_vs(nir_shader *s) s->info.outputs_written |= BITFIELD64_RANGE(VARYING_SLOT_CULL_PRIMITIVE, DIV_ROUND_UP(s->info.cull_distance_array_size, 4)); + return true; } -void +bool agx_nir_lower_cull_distance_fs(nir_shader *s, unsigned nr_distances) { assert(s->info.stage == MESA_SHADER_FRAGMENT); @@ -109,4 +110,7 @@ agx_nir_lower_cull_distance_fs(nir_shader *s, unsigned nr_distances) DIV_ROUND_UP(nr_distances, 4)); s->info.fs.uses_discard = true; + nir_metadata_preserve(b->impl, + nir_metadata_dominance | nir_metadata_block_index); + return true; } diff --git a/src/asahi/compiler/agx_nir_lower_layer.c b/src/asahi/compiler/agx_nir_lower_layer.c index eb443f54ae0..646eb73ab1f 100644 --- a/src/asahi/compiler/agx_nir_lower_layer.c +++ b/src/asahi/compiler/agx_nir_lower_layer.c @@ -7,7 +7,7 @@ #include "compiler/nir/nir_builder.h" #include "agx_nir.h" -void +bool agx_nir_lower_layer(nir_shader *s) { assert(s->info.stage == MESA_SHADER_VERTEX); @@ -66,4 +66,5 @@ agx_nir_lower_layer(nir_shader *s) nir_metadata_preserve(impl, nir_metadata_dominance | nir_metadata_block_index); + return true; } diff --git a/src/asahi/compiler/agx_nir_lower_subgroups.c b/src/asahi/compiler/agx_nir_lower_subgroups.c index 0ef68a6fce1..88166fcf7fa 100644 --- a/src/asahi/compiler/agx_nir_lower_subgroups.c +++ b/src/asahi/compiler/agx_nir_lower_subgroups.c @@ -33,7 +33,7 @@ lower(nir_builder *b, nir_intrinsic_instr *intr, void *data) } } -void +bool agx_nir_lower_subgroups(nir_shader *s) { /* First, do as much common lowering as we can */ @@ -47,9 +47,11 @@ agx_nir_lower_subgroups(nir_shader *s) .ballot_bit_size = 32, }; - NIR_PASS_V(s, nir_lower_subgroups, &opts); + bool progress = nir_lower_subgroups(s, &opts); /* Then do AGX-only lowerings on top */ - nir_shader_intrinsics_pass( + progress |= nir_shader_intrinsics_pass( s, lower, nir_metadata_block_index | nir_metadata_dominance, NULL); + + return progress; }