From 89de5e22ae181f6d71dc88f97aa175a598df1904 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 10 Jan 2024 09:56:32 -0400 Subject: [PATCH] asahi: don't use NIR_PASS_V find . -type f -exec sed -ie 's/NIR_PASS_V(/NIR_PASS(_, /' \{} \; Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/clc/asahi_clc.c | 54 +++--- src/asahi/compiler/agx_compile.c | 178 +++++++++--------- .../compiler/agx_nir_lower_frag_sidefx.c | 2 +- src/asahi/lib/agx_nir_lower_gs.c | 80 ++++---- src/gallium/drivers/asahi/agx_state.c | 79 ++++---- 5 files changed, 197 insertions(+), 196 deletions(-) diff --git a/src/asahi/clc/asahi_clc.c b/src/asahi/clc/asahi_clc.c index a818ccd5872..d2f8e9b97ac 100644 --- a/src/asahi/clc/asahi_clc.c +++ b/src/asahi/clc/asahi_clc.c @@ -144,54 +144,54 @@ compile(void *memctx, const uint32_t *spirv, size_t spirv_size) nir_validate_ssa_dominance(nir, "after spirv_to_nir"); ralloc_steal(memctx, nir); - NIR_PASS_V(nir, nir_lower_system_values); + NIR_PASS(_, nir, nir_lower_system_values); nir_shader_instructions_pass(nir, lower_builtins, nir_metadata_none, NULL); /* We have to lower away local constant initializers right before we * inline functions. That way they get properly initialized at the top * of the function and not at the top of its caller. */ - NIR_PASS_V(nir, nir_lower_variable_initializers, nir_var_function_temp); - NIR_PASS_V(nir, nir_lower_returns); - NIR_PASS_V(nir, nir_inline_functions); + NIR_PASS(_, nir, nir_lower_variable_initializers, nir_var_function_temp); + NIR_PASS(_, nir, nir_lower_returns); + NIR_PASS(_, nir, nir_inline_functions); nir_remove_non_exported(nir); - NIR_PASS_V(nir, nir_copy_prop); - NIR_PASS_V(nir, nir_opt_deref); + NIR_PASS(_, nir, nir_copy_prop); + NIR_PASS(_, nir, nir_opt_deref); /* We can go ahead and lower the rest of the constant initializers. We do * this here so that nir_remove_dead_variables and split_per_member_structs * below see the corresponding stores. */ - NIR_PASS_V(nir, nir_lower_variable_initializers, ~0); + NIR_PASS(_, nir, nir_lower_variable_initializers, ~0); /* LLVM loves take advantage of the fact that vec3s in OpenCL are 16B * aligned and so it can just read/write them as vec4s. This results in a * LOT of vec4->vec3 casts on loads and stores. One solution to this * problem is to get rid of all vec3 variables. */ - NIR_PASS_V(nir, nir_lower_vec3_to_vec4, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global | nir_var_mem_constant); + NIR_PASS(_, nir, nir_lower_vec3_to_vec4, + nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | + nir_var_mem_global | nir_var_mem_constant); /* We assign explicit types early so that the optimizer can take advantage * of that information and hopefully get rid of some of our memcpys. */ - NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, - nir_var_uniform | nir_var_shader_temp | nir_var_function_temp | - nir_var_mem_shared | nir_var_mem_global, - glsl_get_cl_type_size_align); + NIR_PASS(_, nir, nir_lower_vars_to_explicit_types, + nir_var_uniform | nir_var_shader_temp | nir_var_function_temp | + nir_var_mem_shared | nir_var_mem_global, + glsl_get_cl_type_size_align); optimize(nir); - NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_all, NULL); + NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_all, NULL); /* Lower again, this time after dead-variables to get more compact variable * layouts. */ - NIR_PASS_V(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_mem_constant, - glsl_get_cl_type_size_align); + 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_mem_constant, + glsl_get_cl_type_size_align); if (nir->constant_data_size > 0) { assert(nir->constant_data == NULL); nir->constant_data = rzalloc_size(nir, nir->constant_data_size); @@ -200,21 +200,21 @@ compile(void *memctx, const uint32_t *spirv, size_t spirv_size) nir_var_mem_constant); } - NIR_PASS_V(nir, nir_lower_memcpy); + NIR_PASS(_, nir, nir_lower_memcpy); - NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_constant, - nir_address_format_64bit_global); + NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_mem_constant, + nir_address_format_64bit_global); - NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_uniform, - nir_address_format_32bit_offset_as_64bit); + NIR_PASS(_, nir, nir_lower_explicit_io, nir_var_uniform, + nir_address_format_32bit_offset_as_64bit); /* Note: we cannot lower explicit I/O here, because we need derefs in tact * for function calls into the library to work. */ - NIR_PASS_V(nir, nir_lower_convert_alu_types, NULL); - NIR_PASS_V(nir, nir_opt_if, 0); - NIR_PASS_V(nir, nir_opt_idiv_const, 16); + NIR_PASS(_, nir, nir_lower_convert_alu_types, NULL); + NIR_PASS(_, nir, nir_opt_if, 0); + NIR_PASS(_, nir, nir_opt_idiv_const, 16); optimize(nir); diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index e01fe445322..52434dff42e 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -2404,16 +2404,16 @@ static void agx_optimize_nir(nir_shader *nir, unsigned *preamble_size) { /* This runs only once up front since other optimizations don't affect it */ - NIR_PASS_V(nir, nir_opt_shrink_stores, true); + NIR_PASS(_, nir, nir_opt_shrink_stores, true); agx_optimize_loop_nir(nir); - NIR_PASS_V(nir, nir_opt_load_store_vectorize, - &(const nir_load_store_vectorize_options){ - .modes = nir_var_mem_global | nir_var_mem_constant, - .callback = mem_vectorize_cb, - }); - NIR_PASS_V(nir, nir_lower_pack); + NIR_PASS(_, nir, nir_opt_load_store_vectorize, + &(const nir_load_store_vectorize_options){ + .modes = nir_var_mem_global | nir_var_mem_constant, + .callback = mem_vectorize_cb, + }); + NIR_PASS(_, nir, nir_lower_pack); bool progress = false; NIR_PASS(progress, nir, agx_nir_lower_address); @@ -2423,8 +2423,8 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size) * lowering int64 too, to avoid lowering constant int64 arithmetic. */ if (progress) { - NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_opt_dce); + NIR_PASS(_, nir, nir_opt_constant_folding); + NIR_PASS(_, nir, nir_opt_dce); } /* Only lower int64 after optimizing address arithmetic, so that u2u64/i2i64 @@ -2447,16 +2447,16 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size) } if (likely(!(agx_compiler_debug & AGX_DBG_NOPREAMBLE))) - NIR_PASS_V(nir, agx_nir_opt_preamble, preamble_size); + NIR_PASS(_, nir, agx_nir_opt_preamble, preamble_size); /* Forming preambles may dramatically reduce the instruction count * in certain blocks, causing some if-else statements to become * trivial. We want to peephole select those, given that control flow * prediction instructions are costly. */ - NIR_PASS_V(nir, nir_opt_peephole_select, 64, false, true); + NIR_PASS(_, nir, nir_opt_peephole_select, 64, false, true); - NIR_PASS_V(nir, nir_opt_algebraic_late); + NIR_PASS(_, nir, nir_opt_algebraic_late); /* Fuse add/sub/multiplies/shifts after running opt_algebraic_late to fuse * isub but before shifts are lowered. @@ -2472,19 +2472,19 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size) /* Do remaining lowering late, since this inserts &s for shifts so we want to * do it after fusing constant shifts. Constant folding will clean up. */ - NIR_PASS_V(nir, agx_nir_lower_algebraic_late); - NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_opt_combine_barriers, NULL, NULL); + NIR_PASS(_, nir, agx_nir_lower_algebraic_late); + NIR_PASS(_, nir, nir_opt_constant_folding); + NIR_PASS(_, nir, nir_opt_combine_barriers, NULL, NULL); /* Must run after uses are fixed but before a last round of copyprop + DCE */ if (nir->info.stage == MESA_SHADER_FRAGMENT) - NIR_PASS_V(nir, agx_nir_lower_load_mask); + NIR_PASS(_, nir, agx_nir_lower_load_mask); - NIR_PASS_V(nir, nir_copy_prop); - NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, nir_opt_cse); - NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL); - NIR_PASS_V(nir, nir_lower_load_const_to_scalar); + NIR_PASS(_, nir, nir_copy_prop); + NIR_PASS(_, nir, nir_opt_dce); + NIR_PASS(_, nir, nir_opt_cse); + NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL); + NIR_PASS(_, nir, nir_lower_load_const_to_scalar); /* Cleanup optimizations */ nir_move_options move_all = nir_move_const_undef | nir_move_load_ubo | @@ -2492,9 +2492,9 @@ agx_optimize_nir(nir_shader *nir, unsigned *preamble_size) nir_move_copies | nir_move_load_ssbo | nir_move_alu; - NIR_PASS_V(nir, nir_opt_sink, move_all); - NIR_PASS_V(nir, nir_opt_move, move_all); - NIR_PASS_V(nir, nir_lower_phis_to_scalar, true); + NIR_PASS(_, nir, nir_opt_sink, move_all); + NIR_PASS(_, nir, nir_opt_move, move_all); + NIR_PASS(_, nir, nir_lower_phis_to_scalar, true); } /* ABI: position first, then user, then psiz */ @@ -2895,12 +2895,12 @@ static void link_libagx(nir_shader *nir, const nir_shader *libagx) { nir_link_shader_functions(nir, libagx); - NIR_PASS_V(nir, nir_inline_functions); + NIR_PASS(_, nir, nir_inline_functions); nir_remove_non_entrypoints(nir); - NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global, - glsl_get_cl_type_size_align); + 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, + glsl_get_cl_type_size_align); } /* @@ -2925,22 +2925,22 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, if (out) memset(out, 0, sizeof(*out)); - NIR_PASS_V(nir, nir_lower_vars_to_ssa); + NIR_PASS(_, nir, nir_lower_vars_to_ssa); /* Lower large arrays to scratch and small arrays to csel */ - NIR_PASS_V(nir, nir_lower_vars_to_scratch, nir_var_function_temp, 16, - glsl_get_natural_size_align_bytes); - NIR_PASS_V(nir, nir_lower_indirect_derefs, nir_var_function_temp, ~0); - NIR_PASS_V(nir, nir_split_var_copies); - NIR_PASS_V(nir, nir_lower_global_vars_to_local); - NIR_PASS_V(nir, nir_lower_var_copies); - NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out, - glsl_type_size, nir_lower_io_lower_64bit_to_32); - NIR_PASS_V(nir, nir_lower_ssbo); + NIR_PASS(_, nir, nir_lower_vars_to_scratch, nir_var_function_temp, 16, + glsl_get_natural_size_align_bytes); + NIR_PASS(_, nir, nir_lower_indirect_derefs, nir_var_function_temp, ~0); + NIR_PASS(_, nir, nir_split_var_copies); + NIR_PASS(_, nir, nir_lower_global_vars_to_local); + NIR_PASS(_, nir, nir_lower_var_copies); + NIR_PASS(_, nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out, + glsl_type_size, nir_lower_io_lower_64bit_to_32); + NIR_PASS(_, nir, nir_lower_ssbo); if (nir->info.stage == MESA_SHADER_FRAGMENT) { struct interp_masks masks = agx_interp_masks(nir); - NIR_PASS_V(nir, agx_nir_lower_frag_sidefx); + NIR_PASS(_, nir, agx_nir_lower_frag_sidefx); /* Interpolate varyings at fp16 and write to the tilebuffer at fp16. As an * exception, interpolate flat shaded at fp32. This works around a @@ -2950,9 +2950,9 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, if (likely(allow_mediump)) { uint64_t texcoord = agx_texcoord_mask(nir); - NIR_PASS_V(nir, nir_lower_mediump_io, - nir_var_shader_in | nir_var_shader_out, - ~(masks.flat | texcoord), false); + NIR_PASS(_, nir, nir_lower_mediump_io, + nir_var_shader_in | nir_var_shader_out, + ~(masks.flat | texcoord), false); } if (out) { @@ -2964,35 +2964,35 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, out->cull_distance_size = nir->info.cull_distance_array_size; if (out->cull_distance_size) - NIR_PASS_V(nir, agx_nir_lower_cull_distance_vs); + NIR_PASS(_, nir, agx_nir_lower_cull_distance_vs); } /* Clean up deref gunk after lowering I/O */ - NIR_PASS_V(nir, nir_opt_dce); - NIR_PASS_V(nir, agx_nir_lower_texture); + NIR_PASS(_, nir, nir_opt_dce); + NIR_PASS(_, nir, agx_nir_lower_texture); link_libagx(nir, libagx); /* Runs before we lower away idiv, to work at all. But runs after lowering * textures, since the cube map array lowering generates division by 6. */ - NIR_PASS_V(nir, nir_opt_idiv_const, 16); + NIR_PASS(_, nir, nir_opt_idiv_const, 16); nir_lower_idiv_options idiv_options = { .allow_fp16 = true, }; - NIR_PASS_V(nir, nir_lower_idiv, &idiv_options); - NIR_PASS_V(nir, nir_lower_frexp); - NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL); - NIR_PASS_V(nir, nir_lower_load_const_to_scalar); - NIR_PASS_V(nir, nir_lower_flrp, 16 | 32 | 64, false); - NIR_PASS_V(nir, agx_lower_sincos); - NIR_PASS_V(nir, nir_shader_intrinsics_pass, agx_lower_front_face, - nir_metadata_block_index | nir_metadata_dominance, NULL); - NIR_PASS_V(nir, nir_lower_frag_coord_to_pixel_coord); - NIR_PASS_V(nir, agx_nir_lower_subgroups); - NIR_PASS_V(nir, nir_lower_phis_to_scalar, true); + NIR_PASS(_, nir, nir_lower_idiv, &idiv_options); + NIR_PASS(_, nir, nir_lower_frexp); + NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL); + NIR_PASS(_, nir, nir_lower_load_const_to_scalar); + NIR_PASS(_, nir, nir_lower_flrp, 16 | 32 | 64, false); + NIR_PASS(_, nir, agx_lower_sincos); + NIR_PASS(_, nir, nir_shader_intrinsics_pass, agx_lower_front_face, + nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, nir, nir_lower_frag_coord_to_pixel_coord); + NIR_PASS(_, nir, agx_nir_lower_subgroups); + NIR_PASS(_, nir, nir_lower_phis_to_scalar, true); /* After lowering, run through the standard suite of NIR optimizations. We * will run through the loop later, once we have the shader key, but if we @@ -3000,15 +3000,15 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, */ agx_optimize_loop_nir(nir); - NIR_PASS_V(nir, nir_opt_deref); - NIR_PASS_V(nir, nir_lower_vars_to_ssa); - NIR_PASS_V(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); + 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_V(nir, nir_remove_dead_variables, nir_var_all, NULL); + NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_all, NULL); nir->info.io_lowered = true; /* Move before lowering */ @@ -3016,9 +3016,9 @@ agx_preprocess_nir(nir_shader *nir, const nir_shader *libagx, nir_move_load_input | nir_move_comparisons | nir_move_copies | nir_move_load_ssbo; - NIR_PASS_V(nir, nir_opt_sink, move_all); - NIR_PASS_V(nir, nir_opt_move, move_all); - NIR_PASS_V(nir, agx_nir_lower_shared_bitsize); + NIR_PASS(_, nir, nir_opt_sink, move_all); + NIR_PASS(_, nir, nir_opt_move, move_all); + NIR_PASS(_, nir, agx_nir_lower_shared_bitsize); } void @@ -3050,17 +3050,17 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, if (nir->info.stage == MESA_SHADER_FRAGMENT) NIR_PASS(needs_libagx, nir, agx_nir_lower_interpolation); - NIR_PASS_V(nir, nir_lower_vars_to_ssa); + NIR_PASS(_, nir, nir_lower_vars_to_ssa); if (needs_libagx) { link_libagx(nir, key->libagx); - NIR_PASS_V(nir, nir_opt_deref); - NIR_PASS_V(nir, nir_lower_vars_to_ssa); - NIR_PASS_V(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); + 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); } /* Late sysval lowering creates large loads. Load lowering creates unpacks */ @@ -3070,7 +3070,7 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, nir_var_function_temp | nir_var_mem_global | nir_var_mem_shared, .callback = mem_access_size_align_cb, }; - NIR_PASS_V(nir, nir_lower_mem_access_bit_sizes, &lower_mem_access_options); + NIR_PASS(_, nir, nir_lower_mem_access_bit_sizes, &lower_mem_access_options); /* Cleanup 8-bit math before lowering */ bool progress; @@ -3082,31 +3082,31 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, NIR_PASS(progress, nir, nir_opt_dce); } while (progress); - NIR_PASS_V(nir, nir_lower_bit_size, lower_bit_size_callback, NULL); + NIR_PASS(_, nir, nir_lower_bit_size, lower_bit_size_callback, NULL); /* Late blend lowering creates vectors */ - NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL, NULL); - NIR_PASS_V(nir, nir_lower_load_const_to_scalar); + NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL); + NIR_PASS(_, nir, nir_lower_load_const_to_scalar); /* Late VBO lowering creates constant udiv instructions */ - NIR_PASS_V(nir, nir_opt_idiv_const, 16); + NIR_PASS(_, nir, nir_opt_idiv_const, 16); /* Varying output is scalar, other I/O is vector. Lowered late because * transform feedback programs will use vector output. */ if (nir->info.stage == MESA_SHADER_VERTEX) { - NIR_PASS_V(nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); + NIR_PASS(_, nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); if (nir->info.outputs_written & (VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT)) { - NIR_PASS_V(nir, agx_nir_lower_layer); + NIR_PASS(_, nir, agx_nir_lower_layer); } } - NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_shader_intrinsics_pass, lower_load_from_texture_handle, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, nir, nir_opt_constant_folding); + NIR_PASS(_, nir, nir_shader_intrinsics_pass, lower_load_from_texture_handle, + nir_metadata_block_index | nir_metadata_dominance, NULL); out->push_count = key->reserved_preamble; agx_optimize_nir(nir, &out->push_count); @@ -3123,10 +3123,10 @@ agx_compile_shader_nir(nir_shader *nir, struct agx_shader_key *key, * Also constant fold to get the benefit. We need to rescalarize after * folding constants. */ - NIR_PASS_V(nir, agx_nir_opt_ixor_bcsel); - NIR_PASS_V(nir, nir_opt_constant_folding); - NIR_PASS_V(nir, nir_lower_load_const_to_scalar); - NIR_PASS_V(nir, nir_opt_dce); + NIR_PASS(_, nir, agx_nir_opt_ixor_bcsel); + NIR_PASS(_, nir, nir_opt_constant_folding); + NIR_PASS(_, nir, nir_lower_load_const_to_scalar); + NIR_PASS(_, nir, nir_opt_dce); } } diff --git a/src/asahi/compiler/agx_nir_lower_frag_sidefx.c b/src/asahi/compiler/agx_nir_lower_frag_sidefx.c index 7127bdf9104..f1a3923ca86 100644 --- a/src/asahi/compiler/agx_nir_lower_frag_sidefx.c +++ b/src/asahi/compiler/agx_nir_lower_frag_sidefx.c @@ -58,7 +58,7 @@ agx_nir_lower_frag_sidefx(nir_shader *s) return false; /* Lower writes from helper invocations with the common pass */ - NIR_PASS_V(s, nir_lower_helper_writes, false); + NIR_PASS(_, s, nir_lower_helper_writes, false); bool writes_zs = s->info.outputs_written & diff --git a/src/asahi/lib/agx_nir_lower_gs.c b/src/asahi/lib/agx_nir_lower_gs.c index d68814aa28c..238126e2492 100644 --- a/src/asahi/lib/agx_nir_lower_gs.c +++ b/src/asahi/lib/agx_nir_lower_gs.c @@ -260,8 +260,8 @@ agx_nir_link_vs_gs(nir_shader *vs, nir_shader *gs) } /* Rewrite geometry shader inputs to read from those arrays */ - NIR_PASS_V(gs, nir_shader_intrinsics_pass, lower_gs_inputs, - nir_metadata_block_index | nir_metadata_dominance, &state); + NIR_PASS(_, gs, nir_shader_intrinsics_pass, lower_gs_inputs, + nir_metadata_block_index | nir_metadata_dominance, &state); /* Link the vertex shader with the geometry shader. This assumes that * all functions have been inlined in the vertex shader. @@ -431,11 +431,11 @@ agx_nir_create_geometry_count_shader(nir_shader *gs, const nir_shader *libagx, shader->info.name = "count"; } - NIR_PASS_V(shader, nir_shader_intrinsics_pass, lower_gs_count_instr, - nir_metadata_block_index | nir_metadata_dominance, state); + NIR_PASS(_, shader, nir_shader_intrinsics_pass, lower_gs_count_instr, + nir_metadata_block_index | nir_metadata_dominance, state); - NIR_PASS_V(shader, nir_shader_intrinsics_pass, lower_id, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, shader, nir_shader_intrinsics_pass, lower_id, + nir_metadata_block_index | nir_metadata_dominance, NULL); /* Preprocess it */ UNUSED struct agx_uncompiled_shader_info info; @@ -1019,19 +1019,19 @@ static void link_libagx(nir_shader *nir, const nir_shader *libagx) { nir_link_shader_functions(nir, libagx); - NIR_PASS_V(nir, nir_inline_functions); + NIR_PASS(_, nir, nir_inline_functions); nir_remove_non_entrypoints(nir); - NIR_PASS_V(nir, nir_lower_indirect_derefs, nir_var_function_temp, 64); - NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, - nir_var_shader_temp | nir_var_function_temp | nir_var_mem_shared | - nir_var_mem_global, - glsl_get_cl_type_size_align); - NIR_PASS_V(nir, nir_opt_deref); - NIR_PASS_V(nir, nir_lower_vars_to_ssa); - NIR_PASS_V(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); + NIR_PASS(_, nir, nir_lower_indirect_derefs, nir_var_function_temp, 64); + 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, + glsl_get_cl_type_size_align); + 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); } bool @@ -1070,13 +1070,13 @@ agx_nir_lower_gs(nir_shader *gs, nir_shader *vs, const nir_shader *libagx, /* Lower geometry shader writes to contain all of the required counts, so we * know where in the various buffers we should write vertices. */ - NIR_PASS_V(gs, nir_lower_gs_intrinsics, - nir_lower_gs_intrinsics_count_primitives | - nir_lower_gs_intrinsics_per_stream | - nir_lower_gs_intrinsics_count_vertices_per_primitive | - nir_lower_gs_intrinsics_overwrite_incomplete | - nir_lower_gs_intrinsics_always_end_primitive | - nir_lower_gs_intrinsics_count_decomposed_primitives); + NIR_PASS(_, gs, nir_lower_gs_intrinsics, + nir_lower_gs_intrinsics_count_primitives | + nir_lower_gs_intrinsics_per_stream | + nir_lower_gs_intrinsics_count_vertices_per_primitive | + nir_lower_gs_intrinsics_overwrite_incomplete | + nir_lower_gs_intrinsics_always_end_primitive | + nir_lower_gs_intrinsics_count_decomposed_primitives); /* Clean up after all that lowering we did */ bool progress = false; @@ -1101,18 +1101,18 @@ agx_nir_lower_gs(nir_shader *gs, nir_shader *vs, const nir_shader *libagx, } while (progress); if (ia->indirect_multidraw) - NIR_PASS_V(gs, agx_nir_lower_multidraw, ia); + NIR_PASS(_, gs, agx_nir_lower_multidraw, ia); - NIR_PASS_V(gs, nir_shader_intrinsics_pass, lower_id, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, gs, nir_shader_intrinsics_pass, lower_id, + nir_metadata_block_index | nir_metadata_dominance, NULL); link_libagx(gs, libagx); - NIR_PASS_V(gs, nir_lower_idiv, - &(const nir_lower_idiv_options){.allow_fp16 = true}); + NIR_PASS(_, gs, nir_lower_idiv, + &(const nir_lower_idiv_options){.allow_fp16 = true}); /* All those variables we created should've gone away by now */ - NIR_PASS_V(gs, nir_remove_dead_variables, nir_var_function_temp, NULL); + NIR_PASS(_, gs, nir_remove_dead_variables, nir_var_function_temp, NULL); /* If we know counts at compile-time we can simplify, so try to figure out * the counts statically. @@ -1165,8 +1165,8 @@ agx_nir_lower_gs(nir_shader *gs, nir_shader *vs, const nir_shader *libagx, gs_state.stride_B += size_B; } - NIR_PASS_V(gs, nir_shader_instructions_pass, lower_output_to_var, - nir_metadata_block_index | nir_metadata_dominance, &state); + NIR_PASS(_, gs, nir_shader_instructions_pass, lower_output_to_var, + nir_metadata_block_index | nir_metadata_dominance, &state); /* Set flatshade_first. For now this is always a constant, but in the future * we will want this to be dynamic. @@ -1178,8 +1178,8 @@ agx_nir_lower_gs(nir_shader *gs, nir_shader *vs, const nir_shader *libagx, gs_state.flatshade_first = nir_imm_bool(&b, ia->flatshade_first); } - NIR_PASS_V(gs, nir_shader_intrinsics_pass, lower_gs_instr, nir_metadata_none, - &gs_state); + NIR_PASS(_, gs, nir_shader_intrinsics_pass, lower_gs_instr, + nir_metadata_none, &gs_state); /* Clean up after all that lowering we did */ nir_lower_global_vars_to_local(gs); @@ -1199,12 +1199,12 @@ agx_nir_lower_gs(nir_shader *gs, nir_shader *vs, const nir_shader *libagx, } while (progress); /* All those variables we created should've gone away by now */ - NIR_PASS_V(gs, nir_remove_dead_variables, nir_var_function_temp, NULL); + NIR_PASS(_, gs, nir_remove_dead_variables, nir_var_function_temp, NULL); - NIR_PASS_V(gs, nir_opt_sink, ~0); - NIR_PASS_V(gs, nir_opt_move, ~0); - NIR_PASS_V(gs, nir_shader_intrinsics_pass, lower_id, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, gs, nir_opt_sink, ~0); + NIR_PASS(_, gs, nir_opt_move, ~0); + NIR_PASS(_, gs, nir_shader_intrinsics_pass, lower_id, + nir_metadata_block_index | nir_metadata_dominance, NULL); /* Create auxiliary programs */ *gs_copy = agx_nir_create_gs_copy_shader( diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 1c511c6cedd..78bd371b326 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -1744,8 +1744,8 @@ agx_compile_nir(struct agx_device *dev, nir_shader *nir, dev->params.num_dies > 1; key.libagx = dev->libagx; - NIR_PASS_V(nir, agx_nir_lower_sysvals, true); - NIR_PASS_V(nir, agx_nir_layout_uniforms, compiled, &key.reserved_preamble); + NIR_PASS(_, nir, agx_nir_lower_sysvals, true); + NIR_PASS(_, nir, agx_nir_layout_uniforms, compiled, &key.reserved_preamble); agx_compile_shader_nir(nir, &key, debug, &binary, &compiled->info); @@ -1788,21 +1788,21 @@ agx_compile_variant(struct agx_device *dev, struct pipe_context *pctx, if (nir->info.stage == MESA_SHADER_VERTEX) { struct asahi_vs_shader_key *key = &key_->vs; - NIR_PASS_V(nir, agx_nir_lower_vbo, key->attribs); - NIR_PASS_V(nir, agx_nir_lower_point_size, key->fixed_point_size); + NIR_PASS(_, nir, agx_nir_lower_vbo, key->attribs); + NIR_PASS(_, nir, agx_nir_lower_point_size, key->fixed_point_size); if (should_lower_clip_m1_1(dev, key->clip_halfz)) { - NIR_PASS_V(nir, nir_shader_intrinsics_pass, agx_nir_lower_clip_m1_1, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, nir, nir_shader_intrinsics_pass, agx_nir_lower_clip_m1_1, + nir_metadata_block_index | nir_metadata_dominance, NULL); } } else if (nir->info.stage == MESA_SHADER_GEOMETRY) { struct asahi_gs_shader_key *key = &key_->gs; /* XFB occurs for GS, not VS. TODO: Check if active. */ if (nir->xfb_info != NULL) { - NIR_PASS_V(nir, nir_io_add_const_offset_to_base, - nir_var_shader_in | nir_var_shader_out); - NIR_PASS_V(nir, nir_io_add_intrinsic_xfb_info); + NIR_PASS(_, nir, nir_io_add_const_offset_to_base, + nir_var_shader_in | nir_var_shader_out); + NIR_PASS(_, nir, nir_io_add_intrinsic_xfb_info); } struct blob_reader vs_reader; @@ -1811,21 +1811,21 @@ agx_compile_variant(struct agx_device *dev, struct pipe_context *pctx, nir_shader *vs = nir_deserialize(NULL, &agx_nir_options, &vs_reader); /* Apply the VS key to the VS before linking it in */ - NIR_PASS_V(vs, agx_nir_lower_vbo, key->attribs); - NIR_PASS_V(vs, agx_nir_lower_ia, &key->ia); + NIR_PASS(_, vs, agx_nir_lower_vbo, key->attribs); + NIR_PASS(_, vs, agx_nir_lower_ia, &key->ia); - NIR_PASS_V(vs, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); - NIR_PASS_V(nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); + NIR_PASS(_, vs, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); + NIR_PASS(_, nir, nir_lower_io_to_scalar, nir_var_shader_out, NULL, NULL); /* Lower VS sysvals before it's merged in, so we access the correct shader * stage for UBOs etc. Skip draw parameters, those are lowered later. */ - NIR_PASS_V(vs, agx_nir_lower_sysvals, false); + NIR_PASS(_, vs, agx_nir_lower_sysvals, false); /* Link VS with GS */ - NIR_PASS_V(nir, agx_nir_lower_gs, vs, dev->libagx, &key->ia, - key->rasterizer_discard, &gs_count, &gs_copy, &pre_gs, - &gs_out_prim, &gs_out_count_words); + NIR_PASS(_, nir, agx_nir_lower_gs, vs, dev->libagx, &key->ia, + key->rasterizer_discard, &gs_count, &gs_copy, &pre_gs, + &gs_out_prim, &gs_out_count_words); ralloc_free(vs); } else if (nir->info.stage == MESA_SHADER_FRAGMENT) { struct asahi_fs_shader_key *key = &key_->fs; @@ -1884,44 +1884,44 @@ agx_compile_variant(struct agx_device *dev, struct pipe_context *pctx, * the flat/linear masks that get propagated back to the VS. */ if (key->clip_plane_enable) { - NIR_PASS_V(nir, nir_lower_clip_fs, key->clip_plane_enable, false); + NIR_PASS(_, nir, nir_lower_clip_fs, key->clip_plane_enable, false); } /* Similarly for cull distancing lowering */ if (key->cull_distance_size) { - NIR_PASS_V(nir, agx_nir_lower_cull_distance_fs, - key->cull_distance_size); + NIR_PASS(_, nir, agx_nir_lower_cull_distance_fs, + key->cull_distance_size); } /* Discards must be lowering before lowering MSAA to handle discards */ - NIR_PASS_V(nir, agx_nir_lower_discard_zs_emit); + NIR_PASS(_, nir, agx_nir_lower_discard_zs_emit); /* Alpha-to-coverage must be lowered before alpha-to-one */ if (key->blend.alpha_to_coverage) - NIR_PASS_V(nir, agx_nir_lower_alpha_to_coverage, tib.nr_samples); + NIR_PASS(_, nir, agx_nir_lower_alpha_to_coverage, tib.nr_samples); /* Alpha-to-one must be lowered before blending */ if (key->blend.alpha_to_one) - NIR_PASS_V(nir, agx_nir_lower_alpha_to_one); + NIR_PASS(_, nir, agx_nir_lower_alpha_to_one); - NIR_PASS_V(nir, nir_lower_blend, &opts); + NIR_PASS(_, nir, nir_lower_blend, &opts); /* XXX: don't replicate this all over the driver */ unsigned rt_spill_base = BITSET_LAST_BIT(nir->info.textures_used) + (2 * BITSET_LAST_BIT(nir->info.images_used)); unsigned rt_spill = rt_spill_base; - NIR_PASS_V(nir, agx_nir_lower_tilebuffer, &tib, colormasks, &rt_spill, - &force_translucent, false); + NIR_PASS(_, nir, agx_nir_lower_tilebuffer, &tib, colormasks, &rt_spill, + &force_translucent, false); - NIR_PASS_V(nir, agx_nir_lower_sample_intrinsics); - NIR_PASS_V(nir, agx_nir_lower_monolithic_msaa, - &(struct agx_msaa_state){ - .nr_samples = tib.nr_samples, - .api_sample_mask = key->api_sample_mask, - }); + NIR_PASS(_, nir, agx_nir_lower_sample_intrinsics); + NIR_PASS(_, nir, agx_nir_lower_monolithic_msaa, + &(struct agx_msaa_state){ + .nr_samples = tib.nr_samples, + .api_sample_mask = key->api_sample_mask, + }); if (nir->info.inputs_read & VARYING_BIT_LAYER) - NIR_PASS_V(nir, agx_nir_predicate_layer_id); + NIR_PASS(_, nir, agx_nir_predicate_layer_id); } struct agx_shader_key base_key = {0}; @@ -2027,22 +2027,22 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so, /* We need to lower robustness before bindings, since robustness lowering * affects the bindings used. */ - NIR_PASS_V(nir, nir_lower_robust_access, &robustness); + NIR_PASS(_, 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, support_lod_bias); + NIR_PASS(_, 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. */ - NIR_PASS_V(nir, agx_nir_lower_bindings, &so->uses_bindless_samplers); + NIR_PASS(_, nir, agx_nir_lower_bindings, &so->uses_bindless_samplers); if (nir->info.stage == MESA_SHADER_FRAGMENT) { /* Lower to maximum colour buffers, the excess stores will get cleaned up * by tilebuffer lowering so they won't become real shader code. However, * that depends on the shader key which we don't have at this point. */ - NIR_PASS_V(nir, nir_lower_fragcolor, 8); + NIR_PASS(_, nir, nir_lower_fragcolor, 8); } bool allow_mediump = !(dev->debug & AGX_DBG_NO16); @@ -2051,8 +2051,9 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so, if (nir->info.stage == MESA_SHADER_FRAGMENT && (nir->info.inputs_read & VARYING_BITS_TEX_ANY)) { - NIR_PASS_V(nir, nir_shader_intrinsics_pass, agx_nir_lower_point_sprite_zw, - nir_metadata_block_index | nir_metadata_dominance, NULL); + NIR_PASS(_, nir, nir_shader_intrinsics_pass, + agx_nir_lower_point_sprite_zw, + nir_metadata_block_index | nir_metadata_dominance, NULL); } blob_init(&so->serialized_nir);