[clang] [HLSL] Implement the HLSL distance intrinsic (PR #122357)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 9 14:24:00 PST 2025
================
@@ -871,6 +871,34 @@ float3 degrees(float3);
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
float4 degrees(float4);
+//===----------------------------------------------------------------------===//
+// distance builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn K distance(T X, T Y)
+/// \brief Returns a distance scalar between two vectors of \a X and \a Y.
----------------
farzonl wrote:
I see what you are saying. The comment was copied from the official documentation and technically the scalar version is just `abs(X-Y)`. In past intrinsics I've just used this first line: https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/direct3dhlsl/dx-graphics-hlsl-distance.md?plain=1#L20
I could instead use this line for return value as it makes no mention of vectors: https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/direct3dhlsl/dx-graphics-hlsl-distance.md?plain=1#L46
https://github.com/llvm/llvm-project/pull/122357
More information about the cfe-commits
mailing list