From 834b919f6af86da4d5ff27002230ec92acea1dff Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Thu, 17 Oct 2024 16:00:44 -0700 Subject: [PATCH] brw: Optimize 16-bit texture fetches later At the point we were calling this, we hadn't necessarily cleaned up derefs via nir_lower_vars_to_ssa, nor movs/vecs via copy propagation, so it wasn't necessarily easy for this pass to see the actual usage of the destination. Moving this later allows us to detect f2f32(txf(...)) and avoid converting it to a 16-bit txf (why convert with ALU instructions when the sampler could do it for us?). Reviewed-by: Lionel Landwerlin Reviewed-by: Sushma Venkatesh Reddy Part-of: --- src/intel/compiler/brw_nir.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 0f55509aa0e..0ef2a61f25a 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -1019,12 +1019,6 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir, OPT(nir_lower_alu_to_scalar, NULL, NULL); - struct nir_opt_16bit_tex_image_options options = { - .rounding_mode = nir_rounding_mode_undef, - .opt_tex_dest_types = nir_type_float | nir_type_int | nir_type_uint, - }; - OPT(nir_opt_16bit_tex_image, &options); - if (nir->info.stage == MESA_SHADER_GEOMETRY) OPT(nir_lower_gs_intrinsics, 0); @@ -1084,6 +1078,12 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir, brw_nir_optimize(nir, devinfo); + struct nir_opt_16bit_tex_image_options options = { + .rounding_mode = nir_rounding_mode_undef, + .opt_tex_dest_types = nir_type_float | nir_type_int | nir_type_uint, + }; + OPT(nir_opt_16bit_tex_image, &options); + OPT(nir_lower_doubles, opts->softfp64, nir->options->lower_doubles_options); if (OPT(nir_lower_int64_float_conversions)) { OPT(nir_opt_algebraic);