Module: vkd3d Branch: master Commit: 2c8751478ff9c46d9aa6ff82cc9aa4200ae1aa4f URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/2c8751478ff9c46d9aa6ff82cc9aa4...
Author: Zebediah Figura zfigura@codeweavers.com Date: Mon Dec 11 14:06:00 2023 -0600
vkd3d-shader/hlsl: Forbid objects in ternary conditions.
---
libs/vkd3d-shader/hlsl.y | 10 ++++++++++ tests/hlsl/ternary.shader_test | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index e30b3dc5..5552db11 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4091,6 +4091,16 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0}; struct hlsl_type *common_type;
+ if (cond->data_type->class > HLSL_CLASS_LAST_NUMERIC) + { + struct vkd3d_string_buffer *string; + + if ((string = hlsl_type_to_string(ctx, cond->data_type))) + hlsl_error(ctx, &cond->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Ternary condition type '%s' is not numeric.", string->buffer); + hlsl_release_string_buffer(ctx, string); + } + if (first->data_type->class <= HLSL_CLASS_LAST_NUMERIC && second->data_type->class <= HLSL_CLASS_LAST_NUMERIC) { diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 50f40201..f4fffb29 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -353,7 +353,7 @@ float4 main() : sv_target
% Of course objects cannot be used as the condition.
-[pixel shader fail todo] +[pixel shader fail] Texture2D t;
float4 main() : sv_target