From: Christian Gmeiner Date: Sat, 8 Jul 2023 15:37:35 +0000 (+0200) Subject: nir/lower_tex: optimize offset lowering for has_texture_scaling X-Git-Tag: upstream/23.3.3~5743 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f831883af6389097624d0f9d8b067eb59b2c4780;p=platform%2Fupstream%2Fmesa.git nir/lower_tex: optimize offset lowering for has_texture_scaling Generates much better code and even helps to beat a blob driver. Signed-off-by: Christian Gmeiner Reviewed-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/compiler/nir/nir_lower_tex.c b/src/compiler/nir/nir_lower_tex.c index 3e9d43e..8453adb 100644 --- a/src/compiler/nir/nir_lower_tex.c +++ b/src/compiler/nir/nir_lower_tex.c @@ -176,8 +176,15 @@ lower_offset(nir_builder *b, nir_tex_instr *tex) if (tex->sampler_dim == GLSL_SAMPLER_DIM_RECT) { offset_coord = nir_fadd(b, coord, nir_i2f32(b, offset)); } else { - nir_ssa_def *txs = nir_i2f32(b, nir_get_texture_size(b, tex)); - nir_ssa_def *scale = nir_frcp(b, txs); + nir_ssa_def *scale = NULL; + + if (b->shader->options->has_texture_scaling) { + nir_ssa_def *idx = nir_imm_int(b, tex->texture_index); + scale = nir_load_texture_scale(b, 32, idx); + } else { + nir_ssa_def *txs = nir_i2f32(b, nir_get_texture_size(b, tex)); + scale = nir_frcp(b, txs); + } offset_coord = nir_fadd(b, coord, nir_fmul(b,