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
This commit is contained in:
Adam Jackson 2026-05-07 14:46:42 -04:00
parent b1e709384b
commit badd52c7d5

View file

@ -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],
&current->FullInstruction.Dst[0]) &&
(current->FullInstruction.Dst[0].Register.WriteMask &
i915_tex_mask(next)) == i915_tex_mask(next) &&
is_unswizzled(&current->FullInstruction.Src[0], i915_tex_mask(next)) &&
unused_from(ctx, &current->FullInstruction.Dst[0], index)) {
memcpy(&next->FullInstruction.Src[0], &current->FullInstruction.Src[0],