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.
This commit is contained in:
Zebediah Figura 2024-01-22 14:51:02 -06:00 committed by Alexandre Julliard
parent 183172eff4
commit a8b0c03912
Notes: Alexandre Julliard 2024-01-23 23:04:27 +01:00
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/577

View File

@ -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);
}