mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Store constant values as an array of unions.
This allows us to more easily manipulate individual elements in a type-agnostic way. For example, it allows easier implementation of constant swizzle folding. Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
e2b57f6d2b
commit
b4e301b2d8
@@ -828,20 +828,21 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
|
||||
case HLSL_IR_CONSTANT:
|
||||
{
|
||||
struct hlsl_ir_constant *constant = hlsl_ir_constant(node);
|
||||
const union hlsl_constant_value *value = &constant->value[0];
|
||||
|
||||
switch (constant->node.data_type->base_type)
|
||||
{
|
||||
case HLSL_TYPE_UINT:
|
||||
return constant->value.u[0];
|
||||
return value->u;
|
||||
case HLSL_TYPE_INT:
|
||||
return constant->value.i[0];
|
||||
return value->i;
|
||||
case HLSL_TYPE_FLOAT:
|
||||
case HLSL_TYPE_HALF:
|
||||
return constant->value.f[0];
|
||||
return value->f;
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
return constant->value.d[0];
|
||||
return value->d;
|
||||
case HLSL_TYPE_BOOL:
|
||||
return constant->value.b[0];
|
||||
return value->b;
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
@@ -2770,7 +2771,7 @@ primary_expr:
|
||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||
YYABORT;
|
||||
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_FLOAT], @1);
|
||||
c->value.f[0] = $1;
|
||||
c->value[0].f = $1;
|
||||
if (!($$ = make_list(ctx, &c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
@@ -2781,7 +2782,7 @@ primary_expr:
|
||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||
YYABORT;
|
||||
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_INT], @1);
|
||||
c->value.i[0] = $1;
|
||||
c->value[0].i = $1;
|
||||
if (!($$ = make_list(ctx, &c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
@@ -2792,7 +2793,7 @@ primary_expr:
|
||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||
YYABORT;
|
||||
init_node(&c->node, HLSL_IR_CONSTANT, ctx->builtin_types.scalar[HLSL_TYPE_BOOL], @1);
|
||||
c->value.b[0] = $1;
|
||||
c->value[0].b = $1;
|
||||
if (!($$ = make_list(ctx, &c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user