mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Fix a corner case in ternary type conversion.
If the condition and argument types are compatible, i.e. there is no broadcast, the resulting shape should be the shape of the arguments, not the shape of the condition.
This commit is contained in:
parent
b2cddecfc5
commit
650bf4d83f
Notes:
Henri Verbeet
2024-09-23 15:57:02 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1099
@ -5346,11 +5346,6 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
}
|
||||
else
|
||||
{
|
||||
cond_type = hlsl_get_numeric_type(ctx, cond_type->class, HLSL_TYPE_BOOL,
|
||||
cond_type->dimx, cond_type->dimy);
|
||||
if (!(cond = add_implicit_conversion(ctx, block, cond, cond_type, &cond->loc)))
|
||||
return false;
|
||||
|
||||
if (common_type->dimx == 1 && common_type->dimy == 1)
|
||||
{
|
||||
common_type = hlsl_get_numeric_type(ctx, cond_type->class,
|
||||
@ -5372,6 +5367,11 @@ static bool add_ternary(struct hlsl_ctx *ctx, struct hlsl_block *block,
|
||||
hlsl_release_string_buffer(ctx, cond_string);
|
||||
hlsl_release_string_buffer(ctx, value_string);
|
||||
}
|
||||
|
||||
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)))
|
||||
|
@ -203,7 +203,7 @@ draw quad
|
||||
probe (0, 0) rgba (1.0, 6.0, 7.0, 4.0)
|
||||
|
||||
|
||||
[pixel shader todo]
|
||||
[pixel shader]
|
||||
|
||||
static float1x4 cond = {1, 0, 0, 1};
|
||||
static float4 a = {1, 2, 3, 4};
|
||||
@ -215,7 +215,7 @@ float4 main() : sv_target
|
||||
}
|
||||
|
||||
[test]
|
||||
todo draw quad
|
||||
draw quad
|
||||
probe (0, 0) rgba (1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
|
||||
@ -246,6 +246,34 @@ draw quad
|
||||
probe (0, 0) rgba (3.0, 3.0, 3.0, 3.0)
|
||||
|
||||
|
||||
[pixel shader]
|
||||
|
||||
static float1x1 cond = {1};
|
||||
static float1 a = {2};
|
||||
static float1 b = {3};
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return (cond ? a : b)[0];
|
||||
}
|
||||
|
||||
[test]
|
||||
draw quad
|
||||
probe (0, 0) rgba (2.0, 2.0, 2.0, 2.0)
|
||||
|
||||
|
||||
[pixel shader fail]
|
||||
|
||||
static float1x1 cond = {1};
|
||||
static float1 a = {2};
|
||||
static float1 b = {3};
|
||||
|
||||
float4 main() : sv_target
|
||||
{
|
||||
return (cond ? a : b)[0][0];
|
||||
}
|
||||
|
||||
|
||||
[pixel shader]
|
||||
|
||||
uniform float cond;
|
||||
|
Loading…
x
Reference in New Issue
Block a user