d3dcompiler: Allow hlsl_ir_constant to contain only numeric types.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d5a4364f44
commit
d5486b6bb5
|
@ -866,17 +866,12 @@ struct hlsl_ir_constant
|
|||
struct hlsl_ir_node node;
|
||||
union
|
||||
{
|
||||
union
|
||||
{
|
||||
unsigned u[16];
|
||||
int i[16];
|
||||
float f[16];
|
||||
double d[16];
|
||||
BOOL b[16];
|
||||
} value;
|
||||
struct hlsl_ir_constant *array_elements;
|
||||
struct list *struct_elements;
|
||||
} v;
|
||||
unsigned u[16];
|
||||
int i[16];
|
||||
float f[16];
|
||||
double d[16];
|
||||
BOOL b[16];
|
||||
} value;
|
||||
};
|
||||
|
||||
struct hlsl_scope
|
||||
|
|
|
@ -590,7 +590,7 @@ static struct hlsl_ir_constant *new_uint_constant(unsigned int n, const struct s
|
|||
if (!(c = d3dcompiler_alloc(sizeof(*c))))
|
||||
return NULL;
|
||||
init_node(&c->node, HLSL_IR_CONSTANT, hlsl_ctx.builtin_types.scalar[HLSL_TYPE_UINT], loc);
|
||||
c->v.value.u[0] = n;
|
||||
c->value.u[0] = n;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -1231,15 +1231,15 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
|
|||
switch (constant->node.data_type->base_type)
|
||||
{
|
||||
case HLSL_TYPE_UINT:
|
||||
return constant->v.value.u[0];
|
||||
return constant->value.u[0];
|
||||
case HLSL_TYPE_INT:
|
||||
return constant->v.value.i[0];
|
||||
return constant->value.i[0];
|
||||
case HLSL_TYPE_FLOAT:
|
||||
return constant->v.value.f[0];
|
||||
return constant->value.f[0];
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
return constant->v.value.d[0];
|
||||
return constant->value.d[0];
|
||||
case HLSL_TYPE_BOOL:
|
||||
return constant->v.value.b[0];
|
||||
return constant->value.b[0];
|
||||
default:
|
||||
WARN("Invalid type %s.\n", debug_base_type(constant->node.data_type));
|
||||
return 0;
|
||||
|
@ -2252,7 +2252,7 @@ primary_expr: C_FLOAT
|
|||
}
|
||||
init_node(&c->node, HLSL_IR_CONSTANT,
|
||||
hlsl_ctx.builtin_types.scalar[HLSL_TYPE_FLOAT], get_location(&@1));
|
||||
c->v.value.f[0] = $1;
|
||||
c->value.f[0] = $1;
|
||||
if (!($$ = make_list(&c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
|
@ -2266,7 +2266,7 @@ primary_expr: C_FLOAT
|
|||
}
|
||||
init_node(&c->node, HLSL_IR_CONSTANT,
|
||||
hlsl_ctx.builtin_types.scalar[HLSL_TYPE_INT], get_location(&@1));
|
||||
c->v.value.i[0] = $1;
|
||||
c->value.i[0] = $1;
|
||||
if (!($$ = make_list(&c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
|
@ -2280,7 +2280,7 @@ primary_expr: C_FLOAT
|
|||
}
|
||||
init_node(&c->node, HLSL_IR_CONSTANT,
|
||||
hlsl_ctx.builtin_types.scalar[HLSL_TYPE_BOOL], get_location(&@1));
|
||||
c->v.value.b[0] = $1;
|
||||
c->value.b[0] = $1;
|
||||
if (!($$ = make_list(&c->node)))
|
||||
YYABORT;
|
||||
}
|
||||
|
|
|
@ -1831,19 +1831,19 @@ static void debug_dump_ir_constant(const struct hlsl_ir_constant *constant)
|
|||
switch (type->base_type)
|
||||
{
|
||||
case HLSL_TYPE_FLOAT:
|
||||
wine_dbg_printf("%g ", (double)constant->v.value.f[y * type->dimx + x]);
|
||||
wine_dbg_printf("%g ", (double)constant->value.f[y * type->dimx + x]);
|
||||
break;
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
wine_dbg_printf("%g ", constant->v.value.d[y * type->dimx + x]);
|
||||
wine_dbg_printf("%g ", constant->value.d[y * type->dimx + x]);
|
||||
break;
|
||||
case HLSL_TYPE_INT:
|
||||
wine_dbg_printf("%d ", constant->v.value.i[y * type->dimx + x]);
|
||||
wine_dbg_printf("%d ", constant->value.i[y * type->dimx + x]);
|
||||
break;
|
||||
case HLSL_TYPE_UINT:
|
||||
wine_dbg_printf("%u ", constant->v.value.u[y * type->dimx + x]);
|
||||
wine_dbg_printf("%u ", constant->value.u[y * type->dimx + x]);
|
||||
break;
|
||||
case HLSL_TYPE_BOOL:
|
||||
wine_dbg_printf("%s ", constant->v.value.b[y * type->dimx + x] == FALSE ? "false" : "true");
|
||||
wine_dbg_printf("%s ", constant->value.b[y * type->dimx + x] == FALSE ? "false" : "true");
|
||||
break;
|
||||
default:
|
||||
wine_dbg_printf("Constants of type %s not supported\n", debug_base_type(type));
|
||||
|
@ -2123,24 +2123,6 @@ void free_instr_list(struct list *list)
|
|||
|
||||
static void free_ir_constant(struct hlsl_ir_constant *constant)
|
||||
{
|
||||
struct hlsl_type *type = constant->node.data_type;
|
||||
unsigned int i;
|
||||
struct hlsl_ir_constant *field, *next_field;
|
||||
|
||||
switch (type->type)
|
||||
{
|
||||
case HLSL_CLASS_ARRAY:
|
||||
for (i = 0; i < type->e.array.elements_count; ++i)
|
||||
free_ir_constant(&constant->v.array_elements[i]);
|
||||
d3dcompiler_free(constant->v.array_elements);
|
||||
break;
|
||||
case HLSL_CLASS_STRUCT:
|
||||
LIST_FOR_EACH_ENTRY_SAFE(field, next_field, constant->v.struct_elements, struct hlsl_ir_constant, node.entry)
|
||||
free_ir_constant(field);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
d3dcompiler_free(constant);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue