Giovanni Mascellani : vkd3d-shader/hlsl: Simplify expr_common_base_type.
Alexandre Julliard
julliard at winehq.org
Fri Aug 27 14:57:56 CDT 2021
Module: vkd3d
Branch: master
Commit: b5251b33502c74621f607ca283b848f3c1a8c115
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=b5251b33502c74621f607ca283b848f3c1a8c115
Author: Giovanni Mascellani <gmascellani at codeweavers.com>
Date: Fri Aug 27 12:05:13 2021 +0200
vkd3d-shader/hlsl: Simplify expr_common_base_type.
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura 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.y | 39 +++++++++++----------------------------
1 file changed, 11 insertions(+), 28 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y
index 69c42b6..7906356 100644
--- a/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d-shader/hlsl.y
@@ -905,37 +905,20 @@ static bool expr_compatible_data_types(struct hlsl_type *t1, struct hlsl_type *t
static enum hlsl_base_type expr_common_base_type(enum hlsl_base_type t1, enum hlsl_base_type t2)
{
- static const enum hlsl_base_type types[] =
- {
- HLSL_TYPE_BOOL,
- HLSL_TYPE_INT,
- HLSL_TYPE_UINT,
- HLSL_TYPE_HALF,
- HLSL_TYPE_FLOAT,
- HLSL_TYPE_DOUBLE,
- };
- int t1_idx = -1, t2_idx = -1, i;
-
- if (t1 == t2)
- return t1 == HLSL_TYPE_BOOL ? HLSL_TYPE_INT : t1;
-
- for (i = 0; i < ARRAY_SIZE(types); ++i)
- {
- /* Always convert away from HLSL_TYPE_HALF */
- if (t1 == types[i])
- t1_idx = t1 == HLSL_TYPE_HALF ? i + 1 : i;
- if (t2 == types[i])
- t2_idx = t2 == HLSL_TYPE_HALF ? i + 1 : i;
-
- if (t1_idx != -1 && t2_idx != -1)
- break;
- }
- if (t1_idx == -1 || t2_idx == -1)
- {
+ if (t1 > HLSL_TYPE_LAST_SCALAR || t2 > HLSL_TYPE_LAST_SCALAR) {
FIXME("Unexpected base type.\n");
return HLSL_TYPE_FLOAT;
}
- return t1_idx >= t2_idx ? t1 : t2;
+ if (t1 == t2)
+ return t1 == HLSL_TYPE_BOOL ? HLSL_TYPE_INT : t1;
+ if (t1 == HLSL_TYPE_DOUBLE || t2 == HLSL_TYPE_DOUBLE)
+ return HLSL_TYPE_DOUBLE;
+ if (t1 == HLSL_TYPE_FLOAT || t2 == HLSL_TYPE_FLOAT
+ || t1 == HLSL_TYPE_HALF || t2 == HLSL_TYPE_HALF)
+ return HLSL_TYPE_FLOAT;
+ if (t1 == HLSL_TYPE_UINT || t2 == HLSL_TYPE_UINT)
+ return HLSL_TYPE_UINT;
+ return HLSL_TYPE_INT;
}
static struct hlsl_type *expr_common_type(struct hlsl_ctx *ctx, struct hlsl_type *t1, struct hlsl_type *t2,
More information about the wine-cvs
mailing list