[clang] [HLSL] Implement the dst HLSL Function (PR #133828)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 7 10:41:45 PDT 2025
================
@@ -174,6 +174,31 @@ const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,
__detail::HLSL_FIXED_VECTOR<float, N> Y) {
return __detail::distance_vec_impl(X, Y);
}
+//===----------------------------------------------------------------------===//
+// dst builtins
+//===----------------------------------------------------------------------===//
+
+/// \fn fvector dst( fvector, fvector)
+/// \brief Returns the length of a vector
+/// \param Src0 [in] The first vector contain {_, d*d, d*d, _}
+/// \param Src1 [in] The second vector contain {_, 1/d, _, 1/d}
+///
+/// Return the computed distance vector contain {1, d, d*d, 1/d}
----------------
metkarpoonam wrote:
The combination of squared distance (src0) and reciprocal distance (src1) enables the dst function to efficiently compute a distance vector.
dest = (1, d*d, d*d, 1) * (1, 1/d, 1, 1/d);
dest = (1, d, d*d, 1/d)
https://stackoverflow.com/questions/8525803/what-is-the-hlsl-dst-instruction-for
https://github.com/llvm/llvm-project/pull/133828
More information about the cfe-commits
mailing list