Zebediah Figura : vkd3d-shader/hlsl: Fold constant casts from int to uint.
Alexandre Julliard
julliard at winehq.org
Wed Jan 19 15:52:11 CST 2022
Module: vkd3d
Branch: master
Commit: 8ced37058d01e34b98383d5e1890447792648f25
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=8ced37058d01e34b98383d5e1890447792648f25
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Wed Jan 19 12:52:00 2022 +0100
vkd3d-shader/hlsl: Fold constant casts from int to uint.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl_codegen.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index 75716bd..e43e637 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -724,6 +724,31 @@ static bool fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi
{
switch (expr->op)
{
+ case HLSL_OP1_CAST:
+ if (instr->data_type->dimx != arg1->node.data_type->dimx
+ || instr->data_type->dimy != arg1->node.data_type->dimy)
+ {
+ FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, arg1->node.data_type),
+ debug_hlsl_type(ctx, instr->data_type));
+ vkd3d_free(res);
+ return false;
+ }
+
+ switch (arg1->node.data_type->base_type)
+ {
+ case HLSL_TYPE_INT:
+ for (i = 0; i < dimx; ++i)
+ res->value[i].i = arg1->value[i].u;
+ break;
+
+ default:
+ FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, arg1->node.data_type),
+ debug_hlsl_type(ctx, instr->data_type));
+ vkd3d_free(res);
+ return false;
+ }
+ break;
+
case HLSL_OP1_NEG:
for (i = 0; i < instr->data_type->dimx; ++i)
res->value[i].u = -arg1->value[i].u;
More information about the wine-cvs
mailing list