From 175bc33da7a722969d17ae377e019c4e40725fc6 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Thu, 29 Jul 2021 11:06:12 +0200 Subject: [PATCH] gallivm: let nir_lower_tex handle projectors There's no need for us to do this lowering ourselves while emitting code, when there's already a helper that can do this for us that we're even using. Let's just set the right flag, and not worry about projectors any more. Reviewed-by: Roland Scheidegger Reviewed-by: Emma Anholt Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 3669e6e..fd62f2f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -1916,7 +1916,7 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst LLVMBuilderRef builder = gallivm->builder; LLVMValueRef coords[5]; LLVMValueRef offsets[3] = { NULL }; - LLVMValueRef explicit_lod = NULL, projector = NULL, ms_index = NULL; + LLVMValueRef explicit_lod = NULL, ms_index = NULL; struct lp_sampler_params params; struct lp_derivatives derivs; unsigned sample_key = 0; @@ -1963,9 +1963,6 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst case nir_tex_src_sampler_deref: sampler_deref_instr = nir_src_as_deref(instr->src[i].src); break; - case nir_tex_src_projector: - projector = lp_build_rcp(&bld_base->base, cast_type(bld_base, get_src(bld_base, instr->src[i].src), nir_type_float, 32)); - break; case nir_tex_src_comparator: sample_key |= LP_SAMPLER_SHADOW; coords[4] = get_src(bld_base, instr->src[i].src); @@ -2066,13 +2063,6 @@ static void visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *inst coords[1] = coord_undef; } - if (projector) { - for (unsigned chan = 0; chan < instr->coord_components; ++chan) - coords[chan] = lp_build_mul(&bld_base->base, coords[chan], projector); - if (sample_key & LP_SAMPLER_SHADOW) - coords[4] = lp_build_mul(&bld_base->base, coords[4], projector); - } - uint32_t samp_base_index = 0, tex_base_index = 0; if (!sampler_deref_instr) { int samp_src_index = nir_tex_instr_src_index(instr, nir_tex_src_sampler_handle); @@ -2337,6 +2327,7 @@ void lp_build_opt_nir(struct nir_shader *nir) static const struct nir_lower_tex_options lower_tex_options = { .lower_tg4_offsets = true, + .lower_txp = ~0u, }; NIR_PASS_V(nir, nir_lower_tex, &lower_tex_options); NIR_PASS_V(nir, nir_lower_frexp); -- 2.7.4