From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 73322e81..d952a60d 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -1084,6 +1084,34 @@ static bool fold_ternary(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, return true; }
+static bool fold_rshift(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type, + const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2) +{ + unsigned int k; + + assert(dst_type->base_type == src1->node.data_type->base_type); + assert(src2->node.data_type->base_type == HLSL_TYPE_INT); + + for (k = 0; k < dst_type->dimx; ++k) + { + switch (src1->node.data_type->base_type) + { + case HLSL_TYPE_INT: + dst->u[k].i = src1->value.u[k].i >> src2->value.u[k].i; + break; + + case HLSL_TYPE_UINT: + dst->u[k].u = src1->value.u[k].u >> src2->value.u[k].i; + break; + + default: + vkd3d_unreachable(); + } + } + + 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, *arg3 = NULL; @@ -1221,6 +1249,10 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, success = fold_nequal(ctx, &res, instr->data_type, arg1, arg2); break;
+ case HLSL_OP2_RSHIFT: + success = fold_rshift(ctx, &res, instr->data_type, arg1, arg2); + break; + case HLSL_OP3_DP2ADD: success = fold_dp2add(ctx, &res, instr->data_type, arg1, arg2, arg3); break;