asahi: Move compiler preprocess out of agx_nir_lower_gs

We run agx_preprocess_nir as the last step of each new compute shaders
in agx_nir_lower_gs but we could move this out of the pass and makes it
the driver responsability to call it.

Signed-off-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37914>
This commit is contained in:
Mary Guillemard 2025-10-06 09:30:38 +02:00 committed by Marge Bot
parent a427581c4d
commit 60e5abdbaa
4 changed files with 11 additions and 3 deletions

View file

@ -3672,6 +3672,9 @@ agx_nir_lower_fdiv(nir_builder *b, nir_alu_instr *alu, void *_)
void
agx_preprocess_nir(nir_shader *nir)
{
if (!nir)
return;
NIR_PASS(_, nir, nir_lower_vars_to_ssa);
/* Lower large arrays to scratch and small arrays to csel */

View file

@ -459,7 +459,6 @@ create_geometry_count_shader(nir_shader *gs, struct lower_gs_state *state)
NIR_PASS(_, shader, nir_shader_intrinsics_pass, lower_id,
nir_metadata_control_flow, NULL);
agx_preprocess_nir(shader);
return shader;
}
@ -833,7 +832,6 @@ create_gs_rast_shader(const nir_shader *gs, const struct lower_gs_state *state)
nir_lower_default_point_size(shader);
}
agx_preprocess_nir(shader);
return shader;
}
@ -951,7 +949,6 @@ create_pre_gs(struct agx_xfb_key *key)
nir_load_stat_query_address_poly(b, .base = PIPE_STAT_QUERY_C_PRIMITIVES),
nir_load_stat_query_address_poly(b,
.base = PIPE_STAT_QUERY_C_INVOCATIONS));
agx_preprocess_nir(b->shader);
return b->shader;
}

View file

@ -1348,6 +1348,10 @@ hk_compile_shader(struct hk_device *dev, struct vk_shader_compile_info *info,
NIR_PASS(_, nir, agx_nir_lower_gs, &count, &rast, &pre_gs,
&count_variant->info.gs);
agx_preprocess_nir(count);
agx_preprocess_nir(rast);
agx_preprocess_nir(pre_gs);
struct hk_shader *shader = &obj->variants[HK_GS_VARIANT_RAST];
hk_lower_hw_vs(rast, shader, false);
shader->info.gs = count_variant->info.gs;

View file

@ -1593,6 +1593,10 @@ agx_compile_variant(struct agx_device *dev, struct pipe_context *pctx,
} else if (nir->info.stage == MESA_SHADER_GEOMETRY) {
NIR_PASS(_, nir, agx_nir_lower_gs, &gs_count, &gs_copy, &pre_gs,
&gs_info);
agx_preprocess_nir(gs_count);
agx_preprocess_nir(gs_copy);
agx_preprocess_nir(pre_gs);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
struct asahi_fs_shader_key *key = &key_->fs;