From a9a6af50a765b33ca5ece4d7b5caae9fd35e1841 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 27 May 2024 17:40:15 -0400 Subject: [PATCH] agx: rework libagx I/O lowering that would otherwise fight with other driver I/O lowering. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 7 +------ src/asahi/lib/agx_nir_lower_gs.c | 3 +-- src/gallium/drivers/asahi/agx_state.c | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index efc6e223b7b..a0746d6ecae 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -3230,8 +3230,7 @@ agx_link_libagx(nir_shader *nir, const nir_shader *libagx) NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp | nir_var_shader_temp, NULL); NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global, + nir_var_shader_temp | nir_var_function_temp, glsl_get_cl_type_size_align); } @@ -3291,10 +3290,6 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx) NIR_PASS(_, nir, nir_opt_deref); NIR_PASS(_, nir, nir_lower_vars_to_ssa); - NIR_PASS(_, nir, nir_lower_explicit_io, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global, - nir_address_format_62bit_generic); /* We're lowered away all variables. Remove them all for smaller shaders. */ NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_all, NULL); diff --git a/src/asahi/lib/agx_nir_lower_gs.c b/src/asahi/lib/agx_nir_lower_gs.c index 1da1b31371e..4cb45910328 100644 --- a/src/asahi/lib/agx_nir_lower_gs.c +++ b/src/asahi/lib/agx_nir_lower_gs.c @@ -1149,8 +1149,7 @@ link_libagx(nir_shader *nir, const nir_shader *libagx) NIR_PASS(_, nir, nir_lower_indirect_derefs, nir_var_function_temp, 64); NIR_PASS(_, nir, nir_opt_dce); NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global, + nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared, glsl_get_cl_type_size_align); NIR_PASS(_, nir, nir_opt_deref); NIR_PASS(_, nir, nir_lower_vars_to_ssa); diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 300e90b940a..4df862e7f27 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -2562,8 +2562,20 @@ agx_build_meta_shader_internal(struct agx_context *ctx, builder(&b, data); struct agx_device *dev = agx_device(ctx->base.screen); - if (!prolog) - agx_preprocess_nir(b.shader, dev->libagx); + if (!prolog) { + /* We need to link libagx and assign shared before preprocessing, matching + * what the driver would otherwise produce. + */ + agx_link_libagx(b.shader, dev->libagx); + + NIR_PASS(_, b.shader, nir_lower_vars_to_explicit_types, + nir_var_mem_shared, glsl_get_cl_type_size_align); + + NIR_PASS(_, b.shader, nir_lower_explicit_io, nir_var_mem_shared, + nir_address_format_62bit_generic); + + agx_preprocess_nir(b.shader, NULL); + } struct agx_compiled_shader *shader = agx_compile_nir( dev, b.shader, NULL, PIPE_SHADER_COMPUTE, internal_kernel,