Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- 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 69c42b69..7906356f 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,