Zebediah Figura : vkd3d-shader: Move compatible_data_types() to hlsl.y.
Alexandre Julliard
julliard at winehq.org
Tue Feb 2 15:51:09 CST 2021
Module: vkd3d
Branch: master
Commit: ab2e95a78c4f65a33811874edbba423f7128c00e
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=ab2e95a78c4f65a33811874edbba423f7128c00e
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Sat Jan 30 13:51:36 2021 -0600
vkd3d-shader: Move compatible_data_types() to hlsl.y.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d-shader/hlsl.c | 59 ------------------------------------------------
libs/vkd3d-shader/hlsl.h | 1 -
libs/vkd3d-shader/hlsl.y | 54 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+), 60 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c
index 9b76fb4..ebd74e6 100644
--- a/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d-shader/hlsl.c
@@ -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)
{
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h
index 492b6d6..88ed6de 100644
--- a/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d-shader/hlsl.h
@@ -626,7 +626,6 @@ BOOL is_row_major(const struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL find_function(const char *name) DECLSPEC_HIDDEN;
unsigned int components_count_type(struct hlsl_type *type) DECLSPEC_HIDDEN;
BOOL compare_hlsl_types(const struct hlsl_type *t1, const struct hlsl_type *t2) DECLSPEC_HIDDEN;
-BOOL compatible_data_types(struct hlsl_type *s1, struct hlsl_type *s2) DECLSPEC_HIDDEN;
void push_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
BOOL pop_scope(struct hlsl_parse_ctx *ctx) DECLSPEC_HIDDEN;
void init_functions_tree(struct rb_tree *funcs) DECLSPEC_HIDDEN;
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 339a30d..ed83207 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -82,6 +82,60 @@ static BOOL convertible_data_type(struct hlsl_type *type)
return type->type != HLSL_CLASS_OBJECT;
}
+static 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;
+}
+
static BOOL implicit_compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t2)
{
if (!convertible_data_type(t1) || !convertible_data_type(t2))
More information about the wine-cvs
mailing list