From 0c14420169b8456416253f5ca412ed5a3618dc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 5 Aug 2025 13:26:58 -0400 Subject: [PATCH] glsl: use pipe caps in opt_shader do_algebraic doesn't use any options Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/glsl/glsl_parser_extras.cpp | 20 +++++++++----------- src/compiler/glsl/ir_optimization.h | 8 +++----- src/compiler/glsl/opt_algebraic.cpp | 13 +++---------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp index 23aa6fd760d..80bbea94b21 100644 --- a/src/compiler/glsl/glsl_parser_extras.cpp +++ b/src/compiler/glsl/glsl_parser_extras.cpp @@ -2181,7 +2181,8 @@ do_late_parsing_checks(struct _mesa_glsl_parse_state *state) } static void -opt_shader(const struct gl_constants *consts, +opt_shader(const struct pipe_screen *screen, + const struct gl_constants *consts, const struct gl_extensions *exts, struct gl_shader *shader, linear_ctx *linalloc) @@ -2189,15 +2190,12 @@ opt_shader(const struct gl_constants *consts, assert(shader->CompileStatus != COMPILE_FAILURE && !shader->ir->is_empty()); - const struct gl_shader_compiler_options *options = - &consts->ShaderCompilerOptions[shader->Stage]; - /* Do some optimization at compile time to reduce shader IR size * and reduce later work if the same shader is linked multiple times. * * Run it just once, since NIR will do the real optimization. */ - do_common_optimization(shader->ir, false, options, consts->NativeIntegers); + do_common_optimization(shader->ir, false, shader->Stage, screen); validate_ir_tree(shader->ir); @@ -2403,7 +2401,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, lower_builtins(shader->ir); assign_subroutine_indexes(state); lower_subroutine(shader->ir, state); - opt_shader(&ctx->Const, &ctx->Extensions, shader, state->linalloc); + opt_shader(ctx->screen, &ctx->Const, &ctx->Extensions, shader, + state->linalloc); } if (!force_recompile) { @@ -2483,9 +2482,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, * integers in floating point registers). */ bool -do_common_optimization(ir_exec_list *ir, bool linked, - const struct gl_shader_compiler_options *options, - bool native_integers) +do_common_optimization(ir_exec_list *ir, bool linked, mesa_shader_stage stage, + const struct pipe_screen *screen) { const bool debug = false; bool progress = false; @@ -2512,8 +2510,8 @@ do_common_optimization(ir_exec_list *ir, bool linked, OPT(do_tree_grafting, ir); OPT(do_minmax_prune, ir); OPT(do_rebalance_tree, ir); - OPT(do_algebraic, ir, native_integers, options); - OPT(do_lower_jumps, ir, true, options->EmitNoCont); + OPT(do_algebraic, ir); + OPT(do_lower_jumps, ir, true, !screen->shader_caps[stage].cont_supported); /* If an optimization pass fails to preserve the invariant flag, calling * the pass only once earlier may result in incorrect code generation. Always call diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index 1a91c0ddc4c..0009ae38dd1 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -34,13 +34,11 @@ struct gl_shader; struct gl_linked_shader; struct gl_shader_program; -bool do_common_optimization(ir_exec_list *ir, bool linked, - const struct gl_shader_compiler_options *options, - bool native_integers); +bool do_common_optimization(ir_exec_list *ir, bool linked, mesa_shader_stage stage, + const struct pipe_screen *screen); bool do_rebalance_tree(ir_exec_list *instructions); -bool do_algebraic(ir_exec_list *instructions, bool native_integers, - const struct gl_shader_compiler_options *options); +bool do_algebraic(ir_exec_list *instructions); bool do_dead_code(ir_exec_list *instructions); bool do_dead_code_local(ir_exec_list *instructions); bool do_dead_code_unlinked(ir_exec_list *instructions); diff --git a/src/compiler/glsl/opt_algebraic.cpp b/src/compiler/glsl/opt_algebraic.cpp index cafa694e736..19b993e7d9b 100644 --- a/src/compiler/glsl/opt_algebraic.cpp +++ b/src/compiler/glsl/opt_algebraic.cpp @@ -46,12 +46,9 @@ namespace { class ir_algebraic_visitor : public ir_rvalue_visitor { public: - ir_algebraic_visitor(bool native_integers, - const struct gl_shader_compiler_options *options) - : options(options) + ir_algebraic_visitor() { this->progress = false; - this->native_integers = native_integers; } virtual ~ir_algebraic_visitor() @@ -73,9 +70,6 @@ public: ir_rvalue *swizzle_if_required(ir_expression *expr, ir_rvalue *operand); - const struct gl_shader_compiler_options *options; - - bool native_integers; bool progress; }; @@ -403,10 +397,9 @@ ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue) } bool -do_algebraic(ir_exec_list *instructions, bool native_integers, - const struct gl_shader_compiler_options *options) +do_algebraic(ir_exec_list *instructions) { - ir_algebraic_visitor v(native_integers, options); + ir_algebraic_visitor v; visit_list_elements(&v, instructions);