On Mon Apr 1 19:07:17 2024 +0000, Zebediah Figura wrote:
So, integers and bools are represented internally as float in SM1, so
a reinterpret has no real effect (doesn't emit any instruction) besides avoiding the "SM1 non-float expression" fixme in d3dbc.
I think that emitting this fixme is correct for ABS and NEG operations
on bool types, and thus, the reinterpret should be explicit in HLSL IR. lower_nonfloat_exprs() should be taking care of that fixme.
Thinking about it better, I think that the problem is not that we don't have a way to write ABS and NEG operations on bool types in d3dbc.c, but that those operations should not be generated at all in well-formed HLSL IR, because they make sense for integers and floats but not bool.
It should not be a fixme, but an internal compiler error, despite of the shader model.
So to fix it, the conditional is casted to a float before performing the operations, which is good because a ternary with a float condition is still valid (and in the same function, it gets turned into a CMP anyways).
I see now that I could have used a CAST instead of a REINTERPRET, but I still think that the problem should be solved in lower_ternary() were it is introduced.