715 lines · c
1//===----- hlsl_intrinsics.h - HLSL definitions for intrinsics ----------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _HLSL_HLSL_INTRINSICS_H_10#define _HLSL_HLSL_INTRINSICS_H_11 12#include "hlsl/hlsl_intrinsic_helpers.h"13 14namespace hlsl {15 16//===----------------------------------------------------------------------===//17// asfloat builtins18//===----------------------------------------------------------------------===//19 20/// \fn float asfloat(T Val)21/// \brief Interprets the bit pattern of x as float point number.22/// \param Val The input value.23 24template <typename T, int N>25constexpr vector<float, N> asfloat(vector<T, N> V) {26 return __detail::bit_cast<float, T, N>(V);27}28 29template <typename T> constexpr float asfloat(T F) {30 return __detail::bit_cast<float, T>(F);31}32 33//===----------------------------------------------------------------------===//34// asint builtins35//===----------------------------------------------------------------------===//36 37/// \fn int asint(T Val)38/// \brief Interprets the bit pattern of x as an integer.39/// \param Val The input value.40 41template <typename T, int N> constexpr vector<int, N> asint(vector<T, N> V) {42 return __detail::bit_cast<int, T, N>(V);43}44 45template <typename T> constexpr int asint(T F) {46 return __detail::bit_cast<int, T>(F);47}48 49//===----------------------------------------------------------------------===//50// asint16 builtins51//===----------------------------------------------------------------------===//52 53/// \fn int16_t asint16(T X)54/// \brief Interprets the bit pattern of \a X as an 16-bit integer.55/// \param X The input value.56 57#ifdef __HLSL_ENABLE_16_BIT58 59template <typename T, int N>60_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)61constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||62 __detail::is_same<uint16_t, T>::value ||63 __detail::is_same<half, T>::value,64 vector<int16_t, N>> asint16(vector<T, N> V) {65 return __detail::bit_cast<int16_t, T, N>(V);66}67 68template <typename T>69_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)70constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||71 __detail::is_same<uint16_t, T>::value ||72 __detail::is_same<half, T>::value,73 int16_t> asint16(T F) {74 return __detail::bit_cast<int16_t, T>(F);75}76#endif77 78//===----------------------------------------------------------------------===//79// asuint builtins80//===----------------------------------------------------------------------===//81 82/// \fn uint asuint(T Val)83/// \brief Interprets the bit pattern of x as an unsigned integer.84/// \param Val The input value.85 86template <typename T, int N> constexpr vector<uint, N> asuint(vector<T, N> V) {87 return __detail::bit_cast<uint, T, N>(V);88}89 90template <typename T> constexpr uint asuint(T F) {91 return __detail::bit_cast<uint, T>(F);92}93 94//===----------------------------------------------------------------------===//95// asuint splitdouble builtins96//===----------------------------------------------------------------------===//97 98/// \fn void asuint(double D, out uint lowbits, out int highbits)99/// \brief Split and interprets the lowbits and highbits of double D into uints.100/// \param D The input double.101/// \param lowbits The output lowbits of D.102/// \param highbits The output highbits of D.103_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)104void asuint(double, out uint, out uint);105_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)106void asuint(double2, out uint2, out uint2);107_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)108void asuint(double3, out uint3, out uint3);109_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)110void asuint(double4, out uint4, out uint4);111 112//===----------------------------------------------------------------------===//113// asuint16 builtins114//===----------------------------------------------------------------------===//115 116/// \fn uint16_t asuint16(T X)117/// \brief Interprets the bit pattern of \a X as an 16-bit unsigned integer.118/// \param X The input value.119 120#ifdef __HLSL_ENABLE_16_BIT121 122template <typename T, int N>123_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)124constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||125 __detail::is_same<uint16_t, T>::value ||126 __detail::is_same<half, T>::value,127 vector<uint16_t, N>> asuint16(vector<T, N> V) {128 return __detail::bit_cast<uint16_t, T, N>(V);129}130 131template <typename T>132_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)133constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||134 __detail::is_same<uint16_t, T>::value ||135 __detail::is_same<half, T>::value,136 uint16_t> asuint16(T F) {137 return __detail::bit_cast<uint16_t, T>(F);138}139#endif140 141//===----------------------------------------------------------------------===//142// distance builtins143//===----------------------------------------------------------------------===//144 145/// \fn K distance(T X, T Y)146/// \brief Returns a distance scalar between \a X and \a Y.147/// \param X The X input value.148/// \param Y The Y input value.149 150template <typename T>151_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)152const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&153 __detail::is_same<half, T>::value,154 T> distance(T X, T Y) {155 return __detail::distance_impl(X, Y);156}157 158template <typename T>159const inline __detail::enable_if_t<160 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>161distance(T X, T Y) {162 return __detail::distance_impl(X, Y);163}164 165template <int N>166_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)167const inline half distance(__detail::HLSL_FIXED_VECTOR<half, N> X,168 __detail::HLSL_FIXED_VECTOR<half, N> Y) {169 return __detail::distance_vec_impl(X, Y);170}171 172template <int N>173const inline float distance(__detail::HLSL_FIXED_VECTOR<float, N> X,174 __detail::HLSL_FIXED_VECTOR<float, N> Y) {175 return __detail::distance_vec_impl(X, Y);176}177 178//===----------------------------------------------------------------------===//179// dot2add builtins180//===----------------------------------------------------------------------===//181 182/// \fn float dot2add(half2 A, half2 B, float C)183/// \brief Dot product of 2 vector of type half and add a float scalar value.184/// \param A The first input value to dot product.185/// \param B The second input value to dot product.186/// \param C The input value added to the dot product.187 188_HLSL_AVAILABILITY(shadermodel, 6.4)189const inline float dot2add(half2 A, half2 B, float C) {190 return __detail::dot2add_impl(A, B, C);191}192 193//===----------------------------------------------------------------------===//194// dst builtins195//===----------------------------------------------------------------------===//196 197/// \fn vector<T, 4> dst(vector<T, 4>, vector<T, 4>)198/// \brief Calculates a distance vector.199/// \param Src0 [in] Contains the squared distance200/// \param Src1 [in] Contains the reciprocal distance201///202/// Return the computed distance vector203 204_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)205const inline half4 dst(half4 Src0, half4 Src1) {206 return __detail::dst_impl(Src0, Src1);207}208 209const inline float4 dst(float4 Src0, float4 Src1) {210 return __detail::dst_impl(Src0, Src1);211}212 213const inline double4 dst(double4 Src0, double4 Src1) {214 return __detail::dst_impl(Src0, Src1);215}216 217//===----------------------------------------------------------------------===//218// faceforward builtin219//===----------------------------------------------------------------------===//220 221/// \fn T faceforward(T N, T I, T Ng)222/// \brief Flips the surface-normal (if needed) to face in a direction opposite223/// to \a I. Returns the result in terms of \a N.224/// \param N The resulting floating-point surface-normal vector.225/// \param I A floating-point, incident vector that points from the view226/// position to the shading position.227/// \param Ng A floating-point surface-normal vector.228///229/// Return a floating-point, surface normal vector that is facing the view230/// direction.231 232template <typename T>233_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)234const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&235 __detail::is_same<half, T>::value,236 T> faceforward(T N, T I, T Ng) {237 return __detail::faceforward_impl(N, I, Ng);238}239 240template <typename T>241const inline __detail::enable_if_t<242 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>243faceforward(T N, T I, T Ng) {244 return __detail::faceforward_impl(N, I, Ng);245}246 247template <int L>248_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)249const inline __detail::HLSL_FIXED_VECTOR<half, L> faceforward(250 __detail::HLSL_FIXED_VECTOR<half, L> N,251 __detail::HLSL_FIXED_VECTOR<half, L> I,252 __detail::HLSL_FIXED_VECTOR<half, L> Ng) {253 return __detail::faceforward_impl(N, I, Ng);254}255 256template <int L>257const inline __detail::HLSL_FIXED_VECTOR<float, L>258faceforward(__detail::HLSL_FIXED_VECTOR<float, L> N,259 __detail::HLSL_FIXED_VECTOR<float, L> I,260 __detail::HLSL_FIXED_VECTOR<float, L> Ng) {261 return __detail::faceforward_impl(N, I, Ng);262}263 264//===----------------------------------------------------------------------===//265// firstbithigh builtins266//===----------------------------------------------------------------------===//267 268/// \fn T firstbithigh(T Val)269/// \brief Returns the location of the first set bit starting from the lowest270/// order bit and working upward, per component.271/// \param Val the input value.272 273#ifdef __HLSL_ENABLE_16_BIT274 275template <typename T>276_HLSL_AVAILABILITY(shadermodel, 6.2)277const inline __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||278 __detail::is_same<uint16_t, T>::value,279 uint> firstbithigh(T X) {280 return __detail::firstbithigh_impl<uint, T, 16>(X);281}282 283template <typename T, int N>284_HLSL_AVAILABILITY(shadermodel, 6.2)285const286 inline __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||287 __detail::is_same<uint16_t, T>::value,288 vector<uint, N>> firstbithigh(vector<T, N> X) {289 return __detail::firstbithigh_impl<vector<uint, N>, vector<T, N>, 16>(X);290}291 292#endif293 294template <typename T>295const inline __detail::enable_if_t<296 __detail::is_same<int, T>::value || __detail::is_same<uint, T>::value, uint>297firstbithigh(T X) {298 return __detail::firstbithigh_impl<uint, T, 32>(X);299}300 301template <typename T, int N>302const inline __detail::enable_if_t<__detail::is_same<int, T>::value ||303 __detail::is_same<uint, T>::value,304 vector<uint, N>>305firstbithigh(vector<T, N> X) {306 return __detail::firstbithigh_impl<vector<uint, N>, vector<T, N>, 32>(X);307}308 309template <typename T>310const inline __detail::enable_if_t<__detail::is_same<int64_t, T>::value ||311 __detail::is_same<uint64_t, T>::value,312 uint>313firstbithigh(T X) {314 return __detail::firstbithigh_impl<uint, T, 64>(X);315}316 317template <typename T, int N>318const inline __detail::enable_if_t<__detail::is_same<int64_t, T>::value ||319 __detail::is_same<uint64_t, T>::value,320 vector<uint, N>>321firstbithigh(vector<T, N> X) {322 return __detail::firstbithigh_impl<vector<uint, N>, vector<T, N>, 64>(X);323}324 325//===----------------------------------------------------------------------===//326// fmod builtins327//===----------------------------------------------------------------------===//328 329/// \fn T fmod(T x, T y)330/// \brief Returns the linear interpolation of x to y.331/// \param x [in] The dividend.332/// \param y [in] The divisor.333///334/// Return the floating-point remainder of the x parameter divided by the y335/// parameter.336 337template <typename T>338_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)339const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&340 __detail::is_same<half, T>::value,341 T> fmod(T X, T Y) {342 return __detail::fmod_impl(X, Y);343}344 345template <typename T>346const inline __detail::enable_if_t<347 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>348fmod(T X, T Y) {349 return __detail::fmod_impl(X, Y);350}351 352template <int N>353_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)354const inline __detail::HLSL_FIXED_VECTOR<half, N> fmod(355 __detail::HLSL_FIXED_VECTOR<half, N> X,356 __detail::HLSL_FIXED_VECTOR<half, N> Y) {357 return __detail::fmod_vec_impl(X, Y);358}359 360template <int N>361const inline __detail::HLSL_FIXED_VECTOR<float, N>362fmod(__detail::HLSL_FIXED_VECTOR<float, N> X,363 __detail::HLSL_FIXED_VECTOR<float, N> Y) {364 return __detail::fmod_vec_impl(X, Y);365}366 367//===----------------------------------------------------------------------===//368// ldexp builtins369//===----------------------------------------------------------------------===//370 371/// \fn T ldexp(T X, T Exp)372/// \brief Returns the result of multiplying the specified value by two raised373/// to the power of the specified exponent.374/// \param X [in] The specified value.375/// \param Exp [in] The specified exponent.376///377/// This function uses the following formula: X * 2^Exp378 379template <typename T>380_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)381const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&382 __detail::is_same<half, T>::value,383 T> ldexp(T X, T Exp) {384 return __detail::ldexp_impl(X, Exp);385}386 387template <typename T>388const inline __detail::enable_if_t<389 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>390ldexp(T X, T Exp) {391 return __detail::ldexp_impl(X, Exp);392}393 394template <int N>395_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)396const inline __detail::HLSL_FIXED_VECTOR<half, N> ldexp(397 __detail::HLSL_FIXED_VECTOR<half, N> X,398 __detail::HLSL_FIXED_VECTOR<half, N> Exp) {399 return __detail::ldexp_impl(X, Exp);400}401 402template <int N>403const inline __detail::HLSL_FIXED_VECTOR<float, N>404ldexp(__detail::HLSL_FIXED_VECTOR<float, N> X,405 __detail::HLSL_FIXED_VECTOR<float, N> Exp) {406 return __detail::ldexp_impl(X, Exp);407}408 409//===----------------------------------------------------------------------===//410// length builtins411//===----------------------------------------------------------------------===//412 413/// \fn T length(T x)414/// \brief Returns the length of the specified floating-point vector.415/// \param x [in] The vector of floats, or a scalar float.416///417/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).418 419template <typename T>420_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)421const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&422 __detail::is_same<half, T>::value,423 T> length(T X) {424 return __detail::length_impl(X);425}426 427template <typename T>428const inline __detail::enable_if_t<429 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>430length(T X) {431 return __detail::length_impl(X);432}433 434template <int N>435_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)436const inline half length(__detail::HLSL_FIXED_VECTOR<half, N> X) {437 return __detail::length_vec_impl(X);438}439 440template <int N>441const inline float length(__detail::HLSL_FIXED_VECTOR<float, N> X) {442 return __detail::length_vec_impl(X);443}444 445//===----------------------------------------------------------------------===//446// lit builtins447//===----------------------------------------------------------------------===//448 449/// \fn vector<T, 4> lit(T NDotL, T NDotH, T M)450/// \brief Returns a lighting coefficient vector.451/// \param NDotL The dot product of the normalized surface normal and the452/// light vector.453/// \param NDotH The dot product of the half-angle vector and the surface454/// normal.455/// \param M A specular exponent.456///457/// This function returns a lighting coefficient vector (ambient, diffuse,458/// specular, 1).459 460_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)461const inline half4 lit(half NDotL, half NDotH, half M) {462 return __detail::lit_impl(NDotL, NDotH, M);463}464 465const inline float4 lit(float NDotL, float NDotH, float M) {466 return __detail::lit_impl(NDotL, NDotH, M);467}468 469//===----------------------------------------------------------------------===//470// D3DCOLORtoUBYTE4 builtin471//===----------------------------------------------------------------------===//472 473/// \fn T D3DCOLORtoUBYTE4(T x)474/// \brief Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.475/// \param x [in] The floating-point vector4 to convert.476///477/// The return value is the UBYTE4 representation of the \a x parameter.478///479/// This function swizzles and scales components of the \a x parameter. Use this480/// function to compensate for the lack of UBYTE4 support in some hardware.481 482constexpr int4 D3DCOLORtoUBYTE4(float4 V) {483 return __detail::d3d_color_to_ubyte4_impl(V);484}485 486//===----------------------------------------------------------------------===//487// NonUniformResourceIndex builtin488//===----------------------------------------------------------------------===//489 490/// \fn uint NonUniformResourceIndex(uint I)491/// \brief A compiler hint to indicate that a resource index varies across492/// threads within a wave (i.e., it is non-uniform).493/// \param I [in] Resource array index494///495/// The return value is the \Index parameter.496///497/// When indexing into an array of shader resources (e.g., textures, buffers),498/// some GPU hardware and drivers require the compiler to know whether the index499/// is uniform (same for all threads) or non-uniform (varies per thread).500///501/// Using NonUniformResourceIndex explicitly marks an index as non-uniform,502/// disabling certain assumptions or optimizations that could lead to incorrect503/// behavior when dynamically accessing resource arrays with non-uniform504/// indices.505 506constexpr uint32_t NonUniformResourceIndex(uint32_t Index) {507 return __builtin_hlsl_resource_nonuniformindex(Index);508}509 510//===----------------------------------------------------------------------===//511// reflect builtin512//===----------------------------------------------------------------------===//513 514/// \fn T reflect(T I, T N)515/// \brief Returns a reflection using an incident ray, \a I, and a surface516/// normal, \a N.517/// \param I The incident ray.518/// \param N The surface normal.519///520/// The return value is a floating-point vector that represents the reflection521/// of the incident ray, \a I, off a surface with the normal \a N.522///523/// This function calculates the reflection vector using the following formula:524/// V = I - 2 * N * dot(I N) .525///526/// N must already be normalized in order to achieve the desired result.527///528/// The operands must all be a scalar or vector whose component type is529/// floating-point.530///531/// Result type and the type of all operands must be the same type.532 533template <typename T>534_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)535const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&536 __detail::is_same<half, T>::value,537 T> reflect(T I, T N) {538 return __detail::reflect_impl(I, N);539}540 541template <typename T>542const inline __detail::enable_if_t<543 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>544reflect(T I, T N) {545 return __detail::reflect_impl(I, N);546}547 548template <int L>549_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)550const inline __detail::HLSL_FIXED_VECTOR<half, L> reflect(551 __detail::HLSL_FIXED_VECTOR<half, L> I,552 __detail::HLSL_FIXED_VECTOR<half, L> N) {553 return __detail::reflect_vec_impl(I, N);554}555 556template <int L>557const inline __detail::HLSL_FIXED_VECTOR<float, L>558reflect(__detail::HLSL_FIXED_VECTOR<float, L> I,559 __detail::HLSL_FIXED_VECTOR<float, L> N) {560 return __detail::reflect_vec_impl(I, N);561}562 563//===----------------------------------------------------------------------===//564// refract builtin565//===----------------------------------------------------------------------===//566 567/// \fn T refract(T I, T N, T eta)568/// \brief Returns a refraction using an entering ray, \a I, a surface569/// normal, \a N and refraction index \a eta570/// \param I The entering ray.571/// \param N The surface normal.572/// \param eta The refraction index.573///574/// The return value is a floating-point vector that represents the refraction575/// using the refraction index, \a eta, for the direction of the entering ray,576/// \a I, off a surface with the normal \a N.577///578/// This function calculates the refraction vector using the following formulas:579/// k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))580/// if k < 0.0 the result is 0.0581/// otherwise, the result is eta * I - (eta * dot(N, I) + sqrt(k)) * N582///583/// I and N must already be normalized in order to achieve the desired result.584///585/// I and N must be a scalar or vector whose component type is586/// floating-point.587///588/// eta must be a 16-bit or 32-bit floating-point scalar.589///590/// Result type, the type of I, and the type of N must all be the same type.591 592template <typename T>593_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)594const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&595 __detail::is_same<half, T>::value,596 T> refract(T I, T N, T eta) {597 return __detail::refract_impl(I, N, eta);598}599 600template <typename T>601const inline __detail::enable_if_t<602 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>603refract(T I, T N, T eta) {604 return __detail::refract_impl(I, N, eta);605}606 607template <int L>608_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)609const inline __detail::HLSL_FIXED_VECTOR<half, L> refract(610 __detail::HLSL_FIXED_VECTOR<half, L> I,611 __detail::HLSL_FIXED_VECTOR<half, L> N, half eta) {612 return __detail::refract_impl(I, N, eta);613}614 615template <int L>616const inline __detail::HLSL_FIXED_VECTOR<float, L>617refract(__detail::HLSL_FIXED_VECTOR<float, L> I,618 __detail::HLSL_FIXED_VECTOR<float, L> N, float eta) {619 return __detail::refract_impl(I, N, eta);620}621 622//===----------------------------------------------------------------------===//623// smoothstep builtin624//===----------------------------------------------------------------------===//625 626/// \fn T smoothstep(T Min, T Max, T X)627/// \brief Returns a smooth Hermite interpolation between 0 and 1, if \a X is in628/// the range [\a Min, \a Max].629/// \param Min The minimum range of the x parameter.630/// \param Max The maximum range of the x parameter.631/// \param X The specified value to be interpolated.632///633/// The return value is 0.0 if \a X ≤ \a Min and 1.0 if \a X ≥ \a Max. When \a634/// Min < \a X < \a Max, the function performs smooth Hermite interpolation635/// between 0 and 1.636 637template <typename T>638_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)639const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&640 __detail::is_same<half, T>::value,641 T> smoothstep(T Min, T Max, T X) {642 return __detail::smoothstep_impl(Min, Max, X);643}644 645template <typename T>646const inline __detail::enable_if_t<647 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>648smoothstep(T Min, T Max, T X) {649 return __detail::smoothstep_impl(Min, Max, X);650}651 652template <int N>653_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)654const inline __detail::HLSL_FIXED_VECTOR<half, N> smoothstep(655 __detail::HLSL_FIXED_VECTOR<half, N> Min,656 __detail::HLSL_FIXED_VECTOR<half, N> Max,657 __detail::HLSL_FIXED_VECTOR<half, N> X) {658 return __detail::smoothstep_vec_impl(Min, Max, X);659}660 661template <int N>662const inline __detail::HLSL_FIXED_VECTOR<float, N>663smoothstep(__detail::HLSL_FIXED_VECTOR<float, N> Min,664 __detail::HLSL_FIXED_VECTOR<float, N> Max,665 __detail::HLSL_FIXED_VECTOR<float, N> X) {666 return __detail::smoothstep_vec_impl(Min, Max, X);667}668 669inline bool CheckAccessFullyMapped(uint Status) {670 return static_cast<bool>(Status);671}672 673//===----------------------------------------------------------------------===//674// fwidth builtin675//===----------------------------------------------------------------------===//676 677/// \fn T fwidth(T x)678/// \brief Computes the sum of the absolute values of the partial derivatives679/// with regard to the x and y screen space coordinates.680/// \param x [in] The floating-point scalar or vector to process.681///682/// The return value is a floating-point scalar or vector where each element683/// holds the computation of the matching element in the input.684 685template <typename T>686_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)687const inline __detail::enable_if_t<__detail::is_arithmetic<T>::Value &&688 __detail::is_same<half, T>::value,689 T> fwidth(T input) {690 return __detail::fwidth_impl(input);691}692 693template <typename T>694const inline __detail::enable_if_t<695 __detail::is_arithmetic<T>::Value && __detail::is_same<float, T>::value, T>696fwidth(T input) {697 return __detail::fwidth_impl(input);698}699 700template <int N>701_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)702const inline __detail::HLSL_FIXED_VECTOR<half, N> fwidth(703 __detail::HLSL_FIXED_VECTOR<half, N> input) {704 return __detail::fwidth_impl(input);705}706 707template <int N>708const inline __detail::HLSL_FIXED_VECTOR<float, N>709fwidth(__detail::HLSL_FIXED_VECTOR<float, N> input) {710 return __detail::fwidth_impl(input);711}712 713} // namespace hlsl714#endif //_HLSL_HLSL_INTRINSICS_H_715