Module: vkd3d Branch: master Commit: ad0ab664d25251d88e97879bfd9c1c152a56ca82 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/ad0ab664d25251d88e97879bfd9c1c...
Author: Zebediah Figura zfigura@codeweavers.com Date: Fri Nov 11 18:53:33 2022 -0600
vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_mod().
---
libs/vkd3d-shader/hlsl_constant_ops.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index a60ced01..88583231 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -362,44 +362,43 @@ static bool fold_div(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons return true; }
-static bool fold_mod(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, - struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) +static bool fold_mod(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, + const struct vkd3d_shader_location *loc) { - enum hlsl_base_type type = dst->node.data_type->base_type; + enum hlsl_base_type type = dst_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) + for (k = 0; k < dst_type->dimx; ++k) { switch (type) { case HLSL_TYPE_INT: if (src2->value.u[k].i == 0) { - hlsl_error(ctx, &dst->node.loc, VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO, - "Division by zero."); + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO, "Division by zero."); return false; } if (src1->value.u[k].i == INT_MIN && src2->value.u[k].i == -1) - dst->value.u[k].i = 0; + dst->u[k].i = 0; else - dst->value.u[k].i = src1->value.u[k].i % src2->value.u[k].i; + dst->u[k].i = src1->value.u[k].i % src2->value.u[k].i; break;
case HLSL_TYPE_UINT: if (src2->value.u[k].u == 0) { - hlsl_error(ctx, &dst->node.loc, VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO, - "Division by zero."); + hlsl_error(ctx, loc, VKD3D_SHADER_ERROR_HLSL_DIVISION_BY_ZERO, "Division by zero."); return false; } - dst->value.u[k].u = src1->value.u[k].u % src2->value.u[k].u; + dst->u[k].u = src1->value.u[k].u % src2->value.u[k].u; break;
default: - FIXME("Fold modulus for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type)); + FIXME("Fold modulus for type %s.\n", debug_hlsl_type(ctx, dst_type)); return false; } } @@ -605,7 +604,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP2_MOD: - success = fold_mod(ctx, res, arg1, arg2); + success = fold_mod(ctx, &res->value, instr->data_type, arg1, arg2, &instr->loc); break;
case HLSL_OP2_MAX: