// This file is auto-generated by clang-tblgen from HLSLIntrinsics.td.
// Do not edit this file directly.

/// \fn T abs(T Val)
/// \brief Returns the absolute value of the input value, \a Val.
/// \param Val The input value.
///
/// Unsigned overload — unsigned values are already non-negative, so this
/// function returns its input unchanged.
// abs overloads
#ifdef __HLSL_ENABLE_16_BIT
_HLSL_AVAILABILITY(shadermodel, 6.2)
constexpr uint16_t abs(uint16_t V) { return V; }
_HLSL_AVAILABILITY(shadermodel, 6.2)
constexpr uint16_t2 abs(uint16_t2 V) { return V; }
_HLSL_AVAILABILITY(shadermodel, 6.2)
constexpr uint16_t3 abs(uint16_t3 V) { return V; }
_HLSL_AVAILABILITY(shadermodel, 6.2)
constexpr uint16_t4 abs(uint16_t4 V) { return V; }
#endif

constexpr uint abs(uint V) { return V; }
constexpr uint2 abs(uint2 V) { return V; }
constexpr uint3 abs(uint3 V) { return V; }
constexpr uint4 abs(uint4 V) { return V; }

constexpr uint64_t abs(uint64_t V) { return V; }
constexpr uint64_t2 abs(uint64_t2 V) { return V; }
constexpr uint64_t3 abs(uint64_t3 V) { return V; }
constexpr uint64_t4 abs(uint64_t4 V) { return V; }

/// \fn bool CheckAccessFullyMapped(uint Status)
/// \brief Checks whether the value is fully mapped.
/// \param Status The status value to check.
// CheckAccessFullyMapped overloads
inline bool CheckAccessFullyMapped(uint Status) { return static_cast<bool>(Status); }

