mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader: Move compatible_data_types() to hlsl.y.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
d8dd91e840
commit
ab2e95a78c
@@ -312,65 +312,6 @@ struct hlsl_type *clone_hlsl_type(struct hlsl_type *old, unsigned int default_ma
|
||||
return type;
|
||||
}
|
||||
|
||||
static BOOL convertible_data_type(struct hlsl_type *type)
|
||||
{
|
||||
return type->type != HLSL_CLASS_OBJECT;
|
||||
}
|
||||
|
||||
BOOL compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
|
||||
{
|
||||
if (!convertible_data_type(t1) || !convertible_data_type(t2))
|
||||
return FALSE;
|
||||
|
||||
if (t1->type <= HLSL_CLASS_LAST_NUMERIC)
|
||||
{
|
||||
/* Scalar vars can be cast to pretty much everything */
|
||||
if (t1->dimx == 1 && t1->dimy == 1)
|
||||
return TRUE;
|
||||
|
||||
if (t1->type == HLSL_CLASS_VECTOR && t2->type == HLSL_CLASS_VECTOR)
|
||||
return t1->dimx >= t2->dimx;
|
||||
}
|
||||
|
||||
/* The other way around is true too i.e. whatever to scalar */
|
||||
if (t2->type <= HLSL_CLASS_LAST_NUMERIC && t2->dimx == 1 && t2->dimy == 1)
|
||||
return TRUE;
|
||||
|
||||
if (t1->type == HLSL_CLASS_ARRAY)
|
||||
{
|
||||
if (compare_hlsl_types(t1->e.array.type, t2))
|
||||
/* e.g. float4[3] to float4 is allowed */
|
||||
return TRUE;
|
||||
|
||||
if (t2->type == HLSL_CLASS_ARRAY || t2->type == HLSL_CLASS_STRUCT)
|
||||
return components_count_type(t1) >= components_count_type(t2);
|
||||
else
|
||||
return components_count_type(t1) == components_count_type(t2);
|
||||
}
|
||||
|
||||
if (t1->type == HLSL_CLASS_STRUCT)
|
||||
return components_count_type(t1) >= components_count_type(t2);
|
||||
|
||||
if (t2->type == HLSL_CLASS_ARRAY || t2->type == HLSL_CLASS_STRUCT)
|
||||
return components_count_type(t1) == components_count_type(t2);
|
||||
|
||||
if (t1->type == HLSL_CLASS_MATRIX || t2->type == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
if (t1->type == HLSL_CLASS_MATRIX && t2->type == HLSL_CLASS_MATRIX && t1->dimx >= t2->dimx && t1->dimy >= t2->dimy)
|
||||
return TRUE;
|
||||
|
||||
/* Matrix-vector conversion is apparently allowed if they have the same components count */
|
||||
if ((t1->type == HLSL_CLASS_VECTOR || t2->type == HLSL_CLASS_VECTOR)
|
||||
&& components_count_type(t1) == components_count_type(t2))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (components_count_type(t1) >= components_count_type(t2))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
struct hlsl_ir_expr *new_cast(struct hlsl_ir_node *node, struct hlsl_type *type,
|
||||
struct source_location *loc)
|
||||
{
|
||||
|
Reference in New Issue
Block a user