Giovanni Mascellani : vkd3d-shader/hlsl: Check types when folding constants.
Alexandre Julliard
julliard at winehq.org
Tue Apr 5 15:38:53 CDT 2022
Module: vkd3d
Branch: master
Commit: 4739cf1d330706d9c91aefcc14af086f1a1871f7
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=4739cf1d330706d9c91aefcc14af086f1a1871f7
Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date: Tue Apr 5 12:33:07 2022 +0200
vkd3d-shader/hlsl: Check types when folding constants.
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Francisco Casas <fcasas at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura 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_constant_ops.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c
index 109fc2ee..e4e60310 100644
--- a/libs/vkd3d-shader/hlsl_constant_ops.c
+++ b/libs/vkd3d-shader/hlsl_constant_ops.c
@@ -236,10 +236,17 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void
return false;
expr = hlsl_ir_expr(instr);
+ if (instr->data_type->type > HLSL_CLASS_VECTOR)
+ return false;
+
for (i = 0; i < ARRAY_SIZE(expr->operands); ++i)
{
- if (expr->operands[i].node && expr->operands[i].node->type != HLSL_IR_CONSTANT)
- return false;
+ if (expr->operands[i].node)
+ {
+ if (expr->operands[i].node->type != HLSL_IR_CONSTANT)
+ return false;
+ assert(expr->operands[i].node->data_type->type <= HLSL_CLASS_VECTOR);
+ }
}
arg1 = hlsl_ir_constant(expr->operands[0].node);
if (expr->operands[1].node)
More information about the wine-cvs
mailing list