Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl.y:
if (!(second = add_implicit_conversion(ctx, $1, second, common_type, &@5))) YYABORT;
if (!hlsl_add_conditional(ctx, $1, cond, first, second))
args[0] = cond;
args[1] = first;
args[2] = second;
if (!add_expr(ctx, $1, HLSL_OP3_TERNARY, args, common_type, &@1))
This changes the behavior of the conditional expression (in two different ways, unless I am mistaken: because the check is now done per component and because negative zero is considered false). So it would be good to have a test that shows that the change is correct. As usual, the test should be introduced with `todo` first, then fixed in a later commit.
Also, while we are here, it would be nice to check what requirements native imposes on the shape of the condition argument and enforce them as well. Currently we don't check anything on the condition, we just perform the usual implicit conversion to the common type for the "if-true" and "if-false" arguments. I'd guess that native is a bit more picky. We should also check what happens if the conditional operator is fed an object type. Internally I guess that we want the three arguments to have the same shape (and assert that in `lower_ternary()` and in whatever SM1 will have), also because we want `add_expr()` to perform matrix splitting appropriately.
The second part (about checking types) doesn't need to be in this MR, but it would be nice if you could address it at some point.