From 8b2642db8468922a16c09b2be08c1ce702db591f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 20 Aug 2025 09:09:23 -0400 Subject: [PATCH] st/program: stop calling st_finalize_nir() unnecessarily for variants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit st_finalize_nir() only affects: * sampling * uniforms * shader images if a nir pass doesn't affect one of these three things or does not yield progresss, then there is no need to call this Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_program.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index ffb085309f6..e6d2cdb4fb2 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -769,11 +769,9 @@ st_create_common_variant(struct st_context *st, if (key->clamp_color) { NIR_PASS(_, state.ir.nir, nir_lower_clamp_color_outputs); - finalize = true; } if (key->passthrough_edgeflags) { - NIR_PASS(_, state.ir.nir, nir_lower_passthrough_edgeflags); - finalize = true; + NIR_PASS(finalize, state.ir.nir, nir_lower_passthrough_edgeflags); } if (key->export_point_size) { @@ -797,7 +795,7 @@ st_create_common_variant(struct st_context *st, tex_opts.saturate_s = key->gl_clamp[0]; tex_opts.saturate_t = key->gl_clamp[1]; tex_opts.saturate_r = key->gl_clamp[2]; - NIR_PASS(_, state.ir.nir, nir_lower_tex, &tex_opts); + NIR_PASS(finalize, state.ir.nir, nir_lower_tex, &tex_opts); } if (finalize || !st->allow_st_finalize_nir_twice || key->is_draw_shader) { @@ -1039,12 +1037,10 @@ st_create_fp_variant(struct st_context *st, if (key->clamp_color) { NIR_PASS(_, state.ir.nir, nir_lower_clamp_color_outputs); - finalize = true; } if (key->lower_flatshade) { NIR_PASS(_, state.ir.nir, nir_lower_flatshade); - finalize = true; } if (key->lower_alpha_func != COMPARE_FUNC_ALWAYS) { @@ -1057,7 +1053,6 @@ st_create_fp_variant(struct st_context *st, if (key->lower_two_sided_color) { bool face_sysval = st->ctx->Const.GLSLFrontFacingIsSysVal; NIR_PASS(_, state.ir.nir, nir_lower_two_sided_color, face_sysval); - finalize = true; } if (key->persample_shading) { @@ -1070,8 +1065,6 @@ st_create_fp_variant(struct st_context *st, */ shader->info.fs.uses_sample_shading = true; nir_lower_sample_shading(shader); - - finalize = true; } if (st->emulate_gl_clamp && @@ -1080,8 +1073,7 @@ st_create_fp_variant(struct st_context *st, tex_opts.saturate_s = key->gl_clamp[0]; tex_opts.saturate_t = key->gl_clamp[1]; tex_opts.saturate_r = key->gl_clamp[2]; - NIR_PASS(_, state.ir.nir, nir_lower_tex, &tex_opts); - finalize = true; + NIR_PASS(finalize, state.ir.nir, nir_lower_tex, &tex_opts); } assert(!(key->bitmap && key->drawpixels)); @@ -1094,8 +1086,7 @@ st_create_fp_variant(struct st_context *st, options.sampler = variant->bitmap_sampler; options.swizzle_xxxx = st->bitmap.tex_format == PIPE_FORMAT_R8_UNORM; - NIR_PASS(_, state.ir.nir, nir_lower_bitmap, &options); - finalize = true; + NIR_PASS(finalize, state.ir.nir, nir_lower_bitmap, &options); } /* glDrawPixels (color only) */