vkd3d-shader/hlsl: Make pre/post decrement generate a signed one.

If a float expression is pre/post decremented and an unsigned one is
used to execute it, the unsigned one is first negated (becoming 2^32-1)
and then casted to float (becoming 2^32), which leads to an incorrect
result.

Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Giovanni Mascellani
2021-12-01 17:15:00 +01:00
committed by Alexandre Julliard
parent c64627313f
commit 0e45838370
4 changed files with 15 additions and 2 deletions

View File

@@ -1255,7 +1255,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem
hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST,
"Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
if (!(one = hlsl_new_uint_constant(ctx, 1, loc)))
if (!(one = hlsl_new_int_constant(ctx, 1, loc)))
return false;
list_add_tail(instrs, &one->node.entry);