clang 20.0.0git
hlsl_intrinsics.h
Go to the documentation of this file.
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-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _HLSL_HLSL_INTRINSICS_H_
10#define _HLSL_HLSL_INTRINSICS_H_
11
12#include "hlsl_detail.h"
13
14namespace hlsl {
15
16// Note: Functions in this file are sorted alphabetically, then grouped by base
17// element type, and the element types are sorted by size, then singed integer,
18// unsigned integer and floating point. Keeping this ordering consistent will
19// help keep this file manageable as it grows.
20
21#define _HLSL_BUILTIN_ALIAS(builtin) \
22 __attribute__((clang_builtin_alias(builtin)))
23#define _HLSL_AVAILABILITY(platform, version) \
24 __attribute__((availability(platform, introduced = version)))
25#define _HLSL_AVAILABILITY_STAGE(platform, version, stage) \
26 __attribute__(( \
27 availability(platform, introduced = version, environment = stage)))
28
29#ifdef __HLSL_ENABLE_16_BIT
30#define _HLSL_16BIT_AVAILABILITY(platform, version) \
31 __attribute__((availability(platform, introduced = version)))
32#define _HLSL_16BIT_AVAILABILITY_STAGE(platform, version, stage) \
33 __attribute__(( \
34 availability(platform, introduced = version, environment = stage)))
35#else
36#define _HLSL_16BIT_AVAILABILITY(environment, version)
37#define _HLSL_16BIT_AVAILABILITY_STAGE(environment, version, stage)
38#endif
39
40//===----------------------------------------------------------------------===//
41// abs builtins
42//===----------------------------------------------------------------------===//
43
44/// \fn T abs(T Val)
45/// \brief Returns the absolute value of the input value, \a Val.
46/// \param Val The input value.
47
48#ifdef __HLSL_ENABLE_16_BIT
49_HLSL_AVAILABILITY(shadermodel, 6.2)
50_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
51int16_t abs(int16_t);
52_HLSL_AVAILABILITY(shadermodel, 6.2)
53_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
54int16_t2 abs(int16_t2);
55_HLSL_AVAILABILITY(shadermodel, 6.2)
56_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
57int16_t3 abs(int16_t3);
58_HLSL_AVAILABILITY(shadermodel, 6.2)
59_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
60int16_t4 abs(int16_t4);
61#endif
62
63_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
64_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
65half abs(half);
66_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
67_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
69_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
70_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
72_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
73_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
75
76_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
77int abs(int);
78_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
80_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
82_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
84
85_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
86float abs(float);
87_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
89_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
91_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
93
94_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
96_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
98_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
100_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
102
103_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
104double abs(double);
105_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
107_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
109_HLSL_BUILTIN_ALIAS(__builtin_elementwise_abs)
111
112//===----------------------------------------------------------------------===//
113// acos builtins
114//===----------------------------------------------------------------------===//
115
116/// \fn T acos(T Val)
117/// \brief Returns the arccosine of the input value, \a Val.
118/// \param Val The input value.
119
120#ifdef __HLSL_ENABLE_16_BIT
121_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
122half acos(half);
123_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
125_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
127_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
129#endif
130
131_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
132float acos(float);
133_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
135_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
137_HLSL_BUILTIN_ALIAS(__builtin_elementwise_acos)
139
140//===----------------------------------------------------------------------===//
141// all builtins
142//===----------------------------------------------------------------------===//
143
144/// \fn bool all(T x)
145/// \brief Returns True if all components of the \a x parameter are non-zero;
146/// otherwise, false. \param x The input value.
147
148#ifdef __HLSL_ENABLE_16_BIT
149_HLSL_AVAILABILITY(shadermodel, 6.2)
150_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
151bool all(int16_t);
152_HLSL_AVAILABILITY(shadermodel, 6.2)
153_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
154bool all(int16_t2);
155_HLSL_AVAILABILITY(shadermodel, 6.2)
156_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
157bool all(int16_t3);
158_HLSL_AVAILABILITY(shadermodel, 6.2)
159_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
160bool all(int16_t4);
161_HLSL_AVAILABILITY(shadermodel, 6.2)
162_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
163bool all(uint16_t);
164_HLSL_AVAILABILITY(shadermodel, 6.2)
165_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
166bool all(uint16_t2);
167_HLSL_AVAILABILITY(shadermodel, 6.2)
168_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
169bool all(uint16_t3);
170_HLSL_AVAILABILITY(shadermodel, 6.2)
171_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
172bool all(uint16_t4);
173#endif
174
175_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
176_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
177bool all(half);
178_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
179_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
180bool all(half2);
181_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
182_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
183bool all(half3);
184_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
185_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
186bool all(half4);
187
188_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
189bool all(bool);
190_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
191bool all(bool2);
192_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
193bool all(bool3);
194_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
195bool all(bool4);
196_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
197
198_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
199bool all(int);
200_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
201bool all(int2);
202_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
203bool all(int3);
204_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
205bool all(int4);
206
207_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
208bool all(uint);
209_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
210bool all(uint2);
211_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
212bool all(uint3);
213_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
214bool all(uint4);
215
216_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
217bool all(float);
218_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
220_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
222_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
224
225_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
227_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
229_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
231_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
233
234_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
236_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
238_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
240_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
242
243_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
244bool all(double);
245_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
247_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
249_HLSL_BUILTIN_ALIAS(__builtin_hlsl_all)
251
252//===----------------------------------------------------------------------===//
253// any builtins
254//===----------------------------------------------------------------------===//
255
256/// \fn bool any(T x)
257/// \brief Returns True if any components of the \a x parameter are non-zero;
258/// otherwise, false. \param x The input value.
259
260#ifdef __HLSL_ENABLE_16_BIT
261_HLSL_AVAILABILITY(shadermodel, 6.2)
262_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
263bool any(int16_t);
264_HLSL_AVAILABILITY(shadermodel, 6.2)
265_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
266bool any(int16_t2);
267_HLSL_AVAILABILITY(shadermodel, 6.2)
268_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
269bool any(int16_t3);
270_HLSL_AVAILABILITY(shadermodel, 6.2)
271_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
272bool any(int16_t4);
273_HLSL_AVAILABILITY(shadermodel, 6.2)
274_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
275bool any(uint16_t);
276_HLSL_AVAILABILITY(shadermodel, 6.2)
277_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
278bool any(uint16_t2);
279_HLSL_AVAILABILITY(shadermodel, 6.2)
280_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
281bool any(uint16_t3);
282_HLSL_AVAILABILITY(shadermodel, 6.2)
283_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
284bool any(uint16_t4);
285#endif
286
287_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
288_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
289bool any(half);
290_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
291_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
292bool any(half2);
293_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
294_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
295bool any(half3);
296_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
297_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
298bool any(half4);
299
300_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
301bool any(bool);
302_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
303bool any(bool2);
304_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
305bool any(bool3);
306_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
307bool any(bool4);
308_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
309
310_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
311bool any(int);
312_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
313bool any(int2);
314_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
315bool any(int3);
316_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
317bool any(int4);
318
319_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
320bool any(uint);
321_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
322bool any(uint2);
323_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
324bool any(uint3);
325_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
326bool any(uint4);
327
328_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
329bool any(float);
330_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
332_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
334_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
336
337_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
339_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
341_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
343_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
345
346_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
348_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
350_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
352_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
354
355_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
356bool any(double);
357_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
359_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
361_HLSL_BUILTIN_ALIAS(__builtin_hlsl_any)
363
364//===----------------------------------------------------------------------===//
365// asdouble builtins
366//===----------------------------------------------------------------------===//
367
368/// \fn double asdouble(uint LowBits, uint HighBits)
369/// \brief Reinterprets a cast value (two 32-bit values) into a double.
370/// \param LowBits The low 32-bit pattern of the input value.
371/// \param HighBits The high 32-bit pattern of the input value.
372
373_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
375_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
377_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
379_HLSL_BUILTIN_ALIAS(__builtin_hlsl_asdouble)
381
382//===----------------------------------------------------------------------===//
383// asfloat builtins
384//===----------------------------------------------------------------------===//
385
386/// \fn float asfloat(T Val)
387/// \brief Interprets the bit pattern of x as float point number.
388/// \param Val The input value.
389
390template <typename T, int N>
391constexpr vector<float, N> asfloat(vector<T, N> V) {
392 return __detail::bit_cast<float, T, N>(V);
393}
394
395template <typename T> constexpr float asfloat(T F) {
396 return __detail::bit_cast<float, T>(F);
397}
398
399//===----------------------------------------------------------------------===//
400// asint builtins
401//===----------------------------------------------------------------------===//
402
403/// \fn int asint(T Val)
404/// \brief Interprets the bit pattern of x as an integer.
405/// \param Val The input value.
406
407template <typename T, int N> constexpr vector<int, N> asint(vector<T, N> V) {
408 return __detail::bit_cast<int, T, N>(V);
409}
410
411template <typename T> constexpr int asint(T F) {
412 return __detail::bit_cast<int, T>(F);
413}
414
415//===----------------------------------------------------------------------===//
416// asin builtins
417//===----------------------------------------------------------------------===//
418
419/// \fn T asin(T Val)
420/// \brief Returns the arcsine of the input value, \a Val.
421/// \param Val The input value.
422
423#ifdef __HLSL_ENABLE_16_BIT
424_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
425half asin(half);
426_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
428_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
430_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
432#endif
433
434_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
435float asin(float);
436_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
438_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
440_HLSL_BUILTIN_ALIAS(__builtin_elementwise_asin)
442
443//===----------------------------------------------------------------------===//
444// asuint builtins
445//===----------------------------------------------------------------------===//
446
447/// \fn uint asuint(T Val)
448/// \brief Interprets the bit pattern of x as an unsigned integer.
449/// \param Val The input value.
450
451template <typename T, int N> constexpr vector<uint, N> asuint(vector<T, N> V) {
452 return __detail::bit_cast<uint, T, N>(V);
453}
454
455template <typename T> constexpr uint asuint(T F) {
456 return __detail::bit_cast<uint, T>(F);
457}
458
459//===----------------------------------------------------------------------===//
460// asuint splitdouble builtins
461//===----------------------------------------------------------------------===//
462
463/// \fn void asuint(double D, out uint lowbits, out int highbits)
464/// \brief Split and interprets the lowbits and highbits of double D into uints.
465/// \param D The input double.
466/// \param lowbits The output lowbits of D.
467/// \param highbits The output highbits of D.
468_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
469void asuint(double, out uint, out uint);
470_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
471void asuint(double2, out uint2, out uint2);
472_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
473void asuint(double3, out uint3, out uint3);
474_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_splitdouble)
475void asuint(double4, out uint4, out uint4);
476
477//===----------------------------------------------------------------------===//
478// atan builtins
479//===----------------------------------------------------------------------===//
480
481/// \fn T atan(T Val)
482/// \brief Returns the arctangent of the input value, \a Val.
483/// \param Val The input value.
484
485#ifdef __HLSL_ENABLE_16_BIT
486_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
487half atan(half);
488_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
490_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
492_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
494#endif
495
496_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
497float atan(float);
498_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
500_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
502_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan)
504
505//===----------------------------------------------------------------------===//
506// atan2 builtins
507//===----------------------------------------------------------------------===//
508
509/// \fn T atan2(T y, T x)
510/// \brief Returns the arctangent of y/x, using the signs of the arguments to
511/// determine the correct quadrant.
512/// \param y The y-coordinate.
513/// \param x The x-coordinate.
514
515#ifdef __HLSL_ENABLE_16_BIT
516_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
517half atan2(half y, half x);
518_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
519half2 atan2(half2 y, half2 x);
520_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
521half3 atan2(half3 y, half3 x);
522_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
523half4 atan2(half4 y, half4 x);
524#endif
525
526_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
527float atan2(float y, float x);
528_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
530_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
532_HLSL_BUILTIN_ALIAS(__builtin_elementwise_atan2)
534
535//===----------------------------------------------------------------------===//
536// ceil builtins
537//===----------------------------------------------------------------------===//
538
539/// \fn T ceil(T Val)
540/// \brief Returns the smallest integer value that is greater than or equal to
541/// the input value, \a Val.
542/// \param Val The input value.
543
544_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
545_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
546half ceil(half);
547_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
548_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
550_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
551_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
553_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
554_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
556
557_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
558float ceil(float);
559_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
561_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
563_HLSL_BUILTIN_ALIAS(__builtin_elementwise_ceil)
565
566//===----------------------------------------------------------------------===//
567// clamp builtins
568//===----------------------------------------------------------------------===//
569
570/// \fn T clamp(T X, T Min, T Max)
571/// \brief Clamps the specified value \a X to the specified
572/// minimum ( \a Min) and maximum ( \a Max) range.
573/// \param X A value to clamp.
574/// \param Min The specified minimum range.
575/// \param Max The specified maximum range.
576///
577/// Returns The clamped value for the \a X parameter.
578/// For values of -INF or INF, clamp will behave as expected.
579/// However for values of NaN, the results are undefined.
580
581_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
582_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
583half clamp(half, half, half);
584_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
585_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
587_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
588_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
590_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
591_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
593
594#ifdef __HLSL_ENABLE_16_BIT
595_HLSL_AVAILABILITY(shadermodel, 6.2)
596_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
597int16_t clamp(int16_t, int16_t, int16_t);
598_HLSL_AVAILABILITY(shadermodel, 6.2)
599_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
600int16_t2 clamp(int16_t2, int16_t2, int16_t2);
601_HLSL_AVAILABILITY(shadermodel, 6.2)
602_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
603int16_t3 clamp(int16_t3, int16_t3, int16_t3);
604_HLSL_AVAILABILITY(shadermodel, 6.2)
605_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
606int16_t4 clamp(int16_t4, int16_t4, int16_t4);
607
608_HLSL_AVAILABILITY(shadermodel, 6.2)
609_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
610uint16_t clamp(uint16_t, uint16_t, uint16_t);
611_HLSL_AVAILABILITY(shadermodel, 6.2)
612_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
613uint16_t2 clamp(uint16_t2, uint16_t2, uint16_t2);
614_HLSL_AVAILABILITY(shadermodel, 6.2)
615_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
616uint16_t3 clamp(uint16_t3, uint16_t3, uint16_t3);
617_HLSL_AVAILABILITY(shadermodel, 6.2)
618_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
619uint16_t4 clamp(uint16_t4, uint16_t4, uint16_t4);
620#endif
621
622_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
623int clamp(int, int, int);
624_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
626_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
628_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
630
631_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
633_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
635_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
637_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
639
640_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
642_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
644_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
646_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
648
649_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
651_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
653_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
655_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
657
658_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
659float clamp(float, float, float);
660_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
662_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
664_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
666
667_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
668double clamp(double, double, double);
669_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
671_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
673_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clamp)
675
676//===----------------------------------------------------------------------===//
677// clip builtins
678//===----------------------------------------------------------------------===//
679
680/// \fn void clip(T Val)
681/// \brief Discards the current pixel if the specified value is less than zero.
682/// \param Val The input value.
683
684_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
685void clip(float);
686_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
688_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
690_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_clip)
692
693//===----------------------------------------------------------------------===//
694// cos builtins
695//===----------------------------------------------------------------------===//
696
697/// \fn T cos(T Val)
698/// \brief Returns the cosine of the input value, \a Val.
699/// \param Val The input value.
700
701_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
702_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
703half cos(half);
704_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
705_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
707_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
708_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
710_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
711_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
713
714_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
715float cos(float);
716_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
718_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
720_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cos)
722
723//===----------------------------------------------------------------------===//
724// cosh builtins
725//===----------------------------------------------------------------------===//
726
727/// \fn T cosh(T Val)
728/// \brief Returns the hyperbolic cosine of the input value, \a Val.
729/// \param Val The input value.
730
731#ifdef __HLSL_ENABLE_16_BIT
732_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
733half cosh(half);
734_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
736_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
738_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
740#endif
741
742_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
743float cosh(float);
744_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
746_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
748_HLSL_BUILTIN_ALIAS(__builtin_elementwise_cosh)
750
751//===----------------------------------------------------------------------===//
752// count bits builtins
753//===----------------------------------------------------------------------===//
754
755/// \fn T countbits(T Val)
756/// \brief Return the number of bits (per component) set in the input integer.
757/// \param Val The input value.
758
759#ifdef __HLSL_ENABLE_16_BIT
760_HLSL_AVAILABILITY(shadermodel, 6.2)
761const inline uint countbits(int16_t x) {
762 return __builtin_elementwise_popcount(x);
763}
764_HLSL_AVAILABILITY(shadermodel, 6.2)
765const inline uint2 countbits(int16_t2 x) {
766 return __builtin_elementwise_popcount(x);
767}
768_HLSL_AVAILABILITY(shadermodel, 6.2)
769const inline uint3 countbits(int16_t3 x) {
770 return __builtin_elementwise_popcount(x);
771}
772_HLSL_AVAILABILITY(shadermodel, 6.2)
773const inline uint4 countbits(int16_t4 x) {
774 return __builtin_elementwise_popcount(x);
775}
776_HLSL_AVAILABILITY(shadermodel, 6.2)
777const inline uint countbits(uint16_t x) {
778 return __builtin_elementwise_popcount(x);
779}
780_HLSL_AVAILABILITY(shadermodel, 6.2)
781const inline uint2 countbits(uint16_t2 x) {
782 return __builtin_elementwise_popcount(x);
783}
784_HLSL_AVAILABILITY(shadermodel, 6.2)
785const inline uint3 countbits(uint16_t3 x) {
786 return __builtin_elementwise_popcount(x);
787}
788_HLSL_AVAILABILITY(shadermodel, 6.2)
789const inline uint4 countbits(uint16_t4 x) {
790 return __builtin_elementwise_popcount(x);
791}
792#endif
793
794const inline uint countbits(int x) { return __builtin_elementwise_popcount(x); }
795const inline uint2 countbits(int2 x) {
796 return __builtin_elementwise_popcount(x);
797}
798const inline uint3 countbits(int3 x) {
799 return __builtin_elementwise_popcount(x);
800}
801const inline uint4 countbits(int4 x) {
802 return __builtin_elementwise_popcount(x);
803}
804
805const inline uint countbits(uint x) {
806 return __builtin_elementwise_popcount(x);
807}
808const inline uint2 countbits(uint2 x) {
809 return __builtin_elementwise_popcount(x);
810}
811const inline uint3 countbits(uint3 x) {
812 return __builtin_elementwise_popcount(x);
813}
814const inline uint4 countbits(uint4 x) {
815 return __builtin_elementwise_popcount(x);
816}
817
818const inline uint countbits(int64_t x) {
819 return __builtin_elementwise_popcount(x);
820}
821const inline uint2 countbits(int64_t2 x) {
822 return __builtin_elementwise_popcount(x);
823}
824const inline uint3 countbits(int64_t3 x) {
825 return __builtin_elementwise_popcount(x);
826}
827const inline uint4 countbits(int64_t4 x) {
828 return __builtin_elementwise_popcount(x);
829}
830
831const inline uint countbits(uint64_t x) {
832 return __builtin_elementwise_popcount(x);
833}
834const inline uint2 countbits(uint64_t2 x) {
835 return __builtin_elementwise_popcount(x);
836}
837const inline uint3 countbits(uint64_t3 x) {
838 return __builtin_elementwise_popcount(x);
839}
840const inline uint4 countbits(uint64_t4 x) {
841 return __builtin_elementwise_popcount(x);
842}
843
844//===----------------------------------------------------------------------===//
845// degrees builtins
846//===----------------------------------------------------------------------===//
847
848/// \fn T degrees(T x)
849/// \brief Converts the specified value from radians to degrees.
850/// \param x The specified input value.
851
852_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
853_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
854half degrees(half);
855_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
856_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
858_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
859_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
861_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
862_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
864
865_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
866float degrees(float);
867_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
869_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
871_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_degrees)
873
874//===----------------------------------------------------------------------===//
875// distance builtins
876//===----------------------------------------------------------------------===//
877
878/// \fn K distance(T X, T Y)
879/// \brief Returns a distance scalar between \a X and \a Y.
880/// \param X The X input value.
881/// \param Y The Y input value.
882
883_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
884const inline half distance(half X, half Y) {
885 return __detail::distance_impl(X, Y);
886}
887
888const inline float distance(float X, float Y) {
889 return __detail::distance_impl(X, Y);
890}
891
892template <int N>
893_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
894const inline half distance(vector<half, N> X, vector<half, N> Y) {
896}
897
898template <int N>
899const inline float distance(vector<float, N> X, vector<float, N> Y) {
901}
902
903//===----------------------------------------------------------------------===//
904// dot product builtins
905//===----------------------------------------------------------------------===//
906
907/// \fn K dot(T X, T Y)
908/// \brief Return the dot product (a scalar value) of \a X and \a Y.
909/// \param X The X input value.
910/// \param Y The Y input value.
911
912_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
913_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
914half dot(half, half);
915_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
916_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
918_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
919_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
921_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
922_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
924
925#ifdef __HLSL_ENABLE_16_BIT
926_HLSL_AVAILABILITY(shadermodel, 6.2)
927_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
928int16_t dot(int16_t, int16_t);
929_HLSL_AVAILABILITY(shadermodel, 6.2)
930_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
931int16_t dot(int16_t2, int16_t2);
932_HLSL_AVAILABILITY(shadermodel, 6.2)
933_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
934int16_t dot(int16_t3, int16_t3);
935_HLSL_AVAILABILITY(shadermodel, 6.2)
936_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
937int16_t dot(int16_t4, int16_t4);
938
939_HLSL_AVAILABILITY(shadermodel, 6.2)
940_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
941uint16_t dot(uint16_t, uint16_t);
942_HLSL_AVAILABILITY(shadermodel, 6.2)
943_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
944uint16_t dot(uint16_t2, uint16_t2);
945_HLSL_AVAILABILITY(shadermodel, 6.2)
946_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
947uint16_t dot(uint16_t3, uint16_t3);
948_HLSL_AVAILABILITY(shadermodel, 6.2)
949_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
950uint16_t dot(uint16_t4, uint16_t4);
951#endif
952
953_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
954float dot(float, float);
955_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
957_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
959_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
961
962_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
963double dot(double, double);
964
965_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
966int dot(int, int);
967_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
969_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
971_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
973
974_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
976_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
978_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
980_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
982
983_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
985_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
987_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
989_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
991
992_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
994_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
996_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
998_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
1000
1001//===----------------------------------------------------------------------===//
1002// dot4add builtins
1003//===----------------------------------------------------------------------===//
1004
1005/// \fn int dot4add_i8packed(uint A, uint B, int C)
1006
1007_HLSL_AVAILABILITY(shadermodel, 6.4)
1008_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_i8packed)
1010
1011/// \fn uint dot4add_u8packed(uint A, uint B, uint C)
1012
1013_HLSL_AVAILABILITY(shadermodel, 6.4)
1014_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_u8packed)
1016
1017//===----------------------------------------------------------------------===//
1018// exp builtins
1019//===----------------------------------------------------------------------===//
1020
1021/// \fn T exp(T x)
1022/// \brief Returns the base-e exponential, or \a e**x, of the specified value.
1023/// \param x The specified input value.
1024///
1025/// The return value is the base-e exponential of the \a x parameter.
1026
1027_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1028_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1029half exp(half);
1030_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1031_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1033_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1034_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1036_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1037_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1039
1040_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1041float exp(float);
1042_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1044_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1046_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1048
1049//===----------------------------------------------------------------------===//
1050// exp2 builtins
1051//===----------------------------------------------------------------------===//
1052
1053/// \fn T exp2(T x)
1054/// \brief Returns the base 2 exponential, or \a 2**x, of the specified value.
1055/// \param x The specified input value.
1056///
1057/// The base 2 exponential of the \a x parameter.
1058
1059_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1060_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1061half exp2(half);
1062_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1063_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1065_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1066_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1068_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1069_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1071
1072_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1073float exp2(float);
1074_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1076_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1078_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1080
1081//===----------------------------------------------------------------------===//
1082// firstbithigh builtins
1083//===----------------------------------------------------------------------===//
1084
1085/// \fn T firstbithigh(T Val)
1086/// \brief Returns the location of the first set bit starting from the highest
1087/// order bit and working downward, per component.
1088/// \param Val the input value.
1089
1090#ifdef __HLSL_ENABLE_16_BIT
1091_HLSL_AVAILABILITY(shadermodel, 6.2)
1092_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1093uint firstbithigh(int16_t);
1094_HLSL_AVAILABILITY(shadermodel, 6.2)
1095_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1096uint2 firstbithigh(int16_t2);
1097_HLSL_AVAILABILITY(shadermodel, 6.2)
1098_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1099uint3 firstbithigh(int16_t3);
1100_HLSL_AVAILABILITY(shadermodel, 6.2)
1101_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1102uint4 firstbithigh(int16_t4);
1103_HLSL_AVAILABILITY(shadermodel, 6.2)
1104_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1105uint firstbithigh(uint16_t);
1106_HLSL_AVAILABILITY(shadermodel, 6.2)
1107_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1108uint2 firstbithigh(uint16_t2);
1109_HLSL_AVAILABILITY(shadermodel, 6.2)
1110_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1111uint3 firstbithigh(uint16_t3);
1112_HLSL_AVAILABILITY(shadermodel, 6.2)
1113_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1114uint4 firstbithigh(uint16_t4);
1115#endif
1116
1117_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1119_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1121_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1123_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1125
1126_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1128_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1130_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1132_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1134
1135_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1137_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1139_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1141_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1143
1144_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1146_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1148_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1150_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1152
1153//===----------------------------------------------------------------------===//
1154// floor builtins
1155//===----------------------------------------------------------------------===//
1156
1157/// \fn T floor(T Val)
1158/// \brief Returns the largest integer that is less than or equal to the input
1159/// value, \a Val.
1160/// \param Val The input value.
1161
1162_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1163_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1164half floor(half);
1165_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1166_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1168_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1169_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1171_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1172_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1174
1175_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1176float floor(float);
1177_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1179_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1181_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1183
1184//===----------------------------------------------------------------------===//
1185// fmod builtins
1186//===----------------------------------------------------------------------===//
1187
1188/// \fn T fmod(T x, T y)
1189/// \brief Returns the linear interpolation of x to y.
1190/// \param x [in] The dividend.
1191/// \param y [in] The divisor.
1192///
1193/// Return the floating-point remainder of the x parameter divided by the y
1194/// parameter.
1195
1196_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1197_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1198half fmod(half, half);
1199_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1200_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1202_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1203_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1205_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1206_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1208
1209_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1210float fmod(float, float);
1211_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1213_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1215_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1217
1218//===----------------------------------------------------------------------===//
1219// frac builtins
1220//===----------------------------------------------------------------------===//
1221
1222/// \fn T frac(T x)
1223/// \brief Returns the fractional (or decimal) part of x. \a x parameter.
1224/// \param x The specified input value.
1225///
1226/// If \a the return value is greater than or equal to 0 and less than 1.
1227
1228_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1229_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1230half frac(half);
1231_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1232_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1234_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1235_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1237_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1238_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1240
1241_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1242float frac(float);
1243_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1245_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1247_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1249
1250//===----------------------------------------------------------------------===//
1251// isinf builtins
1252//===----------------------------------------------------------------------===//
1253
1254/// \fn T isinf(T x)
1255/// \brief Determines if the specified value \a x is infinite.
1256/// \param x The specified input value.
1257///
1258/// Returns a value of the same size as the input, with a value set
1259/// to True if the x parameter is +INF or -INF. Otherwise, False.
1260
1261_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1262_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1263bool isinf(half);
1264_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1265_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1267_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1268_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1270_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1271_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1273
1274_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1275bool isinf(float);
1276_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1278_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1280_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1282
1283//===----------------------------------------------------------------------===//
1284// lerp builtins
1285//===----------------------------------------------------------------------===//
1286
1287/// \fn T lerp(T x, T y, T s)
1288/// \brief Returns the linear interpolation of x to y by s.
1289/// \param x [in] The first-floating point value.
1290/// \param y [in] The second-floating point value.
1291/// \param s [in] A value that linearly interpolates between the x parameter and
1292/// the y parameter.
1293///
1294/// Linear interpolation is based on the following formula: x*(1-s) + y*s which
1295/// can equivalently be written as x + s(y-x).
1296
1297_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1298_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1299half lerp(half, half, half);
1300_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1301_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1303_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1304_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1306_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1307_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1309
1310_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1311float lerp(float, float, float);
1312_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1314_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1316_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1318
1319//===----------------------------------------------------------------------===//
1320// length builtins
1321//===----------------------------------------------------------------------===//
1322
1323/// \fn T length(T x)
1324/// \brief Returns the length of the specified floating-point vector.
1325/// \param x [in] The vector of floats, or a scalar float.
1326///
1327/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
1328
1329_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1330const inline half length(half X) { return __detail::length_impl(X); }
1331const inline float length(float X) { return __detail::length_impl(X); }
1332
1333template <int N>
1334_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1335const inline half length(vector<half, N> X) {
1337}
1338
1339template <int N> const inline float length(vector<float, N> X) {
1341}
1342
1343//===----------------------------------------------------------------------===//
1344// log builtins
1345//===----------------------------------------------------------------------===//
1346
1347/// \fn T log(T Val)
1348/// \brief The base-e logarithm of the input value, \a Val parameter.
1349/// \param Val The input value.
1350///
1351/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1352/// function returns negative infinity.
1353
1354_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1355_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1356half log(half);
1357_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1358_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1360_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1361_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1363_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1364_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1366
1367_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1368float log(float);
1369_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1371_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1373_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1375
1376//===----------------------------------------------------------------------===//
1377// log10 builtins
1378//===----------------------------------------------------------------------===//
1379
1380/// \fn T log10(T Val)
1381/// \brief The base-10 logarithm of the input value, \a Val parameter.
1382/// \param Val The input value.
1383///
1384/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1385/// function returns negative infinity.
1386
1387_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1388_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1389half log10(half);
1390_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1391_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1393_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1394_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1396_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1397_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1399
1400_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1401float log10(float);
1402_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1404_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1406_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1408
1409//===----------------------------------------------------------------------===//
1410// log2 builtins
1411//===----------------------------------------------------------------------===//
1412
1413/// \fn T log2(T Val)
1414/// \brief The base-2 logarithm of the input value, \a Val parameter.
1415/// \param Val The input value.
1416///
1417/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1418/// function returns negative infinity.
1419
1420_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1421_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1422half log2(half);
1423_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1424_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1426_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1427_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1429_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1430_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1432
1433_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1434float log2(float);
1435_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1437_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1439_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1441
1442//===----------------------------------------------------------------------===//
1443// mad builtins
1444//===----------------------------------------------------------------------===//
1445
1446/// \fn T mad(T M, T A, T B)
1447/// \brief The result of \a M * \a A + \a B.
1448/// \param M The multiplication value.
1449/// \param A The first addition value.
1450/// \param B The second addition value.
1451
1452_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1453_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1454half mad(half, half, half);
1455_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1456_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1458_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1459_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1461_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1462_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1464
1465#ifdef __HLSL_ENABLE_16_BIT
1466_HLSL_AVAILABILITY(shadermodel, 6.2)
1467_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1468int16_t mad(int16_t, int16_t, int16_t);
1469_HLSL_AVAILABILITY(shadermodel, 6.2)
1470_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1471int16_t2 mad(int16_t2, int16_t2, int16_t2);
1472_HLSL_AVAILABILITY(shadermodel, 6.2)
1473_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1474int16_t3 mad(int16_t3, int16_t3, int16_t3);
1475_HLSL_AVAILABILITY(shadermodel, 6.2)
1476_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1477int16_t4 mad(int16_t4, int16_t4, int16_t4);
1478
1479_HLSL_AVAILABILITY(shadermodel, 6.2)
1480_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1481uint16_t mad(uint16_t, uint16_t, uint16_t);
1482_HLSL_AVAILABILITY(shadermodel, 6.2)
1483_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1484uint16_t2 mad(uint16_t2, uint16_t2, uint16_t2);
1485_HLSL_AVAILABILITY(shadermodel, 6.2)
1486_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1487uint16_t3 mad(uint16_t3, uint16_t3, uint16_t3);
1488_HLSL_AVAILABILITY(shadermodel, 6.2)
1489_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1490uint16_t4 mad(uint16_t4, uint16_t4, uint16_t4);
1491#endif
1492
1493_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1494int mad(int, int, int);
1495_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1497_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1499_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1501
1502_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1504_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1506_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1508_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1510
1511_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1513_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1515_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1517_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1519
1520_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1522_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1524_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1526_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1528
1529_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1530float mad(float, float, float);
1531_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1533_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1535_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1537
1538_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1539double mad(double, double, double);
1540_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1542_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1544_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1546
1547//===----------------------------------------------------------------------===//
1548// max builtins
1549//===----------------------------------------------------------------------===//
1550
1551/// \fn T max(T X, T Y)
1552/// \brief Return the greater of \a X and \a Y.
1553/// \param X The X input value.
1554/// \param Y The Y input value.
1555
1556_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1557_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1558half max(half, half);
1559_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1560_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1562_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1563_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1565_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1566_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1568
1569#ifdef __HLSL_ENABLE_16_BIT
1570_HLSL_AVAILABILITY(shadermodel, 6.2)
1571_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1572int16_t max(int16_t, int16_t);
1573_HLSL_AVAILABILITY(shadermodel, 6.2)
1574_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1575int16_t2 max(int16_t2, int16_t2);
1576_HLSL_AVAILABILITY(shadermodel, 6.2)
1577_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1578int16_t3 max(int16_t3, int16_t3);
1579_HLSL_AVAILABILITY(shadermodel, 6.2)
1580_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1581int16_t4 max(int16_t4, int16_t4);
1582
1583_HLSL_AVAILABILITY(shadermodel, 6.2)
1584_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1585uint16_t max(uint16_t, uint16_t);
1586_HLSL_AVAILABILITY(shadermodel, 6.2)
1587_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1588uint16_t2 max(uint16_t2, uint16_t2);
1589_HLSL_AVAILABILITY(shadermodel, 6.2)
1590_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1591uint16_t3 max(uint16_t3, uint16_t3);
1592_HLSL_AVAILABILITY(shadermodel, 6.2)
1593_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1594uint16_t4 max(uint16_t4, uint16_t4);
1595#endif
1596
1597_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1598int max(int, int);
1599_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1601_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1603_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1605
1606_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1608_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1610_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1612_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1614
1615_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1617_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1619_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1621_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1623
1624_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1626_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1628_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1630_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1632
1633_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1634float max(float, float);
1635_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1637_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1639_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1641
1642_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1643double max(double, double);
1644_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1646_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1648_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1650
1651//===----------------------------------------------------------------------===//
1652// min builtins
1653//===----------------------------------------------------------------------===//
1654
1655/// \fn T min(T X, T Y)
1656/// \brief Return the lesser of \a X and \a Y.
1657/// \param X The X input value.
1658/// \param Y The Y input value.
1659
1660_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1661_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1662half min(half, half);
1663_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1664_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1666_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1667_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1669_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1670_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1672
1673#ifdef __HLSL_ENABLE_16_BIT
1674_HLSL_AVAILABILITY(shadermodel, 6.2)
1675_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1676int16_t min(int16_t, int16_t);
1677_HLSL_AVAILABILITY(shadermodel, 6.2)
1678_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1679int16_t2 min(int16_t2, int16_t2);
1680_HLSL_AVAILABILITY(shadermodel, 6.2)
1681_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1682int16_t3 min(int16_t3, int16_t3);
1683_HLSL_AVAILABILITY(shadermodel, 6.2)
1684_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1685int16_t4 min(int16_t4, int16_t4);
1686
1687_HLSL_AVAILABILITY(shadermodel, 6.2)
1688_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1689uint16_t min(uint16_t, uint16_t);
1690_HLSL_AVAILABILITY(shadermodel, 6.2)
1691_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1692uint16_t2 min(uint16_t2, uint16_t2);
1693_HLSL_AVAILABILITY(shadermodel, 6.2)
1694_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1695uint16_t3 min(uint16_t3, uint16_t3);
1696_HLSL_AVAILABILITY(shadermodel, 6.2)
1697_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1698uint16_t4 min(uint16_t4, uint16_t4);
1699#endif
1700
1701_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1702int min(int, int);
1703_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1705_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1707_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1709
1710_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1712_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1714_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1716_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1718
1719_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1720float min(float, float);
1721_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1723_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1725_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1727
1728_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1730_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1732_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1734_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1736
1737_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1739_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1741_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1743_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1745
1746_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1747double min(double, double);
1748_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1750_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1752_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1754
1755//===----------------------------------------------------------------------===//
1756// normalize builtins
1757//===----------------------------------------------------------------------===//
1758
1759/// \fn T normalize(T x)
1760/// \brief Returns the normalized unit vector of the specified floating-point
1761/// vector. \param x [in] The vector of floats.
1762///
1763/// Normalize is based on the following formula: x / length(x).
1764
1765_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1766_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1767half normalize(half);
1768_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1769_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1771_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1772_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1774_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1775_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1777
1778_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1779float normalize(float);
1780_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1782_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1784_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1786
1787//===----------------------------------------------------------------------===//
1788// pow builtins
1789//===----------------------------------------------------------------------===//
1790
1791/// \fn T pow(T Val, T Pow)
1792/// \brief Return the value \a Val, raised to the power \a Pow.
1793/// \param Val The input value.
1794/// \param Pow The specified power.
1795
1796_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1797_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1798half pow(half, half);
1799_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1800_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1802_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1803_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1805_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1806_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1808
1809_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1810float pow(float, float);
1811_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1813_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1815_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1817
1818//===----------------------------------------------------------------------===//
1819// reversebits builtins
1820//===----------------------------------------------------------------------===//
1821
1822/// \fn T reversebits(T Val)
1823/// \brief Return the value \a Val with the bit order reversed.
1824/// \param Val The input value.
1825
1826#ifdef __HLSL_ENABLE_16_BIT
1827_HLSL_AVAILABILITY(shadermodel, 6.2)
1828_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1829uint16_t reversebits(uint16_t);
1830_HLSL_AVAILABILITY(shadermodel, 6.2)
1831_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1832uint16_t2 reversebits(uint16_t2);
1833_HLSL_AVAILABILITY(shadermodel, 6.2)
1834_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1835uint16_t3 reversebits(uint16_t3);
1836_HLSL_AVAILABILITY(shadermodel, 6.2)
1837_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1838uint16_t4 reversebits(uint16_t4);
1839#endif
1840
1841_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1843_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1845_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1847_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1849
1850_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1852_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1854_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1856_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1858
1859//===----------------------------------------------------------------------===//
1860// cross builtins
1861//===----------------------------------------------------------------------===//
1862
1863/// \fn T cross(T x, T y)
1864/// \brief Returns the cross product of two floating-point, 3D vectors.
1865/// \param x [in] The first floating-point, 3D vector.
1866/// \param y [in] The second floating-point, 3D vector.
1867///
1868/// Result is the cross product of x and y, i.e., the resulting
1869/// components are, in order :
1870/// x[1] * y[2] - y[1] * x[2]
1871/// x[2] * y[0] - y[2] * x[0]
1872/// x[0] * y[1] - y[0] * x[1]
1873
1874_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1875_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1877
1878_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1880
1881//===----------------------------------------------------------------------===//
1882// D3DCOLORtoUBYTE4 builtin
1883//===----------------------------------------------------------------------===//
1884
1885/// \fn T D3DCOLORtoUBYTE4(T x)
1886/// \brief Converts a floating-point, 4D vector set by a D3DCOLOR to a UBYTE4.
1887/// \param x [in] The floating-point vector4 to convert.
1888///
1889/// The return value is the UBYTE4 representation of the \a x parameter.
1890///
1891/// This function swizzles and scales components of the \a x parameter. Use this
1892/// function to compensate for the lack of UBYTE4 support in some hardware.
1893
1894constexpr vector<uint, 4> D3DCOLORtoUBYTE4(vector<float, 4> V) {
1896}
1897
1898//===----------------------------------------------------------------------===//
1899// rcp builtins
1900//===----------------------------------------------------------------------===//
1901
1902/// \fn T rcp(T x)
1903/// \brief Calculates a fast, approximate, per-component reciprocal ie 1 / \a x.
1904/// \param x The specified input value.
1905///
1906/// The return value is the reciprocal of the \a x parameter.
1907
1908_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1909_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1910half rcp(half);
1911_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1912_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1914_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1915_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1917_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1918_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1920
1921_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1922float rcp(float);
1923_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1925_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1927_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1929
1930_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1931double rcp(double);
1932_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1934_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1936_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1938
1939//===----------------------------------------------------------------------===//
1940// rsqrt builtins
1941//===----------------------------------------------------------------------===//
1942
1943/// \fn T rsqrt(T x)
1944/// \brief Returns the reciprocal of the square root of the specified value.
1945/// ie 1 / sqrt( \a x).
1946/// \param x The specified input value.
1947///
1948/// This function uses the following formula: 1 / sqrt(x).
1949
1950_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1951_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1952half rsqrt(half);
1953_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1954_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1956_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1957_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1959_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1960_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1962
1963_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1964float rsqrt(float);
1965_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1967_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1969_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1971
1972//===----------------------------------------------------------------------===//
1973// round builtins
1974//===----------------------------------------------------------------------===//
1975
1976/// \fn T round(T x)
1977/// \brief Rounds the specified value \a x to the nearest integer.
1978/// \param x The specified input value.
1979///
1980/// The return value is the \a x parameter, rounded to the nearest integer
1981/// within a floating-point type. Halfway cases are
1982/// rounded to the nearest even value.
1983
1984_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1985_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1986half round(half);
1987_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1988_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1990_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1991_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1993_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1994_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1996
1997_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1998float round(float);
1999_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
2001_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
2003_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
2005
2006//===----------------------------------------------------------------------===//
2007// saturate builtins
2008//===----------------------------------------------------------------------===//
2009
2010/// \fn T saturate(T Val)
2011/// \brief Returns input value, \a Val, clamped within the range of 0.0f
2012/// to 1.0f. \param Val The input value.
2013
2014_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2015_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2016half saturate(half);
2017_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2018_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2020_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2021_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2023_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2024_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2026
2027_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2028float saturate(float);
2029_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2031_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2033_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2035
2036_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2037double saturate(double);
2038_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2040_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2042_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2044
2045//===----------------------------------------------------------------------===//
2046// select builtins
2047//===----------------------------------------------------------------------===//
2048
2049/// \fn T select(bool Cond, T TrueVal, T FalseVal)
2050/// \brief ternary operator.
2051/// \param Cond The Condition input value.
2052/// \param TrueVal The Value returned if Cond is true.
2053/// \param FalseVal The Value returned if Cond is false.
2054
2055template <typename T>
2056_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
2057T select(bool, T, T);
2058
2059/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
2060/// vector<T,Sz> FalseVals)
2061/// \brief ternary operator for vectors. All vectors must be the same size.
2062/// \param Conds The Condition input values.
2063/// \param TrueVals The vector values are chosen from when conditions are true.
2064/// \param FalseVals The vector values are chosen from when conditions are
2065/// false.
2066
2067template <typename T, int Sz>
2068_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
2069vector<T, Sz> select(vector<bool, Sz>, vector<T, Sz>, vector<T, Sz>);
2070
2071//===----------------------------------------------------------------------===//
2072// sin builtins
2073//===----------------------------------------------------------------------===//
2074
2075/// \fn T sin(T Val)
2076/// \brief Returns the sine of the input value, \a Val.
2077/// \param Val The input value.
2078
2079_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2080_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2081half sin(half);
2082_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2083_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2085_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2086_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2088_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2089_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2091
2092_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2093float sin(float);
2094_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2096_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2098_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2100
2101//===----------------------------------------------------------------------===//
2102// sinh builtins
2103//===----------------------------------------------------------------------===//
2104
2105/// \fn T sinh(T Val)
2106/// \brief Returns the hyperbolic sine of the input value, \a Val.
2107/// \param Val The input value.
2108
2109#ifdef __HLSL_ENABLE_16_BIT
2110_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2111half sinh(half);
2112_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2114_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2116_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2118#endif
2119
2120_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2122_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2124_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2126_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2128
2129//===----------------------------------------------------------------------===//
2130// sqrt builtins
2131//===----------------------------------------------------------------------===//
2132
2133/// \fn T sqrt(T Val)
2134/// \brief Returns the square root of the input value, \a Val.
2135/// \param Val The input value.
2136
2137_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2138_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2139half sqrt(half);
2140_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2141_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2143_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2144_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2146_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2147_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2149
2150_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2151float sqrt(float);
2152_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2154_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2156_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2158
2159//===----------------------------------------------------------------------===//
2160// step builtins
2161//===----------------------------------------------------------------------===//
2162
2163/// \fn T step(T x, T y)
2164/// \brief Returns 1 if the x parameter is greater than or equal to the y
2165/// parameter; otherwise, 0. vector. \param x [in] The first floating-point
2166/// value to compare. \param y [in] The first floating-point value to compare.
2167///
2168/// Step is based on the following formula: (x >= y) ? 1 : 0
2169
2170_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2171_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2172half step(half, half);
2173_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2174_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2176_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2177_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2179_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2180_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2182
2183_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2184float step(float, float);
2185_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2187_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2189_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2191
2192//===----------------------------------------------------------------------===//
2193// tan builtins
2194//===----------------------------------------------------------------------===//
2195
2196/// \fn T tan(T Val)
2197/// \brief Returns the tangent of the input value, \a Val.
2198/// \param Val The input value.
2199
2200#ifdef __HLSL_ENABLE_16_BIT
2201_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2202half tan(half);
2203_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2204half2 tan(half2);
2205_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2206half3 tan(half3);
2207_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2208half4 tan(half4);
2209#endif
2210
2211_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2212float tan(float);
2213_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2215_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2217_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2219
2220//===----------------------------------------------------------------------===//
2221// tanh builtins
2222//===----------------------------------------------------------------------===//
2223
2224/// \fn T tanh(T Val)
2225/// \brief Returns the hyperbolic tangent of the input value, \a Val.
2226/// \param Val The input value.
2227
2228#ifdef __HLSL_ENABLE_16_BIT
2229_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2230half tanh(half);
2231_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2233_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2235_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2237#endif
2238
2239_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2241_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2243_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2245_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2247
2248//===----------------------------------------------------------------------===//
2249// trunc builtins
2250//===----------------------------------------------------------------------===//
2251
2252/// \fn T trunc(T Val)
2253/// \brief Returns the truncated integer value of the input value, \a Val.
2254/// \param Val The input value.
2255
2256_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2257_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2258half trunc(half);
2259_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2260_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2262_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2263_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2265_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2266_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2268
2269_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2270float trunc(float);
2271_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2273_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2275_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2277
2278//===----------------------------------------------------------------------===//
2279// Wave* builtins
2280//===----------------------------------------------------------------------===//
2281
2282/// \brief Returns true if the expression is true in all active lanes in the
2283/// current wave.
2284///
2285/// \param Val The boolean expression to evaluate.
2286/// \return True if the expression is true in all lanes.
2287_HLSL_AVAILABILITY(shadermodel, 6.0)
2288_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_true)
2289__attribute__((convergent)) bool WaveActiveAllTrue(bool Val);
2290
2291/// \brief Returns true if the expression is true in any active lane in the
2292/// current wave.
2293///
2294/// \param Val The boolean expression to evaluate.
2295/// \return True if the expression is true in any lane.
2296_HLSL_AVAILABILITY(shadermodel, 6.0)
2297_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_any_true)
2298__attribute__((convergent)) bool WaveActiveAnyTrue(bool Val);
2299
2300/// \brief Counts the number of boolean variables which evaluate to true across
2301/// all active lanes in the current wave.
2302///
2303/// \param Val The input boolean value.
2304/// \return The number of lanes for which the boolean variable evaluates to
2305/// true, across all active lanes in the current wave.
2306_HLSL_AVAILABILITY(shadermodel, 6.0)
2307_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_count_bits)
2308__attribute__((convergent)) uint WaveActiveCountBits(bool Val);
2309
2310/// \brief Returns the index of the current lane within the current wave.
2311_HLSL_AVAILABILITY(shadermodel, 6.0)
2312_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_get_lane_index)
2313__attribute__((convergent)) uint WaveGetLaneIndex();
2314
2315_HLSL_AVAILABILITY(shadermodel, 6.0)
2316_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane)
2317__attribute__((convergent)) bool WaveIsFirstLane();
2318
2319//===----------------------------------------------------------------------===//
2320// WaveReadLaneAt builtins
2321//===----------------------------------------------------------------------===//
2322
2323// \brief Returns the value of the expression for the given lane index within
2324// the specified wave.
2325
2326_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2327__attribute__((convergent)) bool WaveReadLaneAt(bool, int32_t);
2328_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2329__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, int32_t);
2330_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2331__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, int32_t);
2332_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2333__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, int32_t);
2334
2335#ifdef __HLSL_ENABLE_16_BIT
2336_HLSL_AVAILABILITY(shadermodel, 6.0)
2337_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2338__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, int32_t);
2339_HLSL_AVAILABILITY(shadermodel, 6.0)
2340_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2341__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, int32_t);
2342_HLSL_AVAILABILITY(shadermodel, 6.0)
2343_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2344__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, int32_t);
2345_HLSL_AVAILABILITY(shadermodel, 6.0)
2346_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2347__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, int32_t);
2348#endif
2349
2350_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2351_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2352__attribute__((convergent)) half WaveReadLaneAt(half, int32_t);
2353_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2354_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2355__attribute__((convergent)) half2 WaveReadLaneAt(half2, int32_t);
2356_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2357_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2358__attribute__((convergent)) half3 WaveReadLaneAt(half3, int32_t);
2359_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2360_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2361__attribute__((convergent)) half4 WaveReadLaneAt(half4, int32_t);
2362
2363_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2364__attribute__((convergent)) int WaveReadLaneAt(int, int32_t);
2365_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2366__attribute__((convergent)) int2 WaveReadLaneAt(int2, int32_t);
2367_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2368__attribute__((convergent)) int3 WaveReadLaneAt(int3, int32_t);
2369_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2370__attribute__((convergent)) int4 WaveReadLaneAt(int4, int32_t);
2371
2372_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2373__attribute__((convergent)) float WaveReadLaneAt(float, int32_t);
2374_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2375__attribute__((convergent)) float2 WaveReadLaneAt(float2, int32_t);
2376_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2377__attribute__((convergent)) float3 WaveReadLaneAt(float3, int32_t);
2378_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2379__attribute__((convergent)) float4 WaveReadLaneAt(float4, int32_t);
2380
2381_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2382__attribute__((convergent)) int64_t WaveReadLaneAt(int64_t, int32_t);
2383_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2384__attribute__((convergent)) int64_t2 WaveReadLaneAt(int64_t2, int32_t);
2385_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2386__attribute__((convergent)) int64_t3 WaveReadLaneAt(int64_t3, int32_t);
2387_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2388__attribute__((convergent)) int64_t4 WaveReadLaneAt(int64_t4, int32_t);
2389
2390_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2391__attribute__((convergent)) double WaveReadLaneAt(double, int32_t);
2392_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2393__attribute__((convergent)) double2 WaveReadLaneAt(double2, int32_t);
2394_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2395__attribute__((convergent)) double3 WaveReadLaneAt(double3, int32_t);
2396_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2397__attribute__((convergent)) double4 WaveReadLaneAt(double4, int32_t);
2398
2399//===----------------------------------------------------------------------===//
2400// sign builtins
2401//===----------------------------------------------------------------------===//
2402
2403/// \fn T sign(T Val)
2404/// \brief Returns -1 if \a Val is less than zero; 0 if \a Val equals zero; and
2405/// 1 if \a Val is greater than zero. \param Val The input value.
2406
2407#ifdef __HLSL_ENABLE_16_BIT
2408_HLSL_AVAILABILITY(shadermodel, 6.2)
2409_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2410int sign(int16_t);
2411_HLSL_AVAILABILITY(shadermodel, 6.2)
2412_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2413int2 sign(int16_t2);
2414_HLSL_AVAILABILITY(shadermodel, 6.2)
2415_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2416int3 sign(int16_t3);
2417_HLSL_AVAILABILITY(shadermodel, 6.2)
2418_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2419int4 sign(int16_t4);
2420
2421_HLSL_AVAILABILITY(shadermodel, 6.2)
2422_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2423int sign(uint16_t);
2424_HLSL_AVAILABILITY(shadermodel, 6.2)
2425_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2426int2 sign(uint16_t2);
2427_HLSL_AVAILABILITY(shadermodel, 6.2)
2428_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2429int3 sign(uint16_t3);
2430_HLSL_AVAILABILITY(shadermodel, 6.2)
2431_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2432int4 sign(uint16_t4);
2433#endif
2434
2435_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2436_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2437int sign(half);
2438_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2439_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2441_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2442_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2444_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2445_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2447
2448_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2449int sign(int);
2450_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2452_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2454_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2456
2457_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2459_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2461_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2463_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2465
2466_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2467int sign(float);
2468_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2470_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2472_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2474
2475_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2477_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2479_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2481_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2483
2484_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2486_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2488_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2490_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2492
2493_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2494int sign(double);
2495_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2497_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2499_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2501
2502//===----------------------------------------------------------------------===//
2503// radians builtins
2504//===----------------------------------------------------------------------===//
2505
2506/// \fn T radians(T Val)
2507/// \brief Converts the specified value from degrees to radians.
2508
2509_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2510_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2511half radians(half);
2512_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2513_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2515_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2516_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2518_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2519_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2521
2522_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2523float radians(float);
2524_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2526_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2528_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2530
2531//===----------------------------------------------------------------------===//
2532// GroupMemoryBarrierWithGroupSync builtins
2533//===----------------------------------------------------------------------===//
2534
2535/// \fn void GroupMemoryBarrierWithGroupSync(void)
2536/// \brief Blocks execution of all threads in a group until all group shared
2537/// accesses have been completed and all threads in the group have reached this
2538/// call.
2539
2540_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
2542
2543} // namespace hlsl
2544#endif //_HLSL_HLSL_INTRINSICS_H_
#define V(N, I)
Definition: ASTContext.h:3453
#define X(type, name)
Definition: Value.h:144
_Float16 __2f16 __attribute__((ext_vector_type(2)))
Zeroes the upper 128 bits (bits 255:128) of all YMM registers.
__device__ int
__device__ float
#define _HLSL_BUILTIN_ALIAS(builtin)
#define _HLSL_AVAILABILITY(platform, version)
#define _HLSL_16BIT_AVAILABILITY(environment, version)
constexpr enable_if_t< is_same< float, T >::value||is_same< half, T >::value, T > distance_impl(T X, T Y)
Definition: hlsl_detail.h:69
constexpr vector< uint, 4 > d3d_color_to_ubyte4_impl(vector< float, 4 > V)
Definition: hlsl_detail.h:44
constexpr enable_if_t< is_same< float, T >::value||is_same< half, T >::value, T > distance_vec_impl(vector< T, N > X, vector< T, N > Y)
Definition: hlsl_detail.h:75
constexpr enable_if_t< is_same< float, T >::value||is_same< half, T >::value, T > length_impl(T X)
Definition: hlsl_detail.h:57
constexpr enable_if_t< is_same< float, T >::value||is_same< half, T >::value, T > length_vec_impl(vector< T, N > X)
Definition: hlsl_detail.h:63
int int32_t
int sign(half)
unsigned int uint
half radians(half)
double asdouble(uint, uint)
Reinterprets a cast value (two 32-bit values) into a double.
half normalize(half)
vector< half, 4 > half4
half mad(half, half, half)
bool any(half)
T select(bool, T, T)
ternary operator.
const uint countbits(int x)
vector< half, 2 > half2
vector< uint, 2 > uint2
vector< int, 3 > int3
vector< uint64_t, 2 > uint64_t2
half rsqrt(half)
half max(half, half)
half saturate(half)
half3 cross(half3, half3)
half abs(half)
vector< float, 4 > float4
half dot(half, half)
vector< int64_t, 4 > int64_t4
unsigned long uint64_t
int dot4add_i8packed(uint, uint, int)
vector< uint64_t, 3 > uint64_t3
half lerp(half, half, half)
vector< bool, 4 > bool4
void GroupMemoryBarrierWithGroupSync(void)
Blocks execution of all threads in a group until all group shared accesses have been completed and al...
uint firstbithigh(int)
long int64_t
vector< int64_t, 3 > int64_t3
vector< int, 4 > int4
void clip(float)
constexpr vector< uint, 4 > D3DCOLORtoUBYTE4(vector< float, 4 > V)
vector< bool, 3 > bool3
half clamp(half, half, half)
vector< uint64_t, 4 > uint64_t4
const half length(half X)
half step(half, half)
constexpr vector< uint, N > asuint(vector< T, N > V)
vector< double, 3 > double3
vector< float, 2 > float2
vector< float, 3 > float3
vector< int64_t, 2 > int64_t2
const half distance(half X, half Y)
vector< uint, 3 > uint3
half degrees(half)
half rcp(half)
vector< double, 4 > double4
vector< double, 2 > double2
vector< bool, 2 > bool2
vector< int, 2 > int2
half min(half, half)
uint dot4add_u8packed(uint, uint, uint)
vector< uint, 4 > uint4
vector< half, 3 > half3
half frac(half)
constexpr vector< int, N > asint(vector< T, N > V)
bool all(half)
constexpr vector< float, N > asfloat(vector< T, N > V)
bool isinf(half)
uint reversebits(uint)
unsigned int uint
An unsigned 32-bit integer.
#define sinh(__x)
Definition: tgmath.h:373
#define asin(__x)
Definition: tgmath.h:112
#define sqrt(__x)
Definition: tgmath.h:520
#define acos(__x)
Definition: tgmath.h:83
#define exp(__x)
Definition: tgmath.h:431
#define atan2(__x, __y)
Definition: tgmath.h:566
#define exp2(__x)
Definition: tgmath.h:670
#define sin(__x)
Definition: tgmath.h:286
#define log2(__x)
Definition: tgmath.h:970
#define cosh(__x)
Definition: tgmath.h:344
#define trunc(__x)
Definition: tgmath.h:1216
#define round(__x)
Definition: tgmath.h:1148
#define fmod(__x, __y)
Definition: tgmath.h:798
#define tan(__x)
Definition: tgmath.h:315
#define cos(__x)
Definition: tgmath.h:257
#define log10(__x)
Definition: tgmath.h:936
#define pow(__x, __y)
Definition: tgmath.h:490
#define tanh(__x)
Definition: tgmath.h:402
#define atan(__x)
Definition: tgmath.h:141
#define floor(__x)
Definition: tgmath.h:722
#define ceil(__x)
Definition: tgmath.h:601
#define log(__x)
Definition: tgmath.h:460