From 5da76df4cd54d07036441635b6bfb724423429b9 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 21 Feb 2025 17:39:43 +0100 Subject: [PATCH] nir/search_helpers: check tex source type in is_only_used_as_float Foz-DB Navi21: Totals from 164 (0.21% of 79377) affected shaders: Instrs: 197477 -> 197035 (-0.22%); split: -0.23%, +0.01% CodeSize: 1052944 -> 1051140 (-0.17%); split: -0.18%, +0.01% VGPRs: 8104 -> 8080 (-0.30%) Latency: 1115663 -> 1115567 (-0.01%); split: -0.06%, +0.05% InvThroughput: 265822 -> 265158 (-0.25%); split: -0.26%, +0.01% VClause: 3792 -> 3789 (-0.08%); split: -0.11%, +0.03% SClause: 5738 -> 5744 (+0.10%); split: -0.02%, +0.12% Copies: 12223 -> 12200 (-0.19%); split: -0.53%, +0.34% PreVGPRs: 6807 -> 6801 (-0.09%); split: -0.15%, +0.06% VALU: 139206 -> 138785 (-0.30%); split: -0.31%, +0.01% SALU: 27852 -> 27853 (+0.00%) Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_search_helpers.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h index 6ec41ecfb2a..ecbfbf9a6b0 100644 --- a/src/compiler/nir/nir_search_helpers.h +++ b/src/compiler/nir/nir_search_helpers.h @@ -578,6 +578,18 @@ is_only_used_as_float_impl(const nir_alu_instr *instr, unsigned depth) default: break; } + } else if (user_instr->type == nir_instr_type_tex) { + const nir_tex_instr *tex = nir_instr_as_tex(user_instr); + const nir_tex_src *tex_src = container_of(src, nir_tex_src, src); + + /* These have unknown type. */ + if (tex_src->src_type == nir_tex_src_backend1 || + tex_src->src_type == nir_tex_src_backend2) + return false; + + unsigned idx = tex_src - tex->src; + if (nir_tex_instr_src_type(tex, idx) == nir_type_float) + continue; } return false; }