From 0851c30d1616931501ab2c5ba0204f0710bd8d0f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 27 Mar 2024 15:58:59 -0400 Subject: [PATCH] nir/texcoord_replace: fix scalarized io handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if a texcoord load only loads some components, only those components should be replaced cc: mesa-stable Acked-by: Marek Olšák Part-of: --- src/compiler/nir/nir_lower_texcoord_replace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_lower_texcoord_replace.c b/src/compiler/nir/nir_lower_texcoord_replace.c index 17991f3df41..6695ccf8022 100644 --- a/src/compiler/nir/nir_lower_texcoord_replace.c +++ b/src/compiler/nir/nir_lower_texcoord_replace.c @@ -107,6 +107,7 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, unsigned base = var->data.location - VARYING_SLOT_TEX0; b.cursor = nir_after_instr(instr); + uint32_t component_mask = BITFIELD_MASK(glsl_get_vector_elements(var->type)) << var->data.location_frac; nir_deref_instr *deref = nir_src_as_deref(intrin->src[0]); nir_def *index = get_io_index(&b, deref); nir_def *mask = @@ -114,7 +115,7 @@ nir_lower_texcoord_replace_impl(nir_function_impl *impl, nir_iadd_imm(&b, index, base)); nir_def *cond = nir_test_mask(&b, mask, coord_replace); - nir_def *result = nir_bcsel(&b, cond, new_coord, + nir_def *result = nir_bcsel(&b, cond, nir_channels(&b, new_coord, component_mask), &intrin->def); nir_def_rewrite_uses_after(&intrin->def,