From badd52c7d5afbc191f4f51e15f56ae590c630451 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 7 May 2026 14:46:42 -0400 Subject: [PATCH] i915: fix incorrect texcoord optimization in TGSI compiler i915_fpc_optimize_mov_before_tex replaces a MOV+TEX pair with a direct TEX from the input register when the MOV copies from the input with identity swizzle. But it only checked the source swizzle, not the MOV's writemask. When the MOV wrote a subset of the channels the TEX reads (e.g., MOV TEMP.y, IN.y before a 2D TEX that reads XY), the optimization replaced the TEX source with IN, losing the X channel that was set by a different MOV. This caused incorrect texture sampling coordinates in shaders with multi-MOV texcoord construction (blur filters, shadow maps, etc.). Fix: verify the MOV's dest writemask covers all channels the TEX instruction reads before applying the optimization. Assisted-by: Claude --- src/gallium/drivers/i915/i915_fpc_optimize.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/i915/i915_fpc_optimize.c b/src/gallium/drivers/i915/i915_fpc_optimize.c index b4ae362dfef..731f2444fec 100644 --- a/src/gallium/drivers/i915/i915_fpc_optimize.c +++ b/src/gallium/drivers/i915/i915_fpc_optimize.c @@ -405,6 +405,8 @@ i915_fpc_optimize_mov_before_tex(struct i915_optimize_context *ctx, target_is_texture2d(next->FullInstruction.Texture.Texture) && same_src_dst_reg(&next->FullInstruction.Src[0], ¤t->FullInstruction.Dst[0]) && + (current->FullInstruction.Dst[0].Register.WriteMask & + i915_tex_mask(next)) == i915_tex_mask(next) && is_unswizzled(¤t->FullInstruction.Src[0], i915_tex_mask(next)) && unused_from(ctx, ¤t->FullInstruction.Dst[0], index)) { memcpy(&next->FullInstruction.Src[0], ¤t->FullInstruction.Src[0],