vkd3d-shader/hlsl: Allow non-numeric types in the ternary operator.

This commit is contained in:
Zebediah Figura 2023-11-09 19:43:31 -06:00 committed by Alexandre Julliard
parent 46bd099341
commit 16962ac6f1
Notes: Alexandre Julliard 2024-01-17 22:43:18 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/463
2 changed files with 29 additions and 7 deletions

View File

@ -4091,6 +4091,9 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0}; struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0};
struct hlsl_type *common_type; struct hlsl_type *common_type;
if (first->data_type->class <= HLSL_CLASS_LAST_NUMERIC
&& second->data_type->class <= HLSL_CLASS_LAST_NUMERIC)
{
if (!(common_type = get_common_numeric_type(ctx, first, second, &first->loc))) if (!(common_type = get_common_numeric_type(ctx, first, second, &first->loc)))
return false; return false;
@ -4099,6 +4102,25 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
if (!(second = add_implicit_conversion(ctx, block, second, common_type, &second->loc))) if (!(second = add_implicit_conversion(ctx, block, second, common_type, &second->loc)))
return false; return false;
}
else
{
struct vkd3d_string_buffer *first_string, *second_string;
if (!hlsl_types_are_equal(first->data_type, second->data_type))
{
first_string = hlsl_type_to_string(ctx, first->data_type);
second_string = hlsl_type_to_string(ctx, second->data_type);
if (first_string && second_string)
hlsl_error(ctx, &first->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE,
"Ternary argument types '%s' and '%s' do not match.",
first_string->buffer, second_string->buffer);
hlsl_release_string_buffer(ctx, first_string);
hlsl_release_string_buffer(ctx, second_string);
}
common_type = first->data_type;
}
args[0] = cond; args[0] = cond;
args[1] = first; args[1] = first;

View File

@ -329,7 +329,7 @@ float4 main() : sv_target
} }
[pixel shader fail] [pixel shader fail todo]
Texture2D t; Texture2D t;
float4 f; float4 f;