@@ -871,6 +871,34 @@ float3 degrees(float3);
871871_HLSL_BUILTIN_ALIAS (__builtin_hlsl_elementwise_degrees)
872872float4 degrees(float4);
873873
874+ // ===----------------------------------------------------------------------===//
875+ // distance builtins
876+ // ===----------------------------------------------------------------------===//
877+
878+ // / \fn K distance(T X, T Y)
879+ // / \brief Returns a distance scalar between two vectors of \a X and \a Y.
880+ // / \param X The X input value.
881+ // / \param Y The Y input value.
882+ _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
883+ const inline half distance(half X, half Y) {
884+ return __detail::distance_impl (X, Y);
885+ }
886+
887+ const inline float distance (float X, float Y) {
888+ return __detail::distance_impl (X, Y);
889+ }
890+
891+ template <int N>
892+ _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
893+ const inline half distance(vector<half, N> X, vector<half, N> Y) {
894+ return __detail::distance_vec_impl (X, Y);
895+ }
896+
897+ template <int N>
898+ const inline float distance (vector<float , N> X, vector<float , N> Y) {
899+ return __detail::distance_vec_impl (X, Y);
900+ }
901+
874902// ===----------------------------------------------------------------------===//
875903// dot product builtins
876904// ===----------------------------------------------------------------------===//
@@ -1296,28 +1324,19 @@ float4 lerp(float4, float4, float4);
12961324// / \param x [in] The vector of floats, or a scalar float.
12971325// /
12981326// / Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
1299-
13001327_HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
1301- _HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1302- half length(half);
1303- _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
1304- _HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1305- half length(half2);
1306- _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
1307- _HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1308- half length(half3);
1328+ const inline half length(half X) { return __detail::length_impl (X); }
1329+ const inline float length (float X) { return __detail::length_impl (X); }
1330+
1331+ template <int N>
13091332_HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
1310- _HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1311- half length(half4);
1333+ const inline half length(vector<half, N> X) {
1334+ return __detail::length_vec_impl (X);
1335+ }
13121336
1313- _HLSL_BUILTIN_ALIAS (__builtin_hlsl_length)
1314- float length(float );
1315- _HLSL_BUILTIN_ALIAS (__builtin_hlsl_length)
1316- float length(float2);
1317- _HLSL_BUILTIN_ALIAS (__builtin_hlsl_length)
1318- float length(float3);
1319- _HLSL_BUILTIN_ALIAS (__builtin_hlsl_length)
1320- float length(float4);
1337+ template <int N> const inline float length (vector<float , N> X) {
1338+ return __detail::length_vec_impl (X);
1339+ }
13211340
13221341// ===----------------------------------------------------------------------===//
13231342// log builtins
0 commit comments