Pass struct hlsl_constant_value to folding functions, in preparation for creating the destination constant instruction from that value.
-- v2: vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_nequal(). vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_mul(). vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_add(). vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_neg(). vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_cast().
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl_constant_ops.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 0eca3939..676126d7 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -62,7 +62,8 @@ static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct return true; }
-static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src) +static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, + const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src) { unsigned int k; uint32_t u; @@ -70,11 +71,11 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct double d; float f;
- if (dst->node.data_type->dimx != src->node.data_type->dimx - || dst->node.data_type->dimy != src->node.data_type->dimy) + if (dst_type->dimx != src->node.data_type->dimx + || dst_type->dimy != src->node.data_type->dimy) { FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), - debug_hlsl_type(ctx, dst->node.data_type)); + debug_hlsl_type(ctx, dst_type)); return false; }
@@ -122,23 +123,23 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct vkd3d_unreachable(); }
- switch (dst->node.data_type->base_type) + switch (dst_type->base_type) { case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: - dst->value.u[k].f = f; + dst->u[k].f = f; break;
case HLSL_TYPE_DOUBLE: - dst->value.u[k].d = d; + dst->u[k].d = d; break;
case HLSL_TYPE_INT: - dst->value.u[k].i = i; + dst->u[k].i = i; break;
case HLSL_TYPE_UINT: - dst->value.u[k].u = u; + dst->u[k].u = u; break;
case HLSL_TYPE_BOOL: @@ -578,7 +579,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP1_CAST: - success = fold_cast(ctx, res, arg1); + success = fold_cast(ctx, &res->value, instr->data_type, arg1); break;
case HLSL_OP1_NEG:
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl_constant_ops.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 676126d7..2a2b4729 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -151,9 +151,10 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, return true; }
-static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src) +static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, + const struct hlsl_type *dst_type, const struct hlsl_ir_constant *src) { - 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 == src->node.data_type->base_type); @@ -164,20 +165,20 @@ static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct { case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: - dst->value.u[k].f = -src->value.u[k].f; + dst->u[k].f = -src->value.u[k].f; break;
case HLSL_TYPE_DOUBLE: - dst->value.u[k].d = -src->value.u[k].d; + dst->u[k].d = -src->value.u[k].d; break;
case HLSL_TYPE_INT: case HLSL_TYPE_UINT: - dst->value.u[k].u = -src->value.u[k].u; + dst->u[k].u = -src->value.u[k].u; break;
default: - FIXME("Fold negation for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type)); + FIXME("Fold negation for type %s.\n", debug_hlsl_type(ctx, dst_type)); return false; } } @@ -583,7 +584,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP1_NEG: - success = fold_neg(ctx, res, arg1); + success = fold_neg(ctx, &res->value, instr->data_type, arg1); break;
case HLSL_OP2_ADD:
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl_constant_ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 2a2b4729..24ebbf8d 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -185,10 +185,10 @@ static bool fold_neg(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, return true; }
-static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct hlsl_ir_constant *src1, - struct hlsl_ir_constant *src2) +static bool fold_add(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) { - 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); @@ -200,22 +200,22 @@ static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct { case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: - dst->value.u[k].f = src1->value.u[k].f + src2->value.u[k].f; + dst->u[k].f = src1->value.u[k].f + src2->value.u[k].f; break;
case HLSL_TYPE_DOUBLE: - dst->value.u[k].d = src1->value.u[k].d + src2->value.u[k].d; + dst->u[k].d = src1->value.u[k].d + src2->value.u[k].d; break;
/* Handling HLSL_TYPE_INT through the unsigned field to avoid * undefined behavior with signed integers in C. */ case HLSL_TYPE_INT: case HLSL_TYPE_UINT: - 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 addition for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type)); + FIXME("Fold addition for type %s.\n", debug_hlsl_type(ctx, dst_type)); return false; } } @@ -588,7 +588,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP2_ADD: - success = fold_add(ctx, res, arg1, arg2); + success = fold_add(ctx, &res->value, instr->data_type, arg1, arg2); break;
case HLSL_OP2_MUL:
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl_constant_ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 24ebbf8d..015b2222 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -222,10 +222,10 @@ static bool fold_add(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons return true; }
-static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, - struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) +static bool fold_mul(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) { - 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); @@ -237,20 +237,20 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, { case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: - dst->value.u[k].f = src1->value.u[k].f * src2->value.u[k].f; + dst->u[k].f = src1->value.u[k].f * src2->value.u[k].f; break;
case HLSL_TYPE_DOUBLE: - dst->value.u[k].d = src1->value.u[k].d * src2->value.u[k].d; + dst->u[k].d = src1->value.u[k].d * src2->value.u[k].d; break;
case HLSL_TYPE_INT: case HLSL_TYPE_UINT: - 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 multiplication for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type)); + FIXME("Fold multiplication for type %s.\n", debug_hlsl_type(ctx, dst_type)); return false; } } @@ -592,7 +592,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP2_MUL: - success = fold_mul(ctx, res, arg1, arg2); + success = fold_mul(ctx, &res->value, instr->data_type, arg1, arg2); break;
case HLSL_OP2_NEQUAL:
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl_constant_ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 015b2222..80af9b8f 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -257,12 +257,12 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, cons return true; }
-static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, - struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) +static bool fold_nequal(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->node.data_type->base_type == HLSL_TYPE_BOOL); + assert(dst_type->base_type == HLSL_TYPE_BOOL); assert(src1->node.data_type->base_type == src2->node.data_type->base_type);
for (k = 0; k < 4; ++k) @@ -271,24 +271,24 @@ static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, { case HLSL_TYPE_FLOAT: case HLSL_TYPE_HALF: - dst->value.u[k].u = src1->value.u[k].f != src2->value.u[k].f; + dst->u[k].u = src1->value.u[k].f != src2->value.u[k].f; break;
case HLSL_TYPE_DOUBLE: - dst->value.u[k].u = src1->value.u[k].d != src2->value.u[k].d; + dst->u[k].u = src1->value.u[k].d != src2->value.u[k].d; break;
case HLSL_TYPE_INT: case HLSL_TYPE_UINT: case HLSL_TYPE_BOOL: - 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: vkd3d_unreachable(); }
- dst->value.u[k].u *= ~0u; + dst->u[k].u *= ~0u; } return true; } @@ -596,7 +596,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, break;
case HLSL_OP2_NEQUAL: - success = fold_nequal(ctx, res, arg1, arg2); + success = fold_nequal(ctx, &res->value, instr->data_type, arg1, arg2); break;
case HLSL_OP2_DIV:
This merge request was approved by Henri Verbeet.