mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Add support for ternary operator.
This commit is contained in:
parent
725d408974
commit
c190c184ce
Notes:
Alexandre Julliard
2023-04-06 22:23:07 +02:00
Approved-by: Zebediah Figura (@zfigura) 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/139
@ -116,6 +116,7 @@ vkd3d_shader_tests = \
|
||||
tests/hlsl-struct-array.shader_test \
|
||||
tests/hlsl-struct-assignment.shader_test \
|
||||
tests/hlsl-struct-semantics.shader_test \
|
||||
tests/hlsl-ternary.shader_test \
|
||||
tests/hlsl-transpose.shader_test \
|
||||
tests/hlsl-type-names.shader_test \
|
||||
tests/hlsl-vector-indexing.shader_test \
|
||||
|
@ -5743,7 +5743,16 @@ conditional_expr:
|
||||
logicor_expr
|
||||
| logicor_expr '?' expr ':' assignment_expr
|
||||
{
|
||||
hlsl_fixme(ctx, &@$, "Ternary operator.");
|
||||
struct hlsl_ir_node *cond = node_from_list($1), *first = node_from_list($3), *second = node_from_list($5);
|
||||
|
||||
list_move_tail($1, $3);
|
||||
list_move_tail($1, $5);
|
||||
vkd3d_free($3);
|
||||
vkd3d_free($5);
|
||||
|
||||
if (!hlsl_add_conditional(ctx, $1, cond, first, second))
|
||||
YYABORT;
|
||||
$$ = $1;
|
||||
}
|
||||
|
||||
assignment_expr:
|
||||
|
15
tests/hlsl-ternary.shader_test
Normal file
15
tests/hlsl-ternary.shader_test
Normal file
@ -0,0 +1,15 @@
|
||||
[pixel shader]
|
||||
uniform float4 x;
|
||||
|
||||
float4 main() : SV_TARGET
|
||||
{
|
||||
return x.x ? x : x - 1;
|
||||
}
|
||||
|
||||
[test]
|
||||
uniform 0 float4 2.0 3.0 4.0 5.0
|
||||
draw quad
|
||||
probe all rgba (2.0, 3.0, 4.0, 5.0)
|
||||
uniform 0 float4 0.0 10.0 11.0 12.0
|
||||
draw quad
|
||||
probe all rgba (-1.0, 9.0, 10.0, 11.0)
|
Loading…
Reference in New Issue
Block a user