vkd3d-shader/hlsl: Pass hlsl_constant_value and hlsl_type pointers to fold_cast().

This commit is contained in:
Zebediah Figura
2022-11-11 18:43:57 -06:00
committed by Alexandre Julliard
parent 24d4ab7fb3
commit eb04829e66
Notes: Alexandre Julliard 2023-05-23 23:13:26 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/205

View File

@@ -62,7 +62,8 @@ static bool fold_abs(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct
return true; 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; unsigned int k;
uint32_t u; uint32_t u;
@@ -70,11 +71,11 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct
double d; double d;
float f; float f;
if (dst->node.data_type->dimx != src->node.data_type->dimx if (dst_type->dimx != src->node.data_type->dimx
|| dst->node.data_type->dimy != src->node.data_type->dimy) || dst_type->dimy != src->node.data_type->dimy)
{ {
FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), 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; return false;
} }
@@ -122,23 +123,23 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct
vkd3d_unreachable(); vkd3d_unreachable();
} }
switch (dst->node.data_type->base_type) switch (dst_type->base_type)
{ {
case HLSL_TYPE_FLOAT: case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF: case HLSL_TYPE_HALF:
dst->value.u[k].f = f; dst->u[k].f = f;
break; break;
case HLSL_TYPE_DOUBLE: case HLSL_TYPE_DOUBLE:
dst->value.u[k].d = d; dst->u[k].d = d;
break; break;
case HLSL_TYPE_INT: case HLSL_TYPE_INT:
dst->value.u[k].i = i; dst->u[k].i = i;
break; break;
case HLSL_TYPE_UINT: case HLSL_TYPE_UINT:
dst->value.u[k].u = u; dst->u[k].u = u;
break; break;
case HLSL_TYPE_BOOL: case HLSL_TYPE_BOOL:
@@ -578,7 +579,7 @@ bool hlsl_fold_constant_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
break; break;
case HLSL_OP1_CAST: case HLSL_OP1_CAST:
success = fold_cast(ctx, res, arg1); success = fold_cast(ctx, &res->value, instr->data_type, arg1);
break; break;
case HLSL_OP1_NEG: case HLSL_OP1_NEG: