From 854b6020bddb3dd6775b2643411551bdec4dcf88 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 10 Jan 2024 09:57:14 -0400 Subject: [PATCH] glsl: don't use NIR_PASS_V Signed-off-by: Alyssa Rosenzweig Reviewed-by: Konstantin Seurer Part-of: --- src/compiler/glsl/gl_nir_link_varyings.c | 20 ++--- src/compiler/glsl/gl_nir_linker.c | 74 +++++++++---------- .../gl_nir_lower_blend_equation_advanced.c | 4 +- src/compiler/glsl/glsl_to_nir.cpp | 32 ++++---- .../glsl/tests/test_gl_lower_mediump.cpp | 16 ++-- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/compiler/glsl/gl_nir_link_varyings.c b/src/compiler/glsl/gl_nir_link_varyings.c index 83ad722e041..234d4485c1c 100644 --- a/src/compiler/glsl/gl_nir_link_varyings.c +++ b/src/compiler/glsl/gl_nir_link_varyings.c @@ -3850,8 +3850,8 @@ link_shader_opts(struct varying_matches *vm, */ if (producer->options->lower_to_scalar && !vm->disable_varying_packing && !vm->disable_xfb_packing) { - NIR_PASS_V(producer, nir_lower_io_to_scalar_early, nir_var_shader_out); - NIR_PASS_V(consumer, nir_lower_io_to_scalar_early, nir_var_shader_in); + NIR_PASS(_, producer, nir_lower_io_to_scalar_early, nir_var_shader_out); + NIR_PASS(_, consumer, nir_lower_io_to_scalar_early, nir_var_shader_in); } gl_nir_opts(producer); @@ -3860,12 +3860,12 @@ link_shader_opts(struct varying_matches *vm, if (nir_link_opt_varyings(producer, consumer)) gl_nir_opts(consumer); - NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, NULL); - NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); + NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out, NULL); + NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); if (remove_unused_varyings(producer, consumer, prog, mem_ctx)) { - NIR_PASS_V(producer, nir_lower_global_vars_to_local); - NIR_PASS_V(consumer, nir_lower_global_vars_to_local); + NIR_PASS(_, producer, nir_lower_global_vars_to_local); + NIR_PASS(_, consumer, nir_lower_global_vars_to_local); gl_nir_opts(producer); gl_nir_opts(consumer); @@ -3874,9 +3874,9 @@ link_shader_opts(struct varying_matches *vm, * nir_compact_varyings() depends on all dead varyings being removed so * we need to call nir_remove_dead_variables() again here. */ - NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, + NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out, NULL); - NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, + NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); } @@ -4281,9 +4281,9 @@ link_varyings(struct gl_shader_program *prog, unsigned first, if (!prog->SeparateShader) { /* If not SSO remove unused varyings from the first/last stage */ - NIR_PASS_V(prog->_LinkedShaders[first]->Program->nir, + NIR_PASS(_, prog->_LinkedShaders[first]->Program->nir, nir_remove_dead_variables, nir_var_shader_in, NULL); - NIR_PASS_V(prog->_LinkedShaders[last]->Program->nir, + NIR_PASS(_, prog->_LinkedShaders[last]->Program->nir, nir_remove_dead_variables, nir_var_shader_out, NULL); } else { /* Sort inputs / outputs into a canonical order. This is necessary so diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c index 77ba9f2e911..c4ff190dacc 100644 --- a/src/compiler/glsl/gl_nir_linker.c +++ b/src/compiler/glsl/gl_nir_linker.c @@ -49,7 +49,7 @@ gl_nir_opts(nir_shader *nir) do { progress = false; - NIR_PASS_V(nir, nir_lower_vars_to_ssa); + NIR_PASS(_, nir, nir_lower_vars_to_ssa); /* Linking deals with unused inputs/outputs, but here we can remove * things local to the shader in the hopes that we can cleanup other @@ -66,13 +66,13 @@ gl_nir_opts(nir_shader *nir) NIR_PASS(progress, nir, nir_opt_dead_write_vars); if (nir->options->lower_to_scalar) { - NIR_PASS_V(nir, nir_lower_alu_to_scalar, + NIR_PASS(_, nir, nir_lower_alu_to_scalar, nir->options->lower_to_scalar_filter, NULL); - NIR_PASS_V(nir, nir_lower_phis_to_scalar, false); + NIR_PASS(_, nir, nir_lower_phis_to_scalar, false); } - NIR_PASS_V(nir, nir_lower_alu); - NIR_PASS_V(nir, nir_lower_pack); + NIR_PASS(_, nir, nir_lower_alu); + NIR_PASS(_, nir, nir_lower_pack); NIR_PASS(progress, nir, nir_copy_prop); NIR_PASS(progress, nir, nir_opt_remove_phis); NIR_PASS(progress, nir, nir_opt_dce); @@ -124,7 +124,7 @@ gl_nir_opts(nir_shader *nir) } } while (progress); - NIR_PASS_V(nir, nir_lower_var_copies); + NIR_PASS(_, nir, nir_lower_var_copies); } bool @@ -166,8 +166,8 @@ gl_nir_link_opts(nir_shader *producer, nir_shader *consumer) MESA_TRACE_FUNC(); if (producer->options->lower_to_scalar) { - NIR_PASS_V(producer, nir_lower_io_to_scalar_early, nir_var_shader_out); - NIR_PASS_V(consumer, nir_lower_io_to_scalar_early, nir_var_shader_in); + NIR_PASS(_, producer, nir_lower_io_to_scalar_early, nir_var_shader_out); + NIR_PASS(_, consumer, nir_lower_io_to_scalar_early, nir_var_shader_in); } nir_lower_io_arrays_to_elements(producer, consumer); @@ -178,12 +178,12 @@ gl_nir_link_opts(nir_shader *producer, nir_shader *consumer) if (nir_link_opt_varyings(producer, consumer)) gl_nir_opts(consumer); - NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, NULL); - NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); + NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out, NULL); + NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); if (nir_remove_unused_varyings(producer, consumer)) { - NIR_PASS_V(producer, nir_lower_global_vars_to_local); - NIR_PASS_V(consumer, nir_lower_global_vars_to_local); + NIR_PASS(_, producer, nir_lower_global_vars_to_local); + NIR_PASS(_, consumer, nir_lower_global_vars_to_local); gl_nir_opts(producer); gl_nir_opts(consumer); @@ -192,9 +192,9 @@ gl_nir_link_opts(nir_shader *producer, nir_shader *consumer) * nir_compact_varyings() depends on all dead varyings being removed so * we need to call nir_remove_dead_variables() again here. */ - NIR_PASS_V(producer, nir_remove_dead_variables, nir_var_shader_out, + NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_out, NULL); - NIR_PASS_V(consumer, nir_remove_dead_variables, nir_var_shader_in, + NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_in, NULL); } @@ -979,7 +979,7 @@ lower_patch_vertices_in(struct gl_shader_program *shader_prog) * lower TES gl_PatchVerticesIn to a constant. */ uint32_t tes_patch_verts = tcs_nir->info.tess.tcs_vertices_out; - NIR_PASS_V(tes_nir, nir_lower_patch_vertices, tes_patch_verts, NULL); + NIR_PASS(_, tes_nir, nir_lower_patch_vertices, tes_patch_verts, NULL); } } @@ -999,10 +999,10 @@ preprocess_shader(const struct gl_constants *consts, if (prog->info.stage == MESA_SHADER_FRAGMENT && consts->HasFBFetch) { nir_shader_gather_info(prog->nir, nir_shader_get_entrypoint(prog->nir)); - NIR_PASS_V(prog->nir, gl_nir_lower_blend_equation_advanced, + NIR_PASS(_, prog->nir, gl_nir_lower_blend_equation_advanced, exts->KHR_blend_equation_advanced_coherent); nir_lower_global_vars_to_local(prog->nir); - NIR_PASS_V(prog->nir, nir_opt_combine_stores, nir_var_shader_out); + NIR_PASS(_, prog->nir, nir_opt_combine_stores, nir_var_shader_out); } /* Set the next shader stage hint for VS and TES. */ @@ -1024,57 +1024,57 @@ preprocess_shader(const struct gl_constants *consts, if (!consts->PointSizeFixed && prog->skip_pointsize_xfb && stage < MESA_SHADER_FRAGMENT && stage != MESA_SHADER_TESS_CTRL && gl_nir_can_add_pointsize_to_program(consts, prog)) { - NIR_PASS_V(nir, gl_nir_add_point_size); + NIR_PASS(_, nir, gl_nir_add_point_size); } if (stage < MESA_SHADER_FRAGMENT && stage != MESA_SHADER_TESS_CTRL && (nir->info.outputs_written & (VARYING_BIT_CLIP_DIST0 | VARYING_BIT_CLIP_DIST1))) - NIR_PASS_V(nir, gl_nir_zero_initialize_clip_distance); + NIR_PASS(_, nir, gl_nir_zero_initialize_clip_distance); if (options->lower_all_io_to_temps || nir->info.stage == MESA_SHADER_VERTEX || nir->info.stage == MESA_SHADER_GEOMETRY) { - NIR_PASS_V(nir, nir_lower_io_to_temporaries, + NIR_PASS(_, nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, true); } else if (nir->info.stage == MESA_SHADER_FRAGMENT || !consts->SupportsReadingOutputs) { - NIR_PASS_V(nir, nir_lower_io_to_temporaries, + NIR_PASS(_, nir, nir_lower_io_to_temporaries, nir_shader_get_entrypoint(nir), true, false); } - NIR_PASS_V(nir, nir_lower_global_vars_to_local); - NIR_PASS_V(nir, nir_split_var_copies); - NIR_PASS_V(nir, nir_lower_var_copies); + NIR_PASS(_, nir, nir_lower_global_vars_to_local); + NIR_PASS(_, nir, nir_split_var_copies); + NIR_PASS(_, nir, nir_lower_var_copies); if (gl_options->LowerPrecisionFloat16 && gl_options->LowerPrecisionInt16) { - NIR_PASS_V(nir, nir_lower_mediump_vars, nir_var_function_temp | nir_var_shader_temp | nir_var_mem_shared); + NIR_PASS(_, nir, nir_lower_mediump_vars, nir_var_function_temp | nir_var_shader_temp | nir_var_mem_shared); } if (options->lower_to_scalar) { - NIR_PASS_V(nir, nir_remove_dead_variables, + NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp | nir_var_shader_temp | nir_var_mem_shared, NULL); - NIR_PASS_V(nir, nir_opt_copy_prop_vars); - NIR_PASS_V(nir, nir_lower_alu_to_scalar, + NIR_PASS(_, nir, nir_opt_copy_prop_vars); + NIR_PASS(_, nir, nir_lower_alu_to_scalar, options->lower_to_scalar_filter, NULL); } - NIR_PASS_V(nir, nir_opt_barrier_modes); + NIR_PASS(_, nir, nir_opt_barrier_modes); /* before buffers and vars_to_ssa */ - NIR_PASS_V(nir, gl_nir_lower_images, true); + NIR_PASS(_, nir, gl_nir_lower_images, true); if (prog->nir->info.stage == MESA_SHADER_COMPUTE) { - NIR_PASS_V(prog->nir, nir_lower_vars_to_explicit_types, + NIR_PASS(_, prog->nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared, shared_type_info); - NIR_PASS_V(prog->nir, nir_lower_explicit_io, + NIR_PASS(_, prog->nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset); } /* Do a round of constant folding to clean up address calculations */ - NIR_PASS_V(nir, nir_opt_constant_folding); + NIR_PASS(_, nir, nir_opt_constant_folding); } static bool @@ -1106,7 +1106,7 @@ prelink_lowering(const struct gl_constants *consts, } if (options->lower_to_scalar) { - NIR_PASS_V(shader->Program->nir, nir_lower_load_const_to_scalar); + NIR_PASS(_, shader->Program->nir, nir_lower_load_const_to_scalar); } } @@ -1127,10 +1127,10 @@ prelink_lowering(const struct gl_constants *consts, nir_opt_access_options opt_access_options; opt_access_options.is_vulkan = false; - NIR_PASS_V(nir, nir_opt_access, &opt_access_options); + NIR_PASS(_, nir, nir_opt_access, &opt_access_options); if (consts->ShaderCompilerOptions[i].LowerCombinedClipCullDistance) { - NIR_PASS_V(nir, nir_lower_clip_cull_distance_to_vec4s); + NIR_PASS(_, nir, nir_lower_clip_cull_distance_to_vec4s); } /* Combine clip and cull outputs into one array and set: @@ -1138,7 +1138,7 @@ prelink_lowering(const struct gl_constants *consts, * - shader_info::cull_distance_array_size */ if (consts->CombinedClipCullDistanceArrays) - NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays); + NIR_PASS(_, nir, nir_lower_clip_cull_distance_arrays); } return true; diff --git a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c index dffd946b1fd..404c64f4484 100644 --- a/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c +++ b/src/compiler/glsl/gl_nir_lower_blend_equation_advanced.c @@ -580,8 +580,8 @@ gl_nir_lower_blend_equation_advanced(nir_shader *sh, bool coherent) /* Remove any dead writes before assigning location to __blend_fb_fetch * otherwise they will be unable to be removed. */ - NIR_PASS_V(sh, nir_split_var_copies); - NIR_PASS_V(sh, nir_opt_dead_write_vars); + NIR_PASS(_, sh, nir_split_var_copies); + NIR_PASS(_, sh, nir_opt_dead_write_vars); nir_foreach_variable_with_modes(var, sh, nir_var_shader_out) { if (strcmp(var->name, "__blend_fb_fetch") == 0) { diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 887f5f35c96..ed3fa9a91ed 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -179,10 +179,10 @@ glsl_to_nir(const struct gl_constants *consts, * 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(shader, nir_lower_variable_initializers, nir_var_all); - NIR_PASS_V(shader, nir_lower_returns); - NIR_PASS_V(shader, nir_inline_functions); - NIR_PASS_V(shader, nir_opt_deref); + NIR_PASS(_, shader, nir_lower_variable_initializers, nir_var_all); + NIR_PASS(_, shader, nir_lower_returns); + NIR_PASS(_, shader, nir_inline_functions); + NIR_PASS(_, shader, nir_opt_deref); nir_validate_shader(shader, "after function inlining and return lowering"); @@ -2615,24 +2615,24 @@ glsl_float64_funcs_to_nir(struct gl_context *ctx, nir_validate_shader(nir, "float64_funcs_to_nir"); - 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_V(nir, nir_opt_deref); + NIR_PASS(_, nir, nir_lower_variable_initializers, nir_var_function_temp); + NIR_PASS(_, nir, nir_lower_returns); + NIR_PASS(_, nir, nir_inline_functions); + NIR_PASS(_, nir, nir_opt_deref); /* Do some optimizations to clean up the shader now. By optimizing the * functions in the library, we avoid having to re-do that work every * time we inline a copy of a function. Reducing basic blocks also helps * with compile times. */ - NIR_PASS_V(nir, nir_lower_vars_to_ssa); - NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL); - 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_opt_gcm, true); - NIR_PASS_V(nir, nir_opt_peephole_select, 1, false, false); - NIR_PASS_V(nir, nir_opt_dce); + NIR_PASS(_, nir, nir_lower_vars_to_ssa); + NIR_PASS(_, nir, nir_remove_dead_variables, nir_var_function_temp, NULL); + NIR_PASS(_, nir, nir_copy_prop); + NIR_PASS(_, nir, nir_opt_dce); + NIR_PASS(_, nir, nir_opt_cse); + NIR_PASS(_, nir, nir_opt_gcm, true); + NIR_PASS(_, nir, nir_opt_peephole_select, 1, false, false); + NIR_PASS(_, nir, nir_opt_dce); return nir; } diff --git a/src/compiler/glsl/tests/test_gl_lower_mediump.cpp b/src/compiler/glsl/tests/test_gl_lower_mediump.cpp index 1310913d677..312afce4d47 100644 --- a/src/compiler/glsl/tests/test_gl_lower_mediump.cpp +++ b/src/compiler/glsl/tests/test_gl_lower_mediump.cpp @@ -204,18 +204,18 @@ namespace standalone_destroy_shader_program(whole_program); /* nir_lower_mediump_vars happens after copy deref lowering. */ - NIR_PASS_V(nir, nir_split_var_copies); - NIR_PASS_V(nir, nir_lower_var_copies); + NIR_PASS(_, nir, nir_split_var_copies); + NIR_PASS(_, nir, nir_lower_var_copies); /* Make the vars and i/o mediump like we'd expect, so people debugging aren't confused. */ - NIR_PASS_V(nir, nir_lower_mediump_vars, nir_var_uniform | nir_var_function_temp | nir_var_shader_temp); - NIR_PASS_V(nir, nir_lower_mediump_io, nir_var_shader_out, ~0, false); + NIR_PASS(_, nir, nir_lower_mediump_vars, nir_var_uniform | nir_var_function_temp | nir_var_shader_temp); + NIR_PASS(_, nir, nir_lower_mediump_io, nir_var_shader_out, ~0, false); /* Clean up f2fmp(f2f32(x)) noise. */ - NIR_PASS_V(nir, nir_opt_algebraic); - NIR_PASS_V(nir, nir_opt_algebraic_late); - NIR_PASS_V(nir, nir_copy_prop); - NIR_PASS_V(nir, nir_opt_dce); + NIR_PASS(_, nir, nir_opt_algebraic); + NIR_PASS(_, nir, nir_opt_algebraic_late); + NIR_PASS(_, nir, nir_copy_prop); + NIR_PASS(_, nir, nir_opt_dce); /* Store the source for printing from later assertions. */ this->source = source;