From 974528cbe3233c1a20fe3bf3aa04c66324b9f51e Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Mon, 5 Jun 2023 12:32:27 -0500 Subject: [PATCH] vkd3d-shader/hlsl: Only read used coordinates in encode_texel_offset_as_aoffimmi(). The V and W offsets may be uninitialized, which may spuriously trigger "out of range" errors. --- libs/vkd3d-shader/tpf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index b252270c..d066b13e 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -3657,8 +3657,12 @@ static bool encode_texel_offset_as_aoffimmi(struct sm4_instruction *instr, modif.type = VKD3D_SM4_MODIFIER_AOFFIMMI; modif.u.aoffimmi.u = offset->value.u[0].i; - modif.u.aoffimmi.v = offset->value.u[1].i; - modif.u.aoffimmi.w = offset->value.u[2].i; + modif.u.aoffimmi.v = 0; + modif.u.aoffimmi.w = 0; + if (offset->node.data_type->dimx > 1) + modif.u.aoffimmi.v = offset->value.u[1].i; + if (offset->node.data_type->dimx > 2) + modif.u.aoffimmi.w = offset->value.u[2].i; if (modif.u.aoffimmi.u < -8 || modif.u.aoffimmi.u > 7 || modif.u.aoffimmi.v < -8 || modif.u.aoffimmi.v > 7 || modif.u.aoffimmi.w < -8 || modif.u.aoffimmi.w > 7)