From 3738c697967a5787ecf289aa796437992f02515a Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 4 Nov 2024 18:08:25 +0100 Subject: [PATCH] nir/opt_frag_coord_to_pixel_coord: optimize trunc/floor Foz-DB Navi21: Totals from 207 (0.26% of 79206) affected shaders: MaxWaves: 5924 -> 5980 (+0.95%) Instrs: 83164 -> 83144 (-0.02%); split: -0.06%, +0.04% CodeSize: 457296 -> 459092 (+0.39%); split: -0.00%, +0.39% VGPRs: 5336 -> 5160 (-3.30%) Latency: 1308811 -> 1307754 (-0.08%); split: -0.16%, +0.08% InvThroughput: 232768 -> 222979 (-4.21%); split: -4.21%, +0.00% VClause: 1359 -> 1370 (+0.81%); split: -0.07%, +0.88% SClause: 3300 -> 3293 (-0.21%); split: -0.24%, +0.03% Copies: 4992 -> 4985 (-0.14%); split: -0.56%, +0.42% PreVGPRs: 3757 -> 3619 (-3.67%) VALU: 58366 -> 58338 (-0.05%); split: -0.08%, +0.03% Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c b/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c index b785e1bb894..a1ab25d029b 100644 --- a/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c +++ b/src/compiler/nir/nir_opt_frag_coord_to_pixel_coord.c @@ -50,6 +50,8 @@ opt_frag_pos(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) case nir_op_f2u16: case nir_op_f2u32: case nir_op_f2u64: + case nir_op_ftrunc: + case nir_op_ffloor: continue; default: return false; @@ -70,7 +72,8 @@ opt_frag_pos(nir_builder *b, nir_intrinsic_instr *intr, UNUSED void *data) nir_alu_instr *use_instr = nir_instr_as_alu(nir_src_parent_instr(use)); /* load_frag_coord is always positive, so we should never sign extend here. */ - nir_alu_type dst_type = nir_type_uint | use_instr->def.bit_size; + bool needs_float = use_instr->op == nir_op_ffloor || use_instr->op == nir_op_ftrunc; + nir_alu_type dst_type = (needs_float ? nir_type_float : nir_type_uint) | use_instr->def.bit_size; use_instr->op = nir_type_conversion_op(nir_type_uint16, dst_type, nir_rounding_mode_undef); }