[clang] [HLSL] Implement the `lit` intrinsic (PR #134171)
Deric C. via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 7 13:39:44 PDT 2025
================
@@ -280,6 +280,22 @@ constexpr bool4 isinf(double4 V) { return isinf((float4)V); }
_DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp)
_DXC_COMPAT_TERNARY_INTEGER_OVERLOADS(lerp)
+//===----------------------------------------------------------------------===//
+// lit builtins overloads
+//===----------------------------------------------------------------------===//
+
+template <typename T>
+constexpr __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&
+ (__detail::is_same<double, T>::value ||
----------------
Icohedron wrote:
It actually is ambiguous and there isn't special-case handling for overload resolution for HLSL under Clang. I was confused because earlier I thought it was said that defining lit without using templates eliminated the ambiguous call error. I can see that it actually does not eliminate the ambiguous call error: see https://hlsl.godbolt.org/z/KxMYe877x
```c++
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
const inline half4 lit(half A, half B, half M) { return lit_impl(A, B, M); }
const inline float4 lit(float A, float B, float M) { return lit_impl(A, B, M); }
export float4 test(bool A, bool B, bool C) {
return lit(A,B,C);
}
```
Clang HLSL fails to compile this program and reports an ambiguous call to lit:
```
<source>:19:12: error: call to 'lit' is ambiguous
19 | return lit(A,B,C);
|
```
https://github.com/llvm/llvm-project/pull/134171
More information about the cfe-commits
mailing list