diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 6bc8f80951d..03c54dad3af 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -2818,8 +2818,7 @@ link_libagx(nir_shader *nir, const nir_shader *libagx) */ void agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, - bool support_lod_bias, bool allow_mediump, - struct agx_uncompiled_shader_info *out) + bool allow_mediump, struct agx_uncompiled_shader_info *out) { if (out) memset(out, 0, sizeof(*out)); @@ -2867,7 +2866,7 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, /* Clean up deref gunk after lowering I/O */ NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, agx_nir_lower_texture, support_lod_bias); + NIR_PASS_V(nir, agx_nir_lower_texture); link_libagx(nir, libagx); diff --git a/src/asahi/compiler/agx_compile.h b/src/asahi/compiler/agx_compile.h index 2f8990e8583..e9d0ad68906 100644 --- a/src/asahi/compiler/agx_compile.h +++ b/src/asahi/compiler/agx_compile.h @@ -225,10 +225,10 @@ struct agx_shader_key { /* Texture backend flags */ #define AGX_TEXTURE_FLAG_NO_CLAMP (1 << 0) -bool agx_nir_lower_texture_early(nir_shader *s); +bool agx_nir_lower_texture_early(nir_shader *s, bool support_lod_bias); void agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, - bool support_lod_bias, bool allow_mediump, + bool allow_mediump, struct agx_uncompiled_shader_info *out); bool agx_nir_lower_discard_zs_emit(nir_shader *s); diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index 87d16bda53c..e74cb77094d 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -853,7 +853,7 @@ void agx_compute_liveness(agx_context *ctx); void agx_liveness_ins_update(BITSET_WORD *live, agx_instr *I); bool agx_nir_lower_sample_mask(nir_shader *s, unsigned nr_samples); -bool agx_nir_lower_texture(nir_shader *s, bool support_lod_bias); +bool agx_nir_lower_texture(nir_shader *s); bool agx_nir_opt_preamble(nir_shader *s, unsigned *preamble_size); bool agx_nir_lower_load_mask(nir_shader *shader); bool agx_nir_lower_address(nir_shader *shader); diff --git a/src/asahi/compiler/agx_nir_lower_texture.c b/src/asahi/compiler/agx_nir_lower_texture.c index 9a9eb4c0eac..209433a30ec 100644 --- a/src/asahi/compiler/agx_nir_lower_texture.c +++ b/src/asahi/compiler/agx_nir_lower_texture.c @@ -550,7 +550,7 @@ lower_images(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) * agx_preprocess_nir (and hence the full agx_nir_lower_texture). */ bool -agx_nir_lower_texture_early(nir_shader *s) +agx_nir_lower_texture_early(nir_shader *s, bool support_lod_bias) { bool progress = false; @@ -568,11 +568,19 @@ agx_nir_lower_texture_early(nir_shader *s) NIR_PASS(progress, s, nir_lower_tex, &lower_tex_options); + /* Lower bias after nir_lower_tex (to get rid of txd) but before + * lower_regular_texture (which will shuffle around the sources) + */ + if (support_lod_bias) { + NIR_PASS(progress, s, nir_shader_instructions_pass, lower_sampler_bias, + nir_metadata_block_index | nir_metadata_dominance, NULL); + } + return progress; } bool -agx_nir_lower_texture(nir_shader *s, bool support_lod_bias) +agx_nir_lower_texture(nir_shader *s) { bool progress = false; @@ -591,14 +599,6 @@ agx_nir_lower_texture(nir_shader *s, bool support_lod_bias) NIR_PASS(progress, s, nir_lower_image_atomics_to_global); - /* Lower bias after nir_lower_tex (to get rid of txd) but before - * lower_regular_texture (which will shuffle around the sources) - */ - if (support_lod_bias) { - NIR_PASS(progress, s, nir_shader_instructions_pass, lower_sampler_bias, - nir_metadata_block_index | nir_metadata_dominance, NULL); - } - NIR_PASS(progress, s, nir_shader_intrinsics_pass, legalize_image_lod, nir_metadata_block_index | nir_metadata_dominance, NULL); NIR_PASS(progress, s, nir_shader_intrinsics_pass, lower_images, diff --git a/src/asahi/lib/agx_meta.c b/src/asahi/lib/agx_meta.c index ae7664b08d4..e0b90ad7fff 100644 --- a/src/asahi/lib/agx_meta.c +++ b/src/asahi/lib/agx_meta.c @@ -33,7 +33,7 @@ agx_compile_meta_shader(struct agx_meta_cache *cache, nir_shader *shader, struct util_dynarray binary; util_dynarray_init(&binary, NULL); - agx_preprocess_nir(shader, cache->dev->libagx, false, false, NULL); + agx_preprocess_nir(shader, cache->dev->libagx, false, NULL); if (tib) { unsigned bindless_base = 0; agx_nir_lower_tilebuffer(shader, tib, NULL, &bindless_base, NULL, true); diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 92a5dceb3bd..ebd88c4b38c 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -1773,7 +1773,7 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so, NIR_PASS_V(nir, nir_lower_robust_access, &robustness); /* Similarly, we need to do early texture lowering before bindings */ - NIR_PASS_V(nir, agx_nir_lower_texture_early); + NIR_PASS_V(nir, agx_nir_lower_texture_early, support_lod_bias); /* We need to lower binding tables before calling agx_preprocess_nir, since * that does texture lowering that needs to know the binding model. @@ -1789,8 +1789,7 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so, } bool allow_mediump = !(dev->debug & AGX_DBG_NO16); - agx_preprocess_nir(nir, dev->libagx, support_lod_bias, allow_mediump, - &so->info); + agx_preprocess_nir(nir, dev->libagx, allow_mediump, &so->info); blob_init(&so->serialized_nir); nir_serialize(&so->serialized_nir, nir, true);