@@ -46,6 +46,35 @@ template <typename T> constexpr int asint(T F) {
4646 return __detail::bit_cast<int , T>(F);
4747}
4848
49+ // ===----------------------------------------------------------------------===//
50+ // asint16 builtins
51+ // ===----------------------------------------------------------------------===//
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_BIT
58+
59+ template <typename T, int N>
60+ _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
61+ constexpr __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+
68+ template <typename T>
69+ _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
70+ constexpr __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+ #endif
77+
4978// ===----------------------------------------------------------------------===//
5079// asuint builtins
5180// ===----------------------------------------------------------------------===//
@@ -80,35 +109,6 @@ void asuint(double3, out uint3, out uint3);
80109_HLSL_BUILTIN_ALIAS (__builtin_hlsl_elementwise_splitdouble)
81110void asuint (double4, out uint4, out uint4);
82111
83- // ===----------------------------------------------------------------------===//
84- // asint16 builtins
85- // ===----------------------------------------------------------------------===//
86-
87- // / \fn int16_t asint16(T X)
88- // / \brief Interprets the bit pattern of \a X as an 16-bit integer.
89- // / \param X The input value.
90-
91- #ifdef __HLSL_ENABLE_16_BIT
92-
93- template <typename T, int N>
94- _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
95- constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||
96- __detail::is_same<uint16_t, T>::value ||
97- __detail::is_same<half, T>::value,
98- vector<int16_t, N>> asint16(vector<T, N> V) {
99- return __detail::bit_cast<int16_t , T, N>(V);
100- }
101-
102- template <typename T>
103- _HLSL_16BIT_AVAILABILITY (shadermodel, 6.2 )
104- constexpr __detail::enable_if_t<__detail::is_same<int16_t, T>::value ||
105- __detail::is_same<uint16_t, T>::value ||
106- __detail::is_same<half, T>::value,
107- int16_t> asint16(T F) {
108- return __detail::bit_cast<int16_t , T>(F);
109- }
110- #endif
111-
112112// ===----------------------------------------------------------------------===//
113113// asuint16 builtins
114114// ===----------------------------------------------------------------------===//
0 commit comments