mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-shader/hlsl: Ensure that TERNARY condition is always bool.
Also, properly casting it to float in lower_ternary() for SM1 avoids creating ABS and NEG on bool types.
This commit is contained in:
committed by
Alexandre Julliard
parent
9c0d04c862
commit
19fd43214b
Notes:
Alexandre Julliard
2024-04-09 15:44:37 -05:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Zebediah Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/744
@@ -1177,30 +1177,11 @@ static bool fold_ternary(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst,
|
||||
|
||||
assert(dst_type->base_type == src2->node.data_type->base_type);
|
||||
assert(dst_type->base_type == src3->node.data_type->base_type);
|
||||
assert(src1->node.data_type->base_type == HLSL_TYPE_BOOL);
|
||||
|
||||
for (k = 0; k < dst_type->dimx; ++k)
|
||||
{
|
||||
switch (src1->node.data_type->base_type)
|
||||
{
|
||||
case HLSL_TYPE_FLOAT:
|
||||
case HLSL_TYPE_HALF:
|
||||
dst->u[k] = src1->value.u[k].f != 0.0f ? src2->value.u[k] : src3->value.u[k];
|
||||
break;
|
||||
dst->u[k] = src1->value.u[k].u ? src2->value.u[k] : src3->value.u[k];
|
||||
|
||||
case HLSL_TYPE_DOUBLE:
|
||||
dst->u[k] = src1->value.u[k].d != 0.0 ? src2->value.u[k] : src3->value.u[k];
|
||||
break;
|
||||
|
||||
case HLSL_TYPE_INT:
|
||||
case HLSL_TYPE_UINT:
|
||||
case HLSL_TYPE_BOOL:
|
||||
dst->u[k] = src1->value.u[k].u ? src2->value.u[k] : src3->value.u[k];
|
||||
break;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user