Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index c56a74d4..782c1dcb 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1166,7 +1166,7 @@ static void write_sm4_constant(struct hlsl_ctx *ctx, { const unsigned int dimx = constant->node.data_type->dimx; struct sm4_instruction instr; - unsigned int i; + unsigned int i, j = 0;
memset(&instr, 0, sizeof(instr)); instr.opcode = VKD3D_SM4_OP_MOV; @@ -1176,8 +1176,11 @@ static void write_sm4_constant(struct hlsl_ctx *ctx,
instr.srcs[0].reg.dim = (dimx > 1) ? VKD3D_SM4_DIMENSION_VEC4 : VKD3D_SM4_DIMENSION_SCALAR; instr.srcs[0].reg.type = VKD3D_SM4_RT_IMMCONST; - for (i = 0; i < dimx; ++i) - instr.srcs[0].reg.immconst_uint[i] = constant->value[i].u; + for (i = 0; i < 4; ++i) + { + if (dimx == 1 || instr.dsts[0].writemask & (1u << i)) + instr.srcs[0].reg.immconst_uint[i] = constant->value[j++].u; + } instr.src_count = 1,
write_sm4_instruction(buffer, &instr);