[PATCH vkd3d 4/6] vkd3d-shader/hlsl: Fold constant integral bitwise xor.
Giovanni Mascellani
gmascellani at codeweavers.com
Mon Jun 27 10:22:41 CDT 2022
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
---
libs/vkd3d-shader/hlsl_constant_ops.c | 30 +++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c
index 01f394b8..bea9864e 100644
--- a/libs/vkd3d-shader/hlsl_constant_ops.c
+++ b/libs/vkd3d-shader/hlsl_constant_ops.c
@@ -427,6 +427,32 @@ static bool fold_min(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
return true;
}
+static bool fold_bit_xor(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
+ struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2)
+{
+ enum hlsl_base_type type = dst->node.data_type->base_type;
+ unsigned int k;
+
+ assert(type == src1->node.data_type->base_type);
+ assert(type == src2->node.data_type->base_type);
+
+ for (k = 0; k < dst->node.data_type->dimx; ++k)
+ {
+ switch (type)
+ {
+ case HLSL_TYPE_INT:
+ case HLSL_TYPE_UINT:
+ dst->value[k].u = src1->value[k].u ^ src2->value[k].u;
+ break;
+
+ default:
+ FIXME("Fold bit xor for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type));
+ return false;
+ }
+ }
+ return true;
+}
+
bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
{
struct hlsl_ir_constant *arg1, *arg2 = NULL, *res;
@@ -496,6 +522,10 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
success = fold_min(ctx, res, arg1, arg2);
break;
+ case HLSL_OP2_BIT_XOR:
+ success = fold_bit_xor(ctx, res, arg1, arg2);
+ break;
+
default:
FIXME("Fold \"%s\" expression.\n", debug_hlsl_expr_op(expr->op));
success = false;
--
2.36.1
More information about the wine-devel
mailing list