From bc048f5c513ac9f5860572995a2972eb23ea4ae5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 7 Dec 2022 14:49:11 -0700 Subject: [PATCH] gallivm: fix incorrect type for undefined texcoords Texcoords may be 1-5 components in length. We initialize the unused components with an LLVMGetUndef(). But we were using an int vec type rather than a float vec type. This eventually led to a failed assertion in lp_build_clamp() where 'a' was a vec of int[8] but 'min' and 'max' were float[8] in a trace of the game Tom Clancy's Splinter Cell: Blacklist. The game seems to have a bug where a texture sampler mistakenly has shadow comparison turned on, but the shader's tex sample instructions are sampling a 2D R8G8B8A8_UNORM texture. The instruction has a 2-component texcoord so when we do the sampler comparison operation we're using the undefined 5th coordinate component. Signed-off-by: Brian Paul Part-of: --- src/gallium/auxiliary/gallivm/lp_bld_nir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_nir.c b/src/gallium/auxiliary/gallivm/lp_bld_nir.c index 468f203..f3d879b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_nir.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_nir.c @@ -2344,7 +2344,7 @@ visit_tex(struct lp_build_nir_context *bld_base, nir_tex_instr *instr) LLVMValueRef texture_unit_offset = NULL; LLVMValueRef texel[NIR_MAX_VEC_COMPONENTS]; unsigned lod_src = 0; - LLVMValueRef coord_undef = LLVMGetUndef(bld_base->base.int_vec_type); + LLVMValueRef coord_undef = LLVMGetUndef(bld_base->base.vec_type); unsigned coord_vals = is_aos(bld_base) ? 1 : instr->coord_components; memset(¶ms, 0, sizeof(params)); enum lp_sampler_lod_property lod_property = LP_SAMPLER_LOD_SCALAR; -- 2.7.4