agx: Lower LOD bias earlier

To make the extra descriptor accesses explicit for drivers.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26056>
This commit is contained in:
Alyssa Rosenzweig 2023-10-06 09:45:18 -04:00 committed by Marge Bot
parent 972f289740
commit ca42562c7f
6 changed files with 18 additions and 20 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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);

View file

@ -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);