[SER] Compilation fails when select(...) is used with HitObjects
Description
Compilation fails when select(...) is used with HitObjects
Steps to Reproduce
dx::HitObject obja = dx::HitObject::MakeNop();
dx::HitObject objb = dx::HitObject::MakeNop();
dx::HitObject objc = select(true, obja, objb);
-T lib_6_9 See https://godbolt.org/z/6bEh887zq
Actual Behavior
DXC error message
<source>:6:24: error: no matching function for call to 'select'
dx::HitObject objc = select(true, obja, objb);
^~~~~~
<source>:6:24: note: candidate function not viable: no known conversion from 'dx::HitObject' to 'dx::HitObject' for 2nd argument
dx::HitObject objc = select(true, obja, objb);
^ ~~~~
<source>:6:24: note: candidate function not viable: no known conversion from 'dx::HitObject' to 'float' for 2nd argument
dx::HitObject objc = select(true, obja, objb);
^ ~~~~
Compiler returned: 5
Environment
- DXC version: dxcompiler.dll: 1.9 - 1.8.2505.32 (https://github.com/microsoft/DirectXShaderCompiler/commit/b106a961d09221b3c5bdb37be45b679257da08b8); dxil.dll: 1.9(1.8.2505.32)
@simoll - can you look into this as well please?
I think we need to resolve whether we truly want the select() intrinsic to support arbitrary types for the degenerate scalar case. https://github.com/microsoft/DirectXShaderCompiler/pull/7766#pullrequestreview-3273852134
@tex3d This makes this discussion out of scope for SER. Please re-assign to triage whether you want selects for arbitrary scalar types or not.
We've had a number of discussions internally about this and we've to not move forward with this bug/fix.
This basically boils down to the fact that extended select support for arbitrary types has always been hacked on at a per type basis which is not a pattern we want to continue extending here. In the future we may consider a generic solution but that is out of scope for SER.
The specific functionality can be achieved using a ternary instead. https://godbolt.org/z/c7Y13z5zK
Thanks for the report and for helping to improve DXC!