On Mon Apr 1 22:11:28 2024 +0000, Francisco Casas wrote:
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.
Personally I think all these sm1-specific lowering passes are not ideal. I would assert that we should just be translating one instruction into multiple instructions when generating the IR. This is simpler than writing HLSL lowering passes, it avoids the need for some basically backend-specific ops like OP3_CMP, and it reduces the amount of backend-specific logic in the core HLSL compiler, or at least moves it closer to the end.