/// \fn T countbits(T Val)
/// \brief Return the number of bits (per component) set in the input integer.
/// \param Val The input value.
// countbits overloads
#ifdef __HLSL_ENABLE_16_BIT
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint countbits(int16_t x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint2 countbits(int16_t2 x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint3 countbits(int16_t3 x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint4 countbits(int16_t4 x) { return __builtin_elementwise_popcount(x); }

_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint countbits(uint16_t x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint2 countbits(uint16_t2 x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint3 countbits(uint16_t3 x) { return __builtin_elementwise_popcount(x); }
_HLSL_AVAILABILITY(shadermodel, 6.2)
inline uint4 countbits(uint16_t4 x) { return __builtin_elementwise_popcount(x); }
#endif

inline uint countbits(int x) { return __builtin_elementwise_popcount(x); }
inline uint2 countbits(int2 x) { return __builtin_elementwise_popcount(x); }
inline uint3 countbits(int3 x) { return __builtin_elementwise_popcount(x); }
inline uint4 countbits(int4 x) { return __builtin_elementwise_popcount(x); }

inline uint countbits(uint x) { return __builtin_elementwise_popcount(x); }
inline uint2 countbits(uint2 x) { return __builtin_elementwise_popcount(x); }
inline uint3 countbits(uint3 x) { return __builtin_elementwise_popcount(x); }
inline uint4 countbits(uint4 x) { return __builtin_elementwise_popcount(x); }

inline uint countbits(int64_t x) { return __builtin_elementwise_popcount(x); }
inline uint2 countbits(int64_t2 x) { return __builtin_elementwise_popcount(x); }
inline uint3 countbits(int64_t3 x) { return __builtin_elementwise_popcount(x); }
inline uint4 countbits(int64_t4 x) { return __builtin_elementwise_popcount(x); }

inline uint countbits(uint64_t x) { return __builtin_elementwise_popcount(x); }
inline uint2 countbits(uint64_t2 x) { return __builtin_elementwise_popcount(x); }
inline uint3 countbits(uint64_t3 x) { return __builtin_elementwise_popcount(x); }
inline uint4 countbits(uint64_t4 x) { return __builtin_elementwise_popcount(x); }

/// \fn int4 D3DCOLORtoUBYTE4(float4 x)
/// \brief Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
/// \param x [in] The floating-point vector4 to convert.
///
/// The return value is the UBYTE4 representation of the \a x parameter.
///
/// This function swizzles and scales components of the \a x parameter. Use this
/// function to compensate for the lack of UBYTE4 support in some hardware.
// D3DCOLORtoUBYTE4 overloads
constexpr int4 D3DCOLORtoUBYTE4(float4 V) { return V.zyxw * 255.001953f; }

/// \fn T ddx(T x)
/// \brief Computes the partial derivative of the specified value with regard to
/// the screen-space x-coordinate.
/// \param x [in] The floating-point scalar or vector to process.
// ddx overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half ddx(half input) {
  return __detail::ddx_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 ddx(half2 input) {
  return __detail::ddx_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 ddx(half3 input) {
  return __detail::ddx_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 ddx(half4 input) {
  return __detail::ddx_impl(input);
}

inline float ddx(float input) {
  return __detail::ddx_impl(input);
}
inline float2 ddx(float2 input) {
  return __detail::ddx_impl(input);
}
inline float3 ddx(float3 input) {
  return __detail::ddx_impl(input);
}
inline float4 ddx(float4 input) {
  return __detail::ddx_impl(input);
}

/// \fn T ddy(T x)
/// \brief Computes the partial derivative of the specified value with regard to
/// the screen-space y-coordinate.
/// \param x [in] The floating-point scalar or vector to process.
// ddy overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half ddy(half input) {
  return __detail::ddy_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 ddy(half2 input) {
  return __detail::ddy_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 ddy(half3 input) {
  return __detail::ddy_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 ddy(half4 input) {
  return __detail::ddy_impl(input);
}

inline float ddy(float input) {
  return __detail::ddy_impl(input);
}
inline float2 ddy(float2 input) {
  return __detail::ddy_impl(input);
}
inline float3 ddy(float3 input) {
  return __detail::ddy_impl(input);
}
inline float4 ddy(float4 input) {
  return __detail::ddy_impl(input);
}

/// \fn K distance(T X, T Y)
/// \brief Returns a distance scalar between \a X and \a Y.
/// \param X The X input value.
/// \param Y The Y input value.
// distance overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half distance(half X, half Y) { return __detail::length_impl(X - Y); }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half distance(half2 X, half2 Y) { return __detail::length_impl(X - Y); }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half distance(half3 X, half3 Y) { return __detail::length_impl(X - Y); }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half distance(half4 X, half4 Y) { return __detail::length_impl(X - Y); }

inline float distance(float X, float Y) { return __detail::length_impl(X - Y); }
inline float distance(float2 X, float2 Y) { return __detail::length_impl(X - Y); }
inline float distance(float3 X, float3 Y) { return __detail::length_impl(X - Y); }
inline float distance(float4 X, float4 Y) { return __detail::length_impl(X - Y); }

/// \fn float dot2add(half2 A, half2 B, float Acc)
/// \brief Multiplies the elements of the two half-precision float input vectors
/// together and sums the results into the 32-bit float accumulator.
/// \param A The first input value to dot product.
/// \param B The second input value to dot product.
/// \param Acc The accumulator value added to the dot product.
///
/// This instruction operates within a single 32-bit wide SIMD lane.
/// The inputs are 16-bit quantities packed into the same lane.
// dot2add overloads
_HLSL_AVAILABILITY(shadermodel, 6.4)
inline float dot2add(half2 A, half2 B, float Acc) {
  return __detail::dot2add_impl(A, B, Acc);
}

/// \fn vector<T, 4> dst(vector<T, 4> Src0, vector<T, 4> Src1)
/// \brief Calculates a distance vector.
/// \param Src0 [in] Contains the squared distance.
/// \param Src1 [in] Contains the reciprocal distance.
///
/// Return the computed distance vector.
// dst overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 dst(half4 Src0, half4 Src1) { return {1, Src0[1] * Src1[1], Src0[2], Src1[3]}; }

inline float4 dst(float4 Src0, float4 Src1) { return {1, Src0[1] * Src1[1], Src0[2], Src1[3]}; }

inline double4 dst(double4 Src0, double4 Src1) { return {1, Src0[1] * Src1[1], Src0[2], Src1[3]}; }

/// \fn T faceforward(T N, T I, T Ng)
/// \brief Flips the surface-normal (if needed) to face in a direction opposite
/// to \a I. Returns the result in terms of \a N.
/// \param N The resulting floating-point surface-normal vector.
/// \param I A floating-point, incident vector that points from the view
/// position to the shading position.
/// \param Ng A floating-point surface-normal vector.
///
/// Return a floating-point, surface normal vector that is facing the view
/// direction.
// faceforward overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half faceforward(half N, half I, half Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 faceforward(half2 N, half2 I, half2 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 faceforward(half3 N, half3 I, half3 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 faceforward(half4 N, half4 I, half4 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}

inline float faceforward(float N, float I, float Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
inline float2 faceforward(float2 N, float2 I, float2 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
inline float3 faceforward(float3 N, float3 I, float3 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}
inline float4 faceforward(float4 N, float4 I, float4 Ng) {
  return __detail::faceforward_impl(N, I, Ng);
}

/// \fn T fmod(T x, T y)
/// \brief Returns the floating-point remainder of x/y.
/// \param x [in] The dividend.
/// \param y [in] The divisor.
///
/// Return the floating-point remainder of the x parameter divided by the y
/// parameter.
// fmod overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half fmod(half X, half Y) {
  return __detail::fmod_impl(X, Y);
}

inline float fmod(float X, float Y) {
  return __detail::fmod_impl(X, Y);
}

// fmod overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 fmod(half2 X, half2 Y) {
  return __detail::fmod_vec_impl(X, Y);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 fmod(half3 X, half3 Y) {
  return __detail::fmod_vec_impl(X, Y);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 fmod(half4 X, half4 Y) {
  return __detail::fmod_vec_impl(X, Y);
}

inline float2 fmod(float2 X, float2 Y) {
  return __detail::fmod_vec_impl(X, Y);
}
inline float3 fmod(float3 X, float3 Y) {
  return __detail::fmod_vec_impl(X, Y);
}
inline float4 fmod(float4 X, float4 Y) {
  return __detail::fmod_vec_impl(X, Y);
}

/// \fn T fwidth(T x)
/// \brief Computes the sum of the absolute values of the partial derivatives
/// with regard to the x and y screen space coordinates.
/// \param x [in] The floating-point scalar or vector to process.
// fwidth overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half fwidth(half input) {
  return __detail::fwidth_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 fwidth(half2 input) {
  return __detail::fwidth_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 fwidth(half3 input) {
  return __detail::fwidth_impl(input);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 fwidth(half4 input) {
  return __detail::fwidth_impl(input);
}

inline float fwidth(float input) {
  return __detail::fwidth_impl(input);
}
inline float2 fwidth(float2 input) {
  return __detail::fwidth_impl(input);
}
inline float3 fwidth(float3 input) {
  return __detail::fwidth_impl(input);
}
inline float4 fwidth(float4 input) {
  return __detail::fwidth_impl(input);
}

/// \fn T ldexp(T X, T Exp)
/// \brief Returns the result of multiplying the specified value by two raised
/// to the power of the specified exponent.
/// \param X [in] The specified value.
/// \param Exp [in] The specified exponent.
///
/// This function uses the following formula: X * 2^Exp
// ldexp overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half ldexp(half X, half Exp) { return exp2(Exp) * X; }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 ldexp(half2 X, half2 Exp) { return exp2(Exp) * X; }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 ldexp(half3 X, half3 Exp) { return exp2(Exp) * X; }
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 ldexp(half4 X, half4 Exp) { return exp2(Exp) * X; }

inline float ldexp(float X, float Exp) { return exp2(Exp) * X; }
inline float2 ldexp(float2 X, float2 Exp) { return exp2(Exp) * X; }
inline float3 ldexp(float3 X, float3 Exp) { return exp2(Exp) * X; }
inline float4 ldexp(float4 X, float4 Exp) { return exp2(Exp) * X; }

/// \fn T length(T x)
/// \brief Returns the length of the specified floating-point vector.
/// \param x [in] The vector of floats, or a scalar float.
///
/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
// length overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half length(half X) {
  return __detail::length_impl(X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half length(half2 X) {
  return __detail::length_impl(X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half length(half3 X) {
  return __detail::length_impl(X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half length(half4 X) {
  return __detail::length_impl(X);
}

inline float length(float X) {
  return __detail::length_impl(X);
}
inline float length(float2 X) {
  return __detail::length_impl(X);
}
inline float length(float3 X) {
  return __detail::length_impl(X);
}
inline float length(float4 X) {
  return __detail::length_impl(X);
}

// lit overloads
inline float4 lit(float NDotL, float NDotH, float M) {
  return __detail::lit_impl(NDotL, NDotH, M);
}

/// \fn vector<T, 4> lit(T NDotL, T NDotH, T M)
/// \brief Returns a lighting coefficient vector.
/// \param NDotL The dot product of the normalized surface normal and the
/// light vector.
/// \param NDotH The dot product of the half-angle vector and the surface
/// normal.
/// \param M A specular exponent.
///
/// This function returns a lighting coefficient vector (ambient, diffuse,
/// specular, 1).
// lit overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 lit(half NDotL, half NDotH, half M) {
  return __detail::lit_impl(NDotL, NDotH, M);
}

/// \fn T reflect(T I, T N)
/// \brief Returns a reflection using an incident ray, \a I, and a surface
/// normal, \a N.
/// \param I The incident ray.
/// \param N The surface normal.
///
/// The return value is a floating-point vector that represents the reflection
/// of the incident ray, \a I, off a surface with the normal \a N.
///
/// This function calculates the reflection vector using the following formula:
/// V = I - 2 * N * dot(I N) .
///
/// N must already be normalized in order to achieve the desired result.
// reflect overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half reflect(half I, half N) {
  return __detail::reflect_impl(I, N);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 reflect(half2 I, half2 N) {
  return __detail::reflect_impl(I, N);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 reflect(half3 I, half3 N) {
  return __detail::reflect_impl(I, N);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 reflect(half4 I, half4 N) {
  return __detail::reflect_impl(I, N);
}

inline float reflect(float I, float N) {
  return __detail::reflect_impl(I, N);
}
inline float2 reflect(float2 I, float2 N) {
  return __detail::reflect_impl(I, N);
}
inline float3 reflect(float3 I, float3 N) {
  return __detail::reflect_impl(I, N);
}
inline float4 reflect(float4 I, float4 N) {
  return __detail::reflect_impl(I, N);
}

/// \fn T refract(T I, T N, T eta)
/// \brief Returns a refraction using an entering ray, \a I, a surface
/// normal, \a N and refraction index \a eta
/// \param I The entering ray.
/// \param N The surface normal.
/// \param eta The refraction index.
///
/// The return value is a floating-point vector that represents the refraction
/// using the refraction index, \a eta, for the direction of the entering ray,
/// \a I, off a surface with the normal \a N.
///
/// This function calculates the refraction vector using the following formulas:
/// k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
/// if k < 0.0 the result is 0.0
/// otherwise, the result is eta * I - (eta * dot(N, I) + sqrt(k)) * N
///
/// I and N must already be normalized in order to achieve the desired result.
///
/// I and N must be a scalar or vector whose component type is
/// floating-point.
///
/// eta must be a 16-bit or 32-bit floating-point scalar.
///
/// Result type, the type of I, and the type of N must all be the same type.
// refract overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half refract(half I, half N, half eta) {
  return __detail::refract_impl(I, N, eta);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 refract(half2 I, half2 N, half eta) {
  return __detail::refract_impl(I, N, eta);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 refract(half3 I, half3 N, half eta) {
  return __detail::refract_impl(I, N, eta);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 refract(half4 I, half4 N, half eta) {
  return __detail::refract_impl(I, N, eta);
}

inline float refract(float I, float N, float eta) {
  return __detail::refract_impl(I, N, eta);
}
inline float2 refract(float2 I, float2 N, float eta) {
  return __detail::refract_impl(I, N, eta);
}
inline float3 refract(float3 I, float3 N, float eta) {
  return __detail::refract_impl(I, N, eta);
}
inline float4 refract(float4 I, float4 N, float eta) {
  return __detail::refract_impl(I, N, eta);
}

/// \fn T smoothstep(T Min, T Max, T X)
/// \brief Returns a smooth Hermite interpolation between 0 and 1, if \a X is in
/// the range [\a Min, \a Max].
/// \param Min The minimum range of the x parameter.
/// \param Max The maximum range of the x parameter.
/// \param X The specified value to be interpolated.
///
/// The return value is 0.0 if \a X <= \a Min and 1.0 if \a X >= \a Max. When \a
/// Min < \a X < \a Max, the function performs smooth Hermite interpolation
/// between 0 and 1.
// smoothstep overloads
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half smoothstep(half Min, half Max, half X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half2 smoothstep(half2 Min, half2 Max, half2 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half3 smoothstep(half3 Min, half3 Max, half3 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
inline half4 smoothstep(half4 Min, half4 Max, half4 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}

inline float smoothstep(float Min, float Max, float X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
inline float2 smoothstep(float2 Min, float2 Max, float2 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
inline float3 smoothstep(float3 Min, float3 Max, float3 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}
inline float4 smoothstep(float4 Min, float4 Max, float4 X) {
  return __detail::smoothstep_impl(Min, Max, X);
}

