brw: constant fold before texture lowering

This ensures we don't need dynamic stuff. Noticed when debugging weird
regressions around the mcs lowering. ARL:

total instructions in shared programs: 19857061 -> 19854964 (-0.01%)
instructions in affected programs: 91768 -> 89671 (-2.29%)
helped: 154
HURT: 0
helped stats (abs) min: 9.0 max: 33.0 x̄: 13.62 x̃: 13
helped stats (rel) min: 0.51% max: 40.91% x̄: 4.66% x̃: 3.36%
95% mean confidence interval for instructions value: -14.04 -13.19
95% mean confidence interval for instructions %-change: -5.49% -3.84%
Instructions are helped.

total cycles in shared programs: 884538769 -> 884485530 (<.01%)
cycles in affected programs: 10508994 -> 10455755 (-0.51%)
helped: 116
HURT: 38
helped stats (abs) min: 4.0 max: 15238.0 x̄: 666.22 x̃: 148
helped stats (rel) min: 0.01% max: 34.53% x̄: 2.58% x̃: 1.07%
HURT stats (abs)   min: 4.0 max: 4027.0 x̄: 632.68 x̃: 302
HURT stats (rel)   min: 0.01% max: 32.75% x̄: 3.46% x̃: 0.59%
95% mean confidence interval for cycles value: -631.32 -60.09
95% mean confidence interval for cycles %-change: -2.06% -0.12%
Cycles are helped.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39023>
This commit is contained in:
Alyssa Rosenzweig 2025-11-17 15:51:33 -05:00 committed by Marge Bot
parent 0df735a619
commit 61dc9201a1

View file

@ -2550,14 +2550,12 @@ brw_postprocess_nir_opts(nir_shader *nir, const struct brw_compiler *compiler,
if (OPT(nir_lower_tex, &tex_options)) if (OPT(nir_lower_tex, &tex_options))
OPT(nir_lower_tex, &tex_options); OPT(nir_lower_tex, &tex_options);
/* MCS lowering can introduce u2u16 conversions. We need to lower those to OPT(brw_nir_lower_mcs_fetch, devinfo);
* make constant offsets detectable by brw_nir_texture_backend_opcode().
*/
if (OPT(brw_nir_lower_mcs_fetch, devinfo))
OPT(nir_opt_constant_folding);
OPT(intel_nir_lower_sparse_intrinsics); OPT(intel_nir_lower_sparse_intrinsics);
/* Any constants leftover should be folded so we have constant textures */
OPT(nir_opt_constant_folding);
/* Needs to happen before the backend opcode selection */ /* Needs to happen before the backend opcode selection */
OPT(brw_nir_pre_lower_texture); OPT(brw_nir_pre_lower_texture);