From: Zebediah Figura zfigura@codeweavers.com
--- 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 e30b3dc5f..5552db11b 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 50f402018..f4fffb292 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
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 13 +++++++++++-- tests/hlsl/ternary.shader_test | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 5552db11b..9ee679147 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4089,13 +4089,14 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *cond, struct hlsl_ir_node *first, struct hlsl_ir_node *second) { struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = {0}; + struct hlsl_type *cond_type = cond->data_type; struct hlsl_type *common_type;
- if (cond->data_type->class > HLSL_CLASS_LAST_NUMERIC) + if (cond_type->class > HLSL_CLASS_LAST_NUMERIC) { struct vkd3d_string_buffer *string;
- if ((string = hlsl_type_to_string(ctx, cond->data_type))) + if ((string = hlsl_type_to_string(ctx, cond_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); @@ -4107,6 +4108,14 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block, if (!(common_type = get_common_numeric_type(ctx, first, second, &first->loc))) return false;
+ if (cond_type->dimx == 1 && cond_type->dimy == 1) + { + cond_type = hlsl_get_numeric_type(ctx, common_type->class, + HLSL_TYPE_BOOL, common_type->dimx, common_type->dimy); + if (!(cond = add_implicit_conversion(ctx, block, cond, cond_type, &cond->loc))) + return false; + } + if (!(first = add_implicit_conversion(ctx, block, first, common_type, &first->loc))) return false;
diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index f4fffb292..3b62513db 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -114,7 +114,7 @@ float4 main() : sv_target
[test] draw quad -todo probe all rgba (5.0, 6.0, 7.0, 1.0) +probe all rgba (5.0, 6.0, 7.0, 1.0)
% More restrictions are placed on the type of the first (condition) operand, @@ -265,7 +265,7 @@ draw quad probe all rgba (1.0, 2.0, 3.0, 4.0)
-[pixel shader todo] +[pixel shader]
// "scalar" can mean any 1-component numeric type. static float1x1 cond = {0}; @@ -278,7 +278,7 @@ float4 main() : sv_target }
[test] -todo draw quad +draw quad probe all rgba (5.0, 6.0, 7.0, 8.0)
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 5 +++++ tests/hlsl/ternary.shader_test | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 9ee679147..12c955f2f 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4115,6 +4115,11 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block, if (!(cond = add_implicit_conversion(ctx, block, cond, cond_type, &cond->loc))) return false; } + else if (common_type->dimx == 1 && common_type->dimy == 1) + { + common_type = hlsl_get_numeric_type(ctx, cond_type->class, + common_type->base_type, cond_type->dimx, cond_type->dimy); + }
if (!(first = add_implicit_conversion(ctx, block, first, common_type, &first->loc))) return false; diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 3b62513db..5f38d8969 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -282,7 +282,7 @@ draw quad probe all rgba (5.0, 6.0, 7.0, 8.0)
-[pixel shader todo] +[pixel shader]
uniform float4 cond; uniform float4 a, b; @@ -296,11 +296,11 @@ float4 main() : sv_target uniform 0 float4 1.0 0.0 1.0 0.0 uniform 4 float4 1.0 2.0 3.0 4.0 uniform 8 float4 5.0 6.0 7.0 8.0 -todo draw quad +draw quad probe all rgba (1.0, 5.0, 1.0, 5.0)
-[pixel shader todo] +[pixel shader]
// "scalar" can mean any 1-component numeric type. static float4 cond = {1, 0, 0, 1}; @@ -313,7 +313,7 @@ float4 main() : sv_target }
[test] -todo draw quad +draw quad probe all rgba (2.0, 3.0, 3.0, 2.0)
From: Zebediah Figura zfigura@codeweavers.com
--- libs/vkd3d-shader/hlsl.y | 16 ++++++++++++++++ tests/hlsl/ternary.shader_test | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 12c955f2f..c308916e0 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -4120,6 +4120,22 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block, common_type = hlsl_get_numeric_type(ctx, cond_type->class, common_type->base_type, cond_type->dimx, cond_type->dimy); } + else if (cond_type->dimx != common_type->dimx || cond_type->dimy != common_type->dimy) + { + /* This condition looks wrong but is correct. + * floatN is compatible with float1xN, but not with floatNx1. */ + + struct vkd3d_string_buffer *cond_string, *value_string; + + cond_string = hlsl_type_to_string(ctx, cond_type); + value_string = hlsl_type_to_string(ctx, common_type); + if (cond_string && value_string) + hlsl_error(ctx, &first->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_TYPE, + "Ternary condition type '%s' is not compatible with value type '%s'.", + cond_string->buffer, value_string->buffer); + hlsl_release_string_buffer(ctx, cond_string); + hlsl_release_string_buffer(ctx, value_string); + }
if (!(first = add_implicit_conversion(ctx, block, first, common_type, &first->loc))) return false; diff --git a/tests/hlsl/ternary.shader_test b/tests/hlsl/ternary.shader_test index 5f38d8969..902d2e110 100644 --- a/tests/hlsl/ternary.shader_test +++ b/tests/hlsl/ternary.shader_test @@ -124,7 +124,7 @@ probe all rgba (5.0, 6.0, 7.0, 1.0) % * the result operands are scalar; % * one is a typeN and the other is a type1xN
-[pixel shader fail todo] +[pixel shader fail]
uniform float4 cond; uniform float2x2 a, b; @@ -135,7 +135,7 @@ float4 main() : sv_target }
-[pixel shader fail todo] +[pixel shader fail]
uniform float2x2 cond; uniform float4 a, b; @@ -162,7 +162,7 @@ draw quad probe all rgba (1.0, 6.0, 7.0, 4.0)
-[pixel shader fail todo] +[pixel shader fail]
uniform float3 cond; uniform float4 a, b; @@ -174,7 +174,7 @@ float4 main() : sv_target }
-[pixel shader fail todo] +[pixel shader fail]
uniform float4 cond; uniform float4x1 a, b;
This merge request was approved by Giovanni Mascellani.
This merge request was approved by Henri Verbeet.