mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/hlsl: Cast to bool before applying LOGIC_NOT.
Before this commit, it is possible for one of the tests of cf-cond-types.shader_test to pass a non-bool to LOGIC_NOT, which should not be allowed.
This commit is contained in:
parent
ee5fc7e968
commit
a838f97e3f
Notes:
Alexandre Julliard
2024-03-27 23:07:31 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Francisco Casas (@fcasas) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/724
@ -438,8 +438,9 @@ static uint32_t add_modifiers(struct hlsl_ctx *ctx, uint32_t modifiers, uint32_t
|
||||
|
||||
static bool append_conditional_break(struct hlsl_ctx *ctx, struct hlsl_block *cond_block)
|
||||
{
|
||||
struct hlsl_ir_node *condition, *not, *iff, *jump;
|
||||
struct hlsl_ir_node *condition, *cast, *not, *iff, *jump;
|
||||
struct hlsl_block then_block;
|
||||
struct hlsl_type *bool_type;
|
||||
|
||||
/* E.g. "for (i = 0; ; ++i)". */
|
||||
if (list_empty(&cond_block->instrs))
|
||||
@ -449,7 +450,12 @@ static bool append_conditional_break(struct hlsl_ctx *ctx, struct hlsl_block *co
|
||||
|
||||
check_condition_type(ctx, condition);
|
||||
|
||||
if (!(not = hlsl_new_unary_expr(ctx, HLSL_OP1_LOGIC_NOT, condition, &condition->loc)))
|
||||
bool_type = hlsl_get_scalar_type(ctx, HLSL_TYPE_BOOL);
|
||||
if (!(cast = hlsl_new_cast(ctx, condition, bool_type, &condition->loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(cond_block, cast);
|
||||
|
||||
if (!(not = hlsl_new_unary_expr(ctx, HLSL_OP1_LOGIC_NOT, cast, &condition->loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(cond_block, not);
|
||||
|
||||
|
@ -2919,6 +2919,9 @@ static bool lower_logic_not(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, st
|
||||
arg = expr->operands[0].node;
|
||||
float_type = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, arg->data_type->dimx);
|
||||
|
||||
/* If this is happens, it means we failed to cast the argument to boolean somewhere. */
|
||||
assert(arg->data_type->base_type == HLSL_TYPE_BOOL);
|
||||
|
||||
if (!(arg_cast = hlsl_new_cast(ctx, arg, float_type, &arg->loc)))
|
||||
return false;
|
||||
hlsl_block_add_instr(block, arg_cast);
|
||||
|
Loading…
x
Reference in New Issue
Block a user