Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl_constant_ops.c:
return true;
}
+static bool fold_ternary(struct hlsl_ctx *ctx, struct hlsl_constant_value *dst, const struct hlsl_type *dst_type,
const struct hlsl_ir_constant *src1, const struct hlsl_ir_constant *src2, const struct hlsl_ir_constant *src3)
+{
- unsigned int k;
- 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].u = src1->value.u[k].u ? src2->value.u[k].f : src3->value.u[k].f;
I guess this should be something like `dst->u[k].u = (src1->value.u[k].f != 0.0f) ? src2->value.u[k].u : src3->value.u[k].u`.
In particular, the first operand should take the `float` value and compare it to `0.0f`, so that `-0.0f` is also considered equal to zero. The other two operands should take the unsigned part, so that there is no implicit cast when assigning to the destination's unsigned part.
Same for the double below.