Module: vkd3d Branch: master Commit: a8b0c0391273bbeeec9ca9438fc0d2fa8d2ccd90 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/a8b0c0391273bbeeec9ca9438fc0d2...
Author: Zebediah Figura zfigura@codeweavers.com Date: Mon Jan 22 14:51:02 2024 -0600
vkd3d-shader/hlsl: Always cast to bool in if() statements.
We emit sm4 if_nz for these, but that does a bitwise comparison to zero, which is wrong for floats.
---
libs/vkd3d-shader/hlsl.y | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index c934aaae..8dc353e1 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -6763,6 +6763,15 @@ selection_statement: } }
+ check_condition_type(ctx, condition); + + if (!(condition = add_cast(ctx, $4, condition, hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL), &@4))) + { + destroy_block($6.then_block); + destroy_block($6.else_block); + YYABORT; + } + if (!(instr = hlsl_new_if(ctx, condition, $6.then_block, $6.else_block, &@2))) { destroy_block($6.then_block); @@ -6772,8 +6781,6 @@ selection_statement: destroy_block($6.then_block); destroy_block($6.else_block);
- check_condition_type(ctx, condition); - $$ = $4; hlsl_block_add_instr($$, instr); }