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// dot product builtins
876//===----------------------------------------------------------------------===//
877
878/// \fn K dot(T X, T Y)
879/// \brief Return the dot product (a scalar value) of \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)
884_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
885half dot(half, half);
886_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
887_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
889_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
890_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
892_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
893_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
895
896#ifdef __HLSL_ENABLE_16_BIT
897_HLSL_AVAILABILITY(shadermodel, 6.2)
898_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
899int16_t dot(int16_t, int16_t);
900_HLSL_AVAILABILITY(shadermodel, 6.2)
901_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
902int16_t dot(int16_t2, int16_t2);
903_HLSL_AVAILABILITY(shadermodel, 6.2)
904_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
905int16_t dot(int16_t3, int16_t3);
906_HLSL_AVAILABILITY(shadermodel, 6.2)
907_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
908int16_t dot(int16_t4, int16_t4);
909
910_HLSL_AVAILABILITY(shadermodel, 6.2)
911_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
912uint16_t dot(uint16_t, uint16_t);
913_HLSL_AVAILABILITY(shadermodel, 6.2)
914_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
915uint16_t dot(uint16_t2, uint16_t2);
916_HLSL_AVAILABILITY(shadermodel, 6.2)
917_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
918uint16_t dot(uint16_t3, uint16_t3);
919_HLSL_AVAILABILITY(shadermodel, 6.2)
920_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
921uint16_t dot(uint16_t4, uint16_t4);
922#endif
923
924_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
925float dot(float, float);
926_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
928_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
930_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
932
933_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
934double dot(double, double);
935
936_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
937int dot(int, int);
938_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
940_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
942_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
944
945_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
947_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
949_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
951_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
953
954_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
956_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
958_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
960_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
962
963_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
965_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
967_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
969_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot)
971
972//===----------------------------------------------------------------------===//
973// dot4add builtins
974//===----------------------------------------------------------------------===//
975
976/// \fn int dot4add_i8packed(uint A, uint B, int C)
977
978_HLSL_AVAILABILITY(shadermodel, 6.4)
979_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_i8packed)
981
982/// \fn uint dot4add_u8packed(uint A, uint B, uint C)
983
984_HLSL_AVAILABILITY(shadermodel, 6.4)
985_HLSL_BUILTIN_ALIAS(__builtin_hlsl_dot4add_u8packed)
987
988//===----------------------------------------------------------------------===//
989// exp builtins
990//===----------------------------------------------------------------------===//
991
992/// \fn T exp(T x)
993/// \brief Returns the base-e exponential, or \a e**x, of the specified value.
994/// \param x The specified input value.
995///
996/// The return value is the base-e exponential of the \a x parameter.
997
998_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
999_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1000half exp(half);
1001_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1002_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1004_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1005_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1007_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1008_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1010
1011_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1012float exp(float);
1013_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1015_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1017_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp)
1019
1020//===----------------------------------------------------------------------===//
1021// exp2 builtins
1022//===----------------------------------------------------------------------===//
1023
1024/// \fn T exp2(T x)
1025/// \brief Returns the base 2 exponential, or \a 2**x, of the specified value.
1026/// \param x The specified input value.
1027///
1028/// The base 2 exponential of the \a x parameter.
1029
1030_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1031_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1032half exp2(half);
1033_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1034_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1036_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1037_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1039_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1040_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1042
1043_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1044float exp2(float);
1045_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1047_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1049_HLSL_BUILTIN_ALIAS(__builtin_elementwise_exp2)
1051
1052//===----------------------------------------------------------------------===//
1053// firstbithigh builtins
1054//===----------------------------------------------------------------------===//
1055
1056/// \fn T firstbithigh(T Val)
1057/// \brief Returns the location of the first set bit starting from the highest
1058/// order bit and working downward, per component.
1059/// \param Val the input value.
1060
1061#ifdef __HLSL_ENABLE_16_BIT
1062_HLSL_AVAILABILITY(shadermodel, 6.2)
1063_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1064uint firstbithigh(int16_t);
1065_HLSL_AVAILABILITY(shadermodel, 6.2)
1066_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1067uint2 firstbithigh(int16_t2);
1068_HLSL_AVAILABILITY(shadermodel, 6.2)
1069_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1070uint3 firstbithigh(int16_t3);
1071_HLSL_AVAILABILITY(shadermodel, 6.2)
1072_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1073uint4 firstbithigh(int16_t4);
1074_HLSL_AVAILABILITY(shadermodel, 6.2)
1075_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1076uint firstbithigh(uint16_t);
1077_HLSL_AVAILABILITY(shadermodel, 6.2)
1078_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1079uint2 firstbithigh(uint16_t2);
1080_HLSL_AVAILABILITY(shadermodel, 6.2)
1081_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1082uint3 firstbithigh(uint16_t3);
1083_HLSL_AVAILABILITY(shadermodel, 6.2)
1084_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1085uint4 firstbithigh(uint16_t4);
1086#endif
1087
1088_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1090_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1092_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1094_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1096
1097_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1099_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1101_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1103_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1105
1106_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1108_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1110_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1112_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
1114
1115_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_firstbithigh)
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
1124//===----------------------------------------------------------------------===//
1125// floor builtins
1126//===----------------------------------------------------------------------===//
1127
1128/// \fn T floor(T Val)
1129/// \brief Returns the largest integer that is less than or equal to the input
1130/// value, \a Val.
1131/// \param Val The input value.
1132
1133_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1134_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1135half floor(half);
1136_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1137_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1139_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1140_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1142_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1143_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1145
1146_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1147float floor(float);
1148_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1150_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1152_HLSL_BUILTIN_ALIAS(__builtin_elementwise_floor)
1154
1155//===----------------------------------------------------------------------===//
1156// fmod builtins
1157//===----------------------------------------------------------------------===//
1158
1159/// \fn T fmod(T x, T y)
1160/// \brief Returns the linear interpolation of x to y.
1161/// \param x [in] The dividend.
1162/// \param y [in] The divisor.
1163///
1164/// Return the floating-point remainder of the x parameter divided by the y
1165/// parameter.
1166
1167_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1168_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1169half fmod(half, half);
1170_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1171_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1173_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1174_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1176_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1177_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1179
1180_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1181float fmod(float, float);
1182_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1184_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1186_HLSL_BUILTIN_ALIAS(__builtin_elementwise_fmod)
1188
1189//===----------------------------------------------------------------------===//
1190// frac builtins
1191//===----------------------------------------------------------------------===//
1192
1193/// \fn T frac(T x)
1194/// \brief Returns the fractional (or decimal) part of x. \a x parameter.
1195/// \param x The specified input value.
1196///
1197/// If \a the return value is greater than or equal to 0 and less than 1.
1198
1199_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1200_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1201half frac(half);
1202_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1203_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1205_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1206_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1208_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1209_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1211
1212_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1213float frac(float);
1214_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1216_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1218_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_frac)
1220
1221//===----------------------------------------------------------------------===//
1222// isinf builtins
1223//===----------------------------------------------------------------------===//
1224
1225/// \fn T isinf(T x)
1226/// \brief Determines if the specified value \a x is infinite.
1227/// \param x The specified input value.
1228///
1229/// Returns a value of the same size as the input, with a value set
1230/// to True if the x parameter is +INF or -INF. Otherwise, False.
1231
1232_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1233_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1234bool isinf(half);
1235_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1236_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1238_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1239_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1241_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1242_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1244
1245_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1246bool isinf(float);
1247_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1249_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1251_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_isinf)
1253
1254//===----------------------------------------------------------------------===//
1255// lerp builtins
1256//===----------------------------------------------------------------------===//
1257
1258/// \fn T lerp(T x, T y, T s)
1259/// \brief Returns the linear interpolation of x to y by s.
1260/// \param x [in] The first-floating point value.
1261/// \param y [in] The second-floating point value.
1262/// \param s [in] A value that linearly interpolates between the x parameter and
1263/// the y parameter.
1264///
1265/// Linear interpolation is based on the following formula: x*(1-s) + y*s which
1266/// can equivalently be written as x + s(y-x).
1267
1268_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1269_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1270half lerp(half, half, half);
1271_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1272_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1274_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1275_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1277_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1278_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1280
1281_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1282float lerp(float, float, float);
1283_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1285_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1287_HLSL_BUILTIN_ALIAS(__builtin_hlsl_lerp)
1289
1290//===----------------------------------------------------------------------===//
1291// length builtins
1292//===----------------------------------------------------------------------===//
1293
1294/// \fn T length(T x)
1295/// \brief Returns the length of the specified floating-point vector.
1296/// \param x [in] The vector of floats, or a scalar float.
1297///
1298/// Length is based on the following formula: sqrt(x[0]^2 + x[1]^2 + ...).
1299
1300_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1301_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1302half length(half);
1303_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1304_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1306_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1307_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1309_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1310_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1312
1313_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1314float length(float);
1315_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1317_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1319_HLSL_BUILTIN_ALIAS(__builtin_hlsl_length)
1321
1322//===----------------------------------------------------------------------===//
1323// log builtins
1324//===----------------------------------------------------------------------===//
1325
1326/// \fn T log(T Val)
1327/// \brief The base-e logarithm of the input value, \a Val parameter.
1328/// \param Val The input value.
1329///
1330/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1331/// function returns negative infinity.
1332
1333_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1334_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1335half log(half);
1336_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1337_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1339_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1340_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1342_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1343_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1345
1346_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1347float log(float);
1348_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1350_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1352_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log)
1354
1355//===----------------------------------------------------------------------===//
1356// log10 builtins
1357//===----------------------------------------------------------------------===//
1358
1359/// \fn T log10(T Val)
1360/// \brief The base-10 logarithm of the input value, \a Val parameter.
1361/// \param Val The input value.
1362///
1363/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1364/// function returns negative infinity.
1365
1366_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1367_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1368half log10(half);
1369_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1370_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1372_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1373_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1375_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1376_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1378
1379_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1380float log10(float);
1381_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1383_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1385_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log10)
1387
1388//===----------------------------------------------------------------------===//
1389// log2 builtins
1390//===----------------------------------------------------------------------===//
1391
1392/// \fn T log2(T Val)
1393/// \brief The base-2 logarithm of the input value, \a Val parameter.
1394/// \param Val The input value.
1395///
1396/// If \a Val is negative, this result is undefined. If \a Val is 0, this
1397/// function returns negative infinity.
1398
1399_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1400_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1401half log2(half);
1402_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1403_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1405_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1406_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1408_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1409_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1411
1412_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1413float log2(float);
1414_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1416_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1418_HLSL_BUILTIN_ALIAS(__builtin_elementwise_log2)
1420
1421//===----------------------------------------------------------------------===//
1422// mad builtins
1423//===----------------------------------------------------------------------===//
1424
1425/// \fn T mad(T M, T A, T B)
1426/// \brief The result of \a M * \a A + \a B.
1427/// \param M The multiplication value.
1428/// \param A The first addition value.
1429/// \param B The second addition value.
1430
1431_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1432_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1433half mad(half, half, half);
1434_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1435_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1437_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1438_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1440_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1441_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1443
1444#ifdef __HLSL_ENABLE_16_BIT
1445_HLSL_AVAILABILITY(shadermodel, 6.2)
1446_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1447int16_t mad(int16_t, int16_t, int16_t);
1448_HLSL_AVAILABILITY(shadermodel, 6.2)
1449_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1450int16_t2 mad(int16_t2, int16_t2, int16_t2);
1451_HLSL_AVAILABILITY(shadermodel, 6.2)
1452_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1453int16_t3 mad(int16_t3, int16_t3, int16_t3);
1454_HLSL_AVAILABILITY(shadermodel, 6.2)
1455_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1456int16_t4 mad(int16_t4, int16_t4, int16_t4);
1457
1458_HLSL_AVAILABILITY(shadermodel, 6.2)
1459_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1460uint16_t mad(uint16_t, uint16_t, uint16_t);
1461_HLSL_AVAILABILITY(shadermodel, 6.2)
1462_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1463uint16_t2 mad(uint16_t2, uint16_t2, uint16_t2);
1464_HLSL_AVAILABILITY(shadermodel, 6.2)
1465_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1466uint16_t3 mad(uint16_t3, uint16_t3, uint16_t3);
1467_HLSL_AVAILABILITY(shadermodel, 6.2)
1468_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1469uint16_t4 mad(uint16_t4, uint16_t4, uint16_t4);
1470#endif
1471
1472_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1473int mad(int, int, int);
1474_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1476_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1478_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1480
1481_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1483_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1485_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1487_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1489
1490_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1492_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1494_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1496_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1498
1499_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1501_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1503_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1505_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1507
1508_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1509float mad(float, float, float);
1510_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1512_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1514_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1516
1517_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1518double mad(double, double, double);
1519_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1521_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1523_HLSL_BUILTIN_ALIAS(__builtin_hlsl_mad)
1525
1526//===----------------------------------------------------------------------===//
1527// max builtins
1528//===----------------------------------------------------------------------===//
1529
1530/// \fn T max(T X, T Y)
1531/// \brief Return the greater of \a X and \a Y.
1532/// \param X The X input value.
1533/// \param Y The Y input value.
1534
1535_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1536_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1537half max(half, half);
1538_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1539_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1541_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1542_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1544_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1545_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1547
1548#ifdef __HLSL_ENABLE_16_BIT
1549_HLSL_AVAILABILITY(shadermodel, 6.2)
1550_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1551int16_t max(int16_t, int16_t);
1552_HLSL_AVAILABILITY(shadermodel, 6.2)
1553_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1554int16_t2 max(int16_t2, int16_t2);
1555_HLSL_AVAILABILITY(shadermodel, 6.2)
1556_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1557int16_t3 max(int16_t3, int16_t3);
1558_HLSL_AVAILABILITY(shadermodel, 6.2)
1559_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1560int16_t4 max(int16_t4, int16_t4);
1561
1562_HLSL_AVAILABILITY(shadermodel, 6.2)
1563_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1564uint16_t max(uint16_t, uint16_t);
1565_HLSL_AVAILABILITY(shadermodel, 6.2)
1566_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1567uint16_t2 max(uint16_t2, uint16_t2);
1568_HLSL_AVAILABILITY(shadermodel, 6.2)
1569_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1570uint16_t3 max(uint16_t3, uint16_t3);
1571_HLSL_AVAILABILITY(shadermodel, 6.2)
1572_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1573uint16_t4 max(uint16_t4, uint16_t4);
1574#endif
1575
1576_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1577int max(int, int);
1578_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1580_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1582_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1584
1585_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1587_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1589_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1591_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1593
1594_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1596_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1598_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1600_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1602
1603_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1605_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1607_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1609_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1611
1612_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1613float max(float, float);
1614_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1616_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1618_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1620
1621_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1622double max(double, double);
1623_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1625_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1627_HLSL_BUILTIN_ALIAS(__builtin_elementwise_max)
1629
1630//===----------------------------------------------------------------------===//
1631// min builtins
1632//===----------------------------------------------------------------------===//
1633
1634/// \fn T min(T X, T Y)
1635/// \brief Return the lesser of \a X and \a Y.
1636/// \param X The X input value.
1637/// \param Y The Y input value.
1638
1639_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1640_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1641half min(half, half);
1642_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1643_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1645_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1646_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1648_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1649_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1651
1652#ifdef __HLSL_ENABLE_16_BIT
1653_HLSL_AVAILABILITY(shadermodel, 6.2)
1654_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1655int16_t min(int16_t, int16_t);
1656_HLSL_AVAILABILITY(shadermodel, 6.2)
1657_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1658int16_t2 min(int16_t2, int16_t2);
1659_HLSL_AVAILABILITY(shadermodel, 6.2)
1660_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1661int16_t3 min(int16_t3, int16_t3);
1662_HLSL_AVAILABILITY(shadermodel, 6.2)
1663_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1664int16_t4 min(int16_t4, int16_t4);
1665
1666_HLSL_AVAILABILITY(shadermodel, 6.2)
1667_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1668uint16_t min(uint16_t, uint16_t);
1669_HLSL_AVAILABILITY(shadermodel, 6.2)
1670_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1671uint16_t2 min(uint16_t2, uint16_t2);
1672_HLSL_AVAILABILITY(shadermodel, 6.2)
1673_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1674uint16_t3 min(uint16_t3, uint16_t3);
1675_HLSL_AVAILABILITY(shadermodel, 6.2)
1676_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1677uint16_t4 min(uint16_t4, uint16_t4);
1678#endif
1679
1680_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1681int min(int, int);
1682_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1684_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1686_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1688
1689_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1691_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1693_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1695_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1697
1698_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1699float min(float, float);
1700_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1702_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1704_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1706
1707_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1709_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1711_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1713_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1715
1716_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1718_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1720_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1722_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1724
1725_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1726double min(double, double);
1727_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1729_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1731_HLSL_BUILTIN_ALIAS(__builtin_elementwise_min)
1733
1734//===----------------------------------------------------------------------===//
1735// normalize builtins
1736//===----------------------------------------------------------------------===//
1737
1738/// \fn T normalize(T x)
1739/// \brief Returns the normalized unit vector of the specified floating-point
1740/// vector. \param x [in] The vector of floats.
1741///
1742/// Normalize is based on the following formula: x / length(x).
1743
1744_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1745_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1746half normalize(half);
1747_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1748_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1750_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1751_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1753_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1754_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1756
1757_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1758float normalize(float);
1759_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1761_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1763_HLSL_BUILTIN_ALIAS(__builtin_hlsl_normalize)
1765
1766//===----------------------------------------------------------------------===//
1767// pow builtins
1768//===----------------------------------------------------------------------===//
1769
1770/// \fn T pow(T Val, T Pow)
1771/// \brief Return the value \a Val, raised to the power \a Pow.
1772/// \param Val The input value.
1773/// \param Pow The specified power.
1774
1775_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1776_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1777half pow(half, half);
1778_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1779_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1781_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1782_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1784_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1785_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1787
1788_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1789float pow(float, float);
1790_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1792_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1794_HLSL_BUILTIN_ALIAS(__builtin_elementwise_pow)
1796
1797//===----------------------------------------------------------------------===//
1798// reversebits builtins
1799//===----------------------------------------------------------------------===//
1800
1801/// \fn T reversebits(T Val)
1802/// \brief Return the value \a Val with the bit order reversed.
1803/// \param Val The input value.
1804
1805#ifdef __HLSL_ENABLE_16_BIT
1806_HLSL_AVAILABILITY(shadermodel, 6.2)
1807_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1808uint16_t reversebits(uint16_t);
1809_HLSL_AVAILABILITY(shadermodel, 6.2)
1810_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1811uint16_t2 reversebits(uint16_t2);
1812_HLSL_AVAILABILITY(shadermodel, 6.2)
1813_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1814uint16_t3 reversebits(uint16_t3);
1815_HLSL_AVAILABILITY(shadermodel, 6.2)
1816_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1817uint16_t4 reversebits(uint16_t4);
1818#endif
1819
1820_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1822_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1824_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1826_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1828
1829_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1831_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1833_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1835_HLSL_BUILTIN_ALIAS(__builtin_elementwise_bitreverse)
1837
1838//===----------------------------------------------------------------------===//
1839// cross builtins
1840//===----------------------------------------------------------------------===//
1841
1842/// \fn T cross(T x, T y)
1843/// \brief Returns the cross product of two floating-point, 3D vectors.
1844/// \param x [in] The first floating-point, 3D vector.
1845/// \param y [in] The second floating-point, 3D vector.
1846///
1847/// Result is the cross product of x and y, i.e., the resulting
1848/// components are, in order :
1849/// x[1] * y[2] - y[1] * x[2]
1850/// x[2] * y[0] - y[2] * x[0]
1851/// x[0] * y[1] - y[0] * x[1]
1852
1853_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1854_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1856
1857_HLSL_BUILTIN_ALIAS(__builtin_hlsl_cross)
1859
1860//===----------------------------------------------------------------------===//
1861// rcp builtins
1862//===----------------------------------------------------------------------===//
1863
1864/// \fn T rcp(T x)
1865/// \brief Calculates a fast, approximate, per-component reciprocal ie 1 / \a x.
1866/// \param x The specified input value.
1867///
1868/// The return value is the reciprocal of the \a x parameter.
1869
1870_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1871_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1872half rcp(half);
1873_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1874_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1876_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1877_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1879_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1880_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1882
1883_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1884float rcp(float);
1885_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1887_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1889_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1891
1892_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1893double rcp(double);
1894_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1896_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1898_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
1900
1901//===----------------------------------------------------------------------===//
1902// rsqrt builtins
1903//===----------------------------------------------------------------------===//
1904
1905/// \fn T rsqrt(T x)
1906/// \brief Returns the reciprocal of the square root of the specified value.
1907/// ie 1 / sqrt( \a x).
1908/// \param x The specified input value.
1909///
1910/// This function uses the following formula: 1 / sqrt(x).
1911
1912_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1913_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1914half rsqrt(half);
1915_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1916_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1918_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1919_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1921_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1922_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1924
1925_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1926float rsqrt(float);
1927_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1929_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1931_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rsqrt)
1933
1934//===----------------------------------------------------------------------===//
1935// round builtins
1936//===----------------------------------------------------------------------===//
1937
1938/// \fn T round(T x)
1939/// \brief Rounds the specified value \a x to the nearest integer.
1940/// \param x The specified input value.
1941///
1942/// The return value is the \a x parameter, rounded to the nearest integer
1943/// within a floating-point type. Halfway cases are
1944/// rounded to the nearest even value.
1945
1946_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1947_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1948half round(half);
1949_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1950_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1952_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1953_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1955_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1956_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1958
1959_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1960float round(float);
1961_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1963_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1965_HLSL_BUILTIN_ALIAS(__builtin_elementwise_roundeven)
1967
1968//===----------------------------------------------------------------------===//
1969// saturate builtins
1970//===----------------------------------------------------------------------===//
1971
1972/// \fn T saturate(T Val)
1973/// \brief Returns input value, \a Val, clamped within the range of 0.0f
1974/// to 1.0f. \param Val The input value.
1975
1976_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1977_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1978half saturate(half);
1979_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1980_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1982_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1983_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1985_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
1986_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1988
1989_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1990float saturate(float);
1991_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1993_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1995_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1997
1998_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
1999double saturate(double);
2000_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2002_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2004_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_saturate)
2006
2007//===----------------------------------------------------------------------===//
2008// select builtins
2009//===----------------------------------------------------------------------===//
2010
2011/// \fn T select(bool Cond, T TrueVal, T FalseVal)
2012/// \brief ternary operator.
2013/// \param Cond The Condition input value.
2014/// \param TrueVal The Value returned if Cond is true.
2015/// \param FalseVal The Value returned if Cond is false.
2016
2017template <typename T>
2018_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
2019T select(bool, T, T);
2020
2021/// \fn vector<T,Sz> select(vector<bool,Sz> Conds, vector<T,Sz> TrueVals,
2022/// vector<T,Sz> FalseVals)
2023/// \brief ternary operator for vectors. All vectors must be the same size.
2024/// \param Conds The Condition input values.
2025/// \param TrueVals The vector values are chosen from when conditions are true.
2026/// \param FalseVals The vector values are chosen from when conditions are
2027/// false.
2028
2029template <typename T, int Sz>
2030_HLSL_BUILTIN_ALIAS(__builtin_hlsl_select)
2031vector<T, Sz> select(vector<bool, Sz>, vector<T, Sz>, vector<T, Sz>);
2032
2033//===----------------------------------------------------------------------===//
2034// sin builtins
2035//===----------------------------------------------------------------------===//
2036
2037/// \fn T sin(T Val)
2038/// \brief Returns the sine of the input value, \a Val.
2039/// \param Val The input value.
2040
2041_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2042_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2043half sin(half);
2044_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2045_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2047_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2048_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2050_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2051_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2053
2054_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2055float sin(float);
2056_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2058_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2060_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sin)
2062
2063//===----------------------------------------------------------------------===//
2064// sinh builtins
2065//===----------------------------------------------------------------------===//
2066
2067/// \fn T sinh(T Val)
2068/// \brief Returns the hyperbolic sine of the input value, \a Val.
2069/// \param Val The input value.
2070
2071#ifdef __HLSL_ENABLE_16_BIT
2072_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2073half sinh(half);
2074_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2076_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2078_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2080#endif
2081
2082_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2084_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2086_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2088_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sinh)
2090
2091//===----------------------------------------------------------------------===//
2092// sqrt builtins
2093//===----------------------------------------------------------------------===//
2094
2095/// \fn T sqrt(T Val)
2096/// \brief Returns the square root of the input value, \a Val.
2097/// \param Val The input value.
2098
2099_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2100_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2101half sqrt(half);
2102_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2103_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2105_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2106_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2108_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2109_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2111
2112_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2113float sqrt(float);
2114_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2116_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2118_HLSL_BUILTIN_ALIAS(__builtin_elementwise_sqrt)
2120
2121//===----------------------------------------------------------------------===//
2122// step builtins
2123//===----------------------------------------------------------------------===//
2124
2125/// \fn T step(T x, T y)
2126/// \brief Returns 1 if the x parameter is greater than or equal to the y
2127/// parameter; otherwise, 0. vector. \param x [in] The first floating-point
2128/// value to compare. \param y [in] The first floating-point value to compare.
2129///
2130/// Step is based on the following formula: (x >= y) ? 1 : 0
2131
2132_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2133_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2134half step(half, half);
2135_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2136_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2138_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2139_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2141_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2142_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2144
2145_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2146float step(float, float);
2147_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2149_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2151_HLSL_BUILTIN_ALIAS(__builtin_hlsl_step)
2153
2154//===----------------------------------------------------------------------===//
2155// tan builtins
2156//===----------------------------------------------------------------------===//
2157
2158/// \fn T tan(T Val)
2159/// \brief Returns the tangent of the input value, \a Val.
2160/// \param Val The input value.
2161
2162#ifdef __HLSL_ENABLE_16_BIT
2163_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2164half tan(half);
2165_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2166half2 tan(half2);
2167_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2168half3 tan(half3);
2169_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2170half4 tan(half4);
2171#endif
2172
2173_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2174float tan(float);
2175_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2177_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2179_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tan)
2181
2182//===----------------------------------------------------------------------===//
2183// tanh builtins
2184//===----------------------------------------------------------------------===//
2185
2186/// \fn T tanh(T Val)
2187/// \brief Returns the hyperbolic tangent of the input value, \a Val.
2188/// \param Val The input value.
2189
2190#ifdef __HLSL_ENABLE_16_BIT
2191_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2192half tanh(half);
2193_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2195_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2197_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2199#endif
2200
2201_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2203_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2205_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2207_HLSL_BUILTIN_ALIAS(__builtin_elementwise_tanh)
2209
2210//===----------------------------------------------------------------------===//
2211// trunc builtins
2212//===----------------------------------------------------------------------===//
2213
2214/// \fn T trunc(T Val)
2215/// \brief Returns the truncated integer value of the input value, \a Val.
2216/// \param Val The input value.
2217
2218_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2219_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2220half trunc(half);
2221_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2222_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2224_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2225_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2227_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2228_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2230
2231_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2232float trunc(float);
2233_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2235_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2237_HLSL_BUILTIN_ALIAS(__builtin_elementwise_trunc)
2239
2240//===----------------------------------------------------------------------===//
2241// Wave* builtins
2242//===----------------------------------------------------------------------===//
2243
2244/// \brief Returns true if the expression is true in all active lanes in the
2245/// current wave.
2246///
2247/// \param Val The boolean expression to evaluate.
2248/// \return True if the expression is true in all lanes.
2249_HLSL_AVAILABILITY(shadermodel, 6.0)
2250_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_all_true)
2251__attribute__((convergent)) bool WaveActiveAllTrue(bool Val);
2252
2253/// \brief Returns true if the expression is true in any active lane in the
2254/// current wave.
2255///
2256/// \param Val The boolean expression to evaluate.
2257/// \return True if the expression is true in any lane.
2258_HLSL_AVAILABILITY(shadermodel, 6.0)
2259_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_any_true)
2260__attribute__((convergent)) bool WaveActiveAnyTrue(bool Val);
2261
2262/// \brief Counts the number of boolean variables which evaluate to true across
2263/// all active lanes in the current wave.
2264///
2265/// \param Val The input boolean value.
2266/// \return The number of lanes for which the boolean variable evaluates to
2267/// true, across all active lanes in the current wave.
2268_HLSL_AVAILABILITY(shadermodel, 6.0)
2269_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_active_count_bits)
2270__attribute__((convergent)) uint WaveActiveCountBits(bool Val);
2271
2272/// \brief Returns the index of the current lane within the current wave.
2273_HLSL_AVAILABILITY(shadermodel, 6.0)
2274_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_get_lane_index)
2275__attribute__((convergent)) uint WaveGetLaneIndex();
2276
2277_HLSL_AVAILABILITY(shadermodel, 6.0)
2278_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_is_first_lane)
2279__attribute__((convergent)) bool WaveIsFirstLane();
2280
2281//===----------------------------------------------------------------------===//
2282// WaveReadLaneAt builtins
2283//===----------------------------------------------------------------------===//
2284
2285// \brief Returns the value of the expression for the given lane index within
2286// the specified wave.
2287
2288_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2289__attribute__((convergent)) bool WaveReadLaneAt(bool, int32_t);
2290_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2291__attribute__((convergent)) bool2 WaveReadLaneAt(bool2, int32_t);
2292_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2293__attribute__((convergent)) bool3 WaveReadLaneAt(bool3, int32_t);
2294_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2295__attribute__((convergent)) bool4 WaveReadLaneAt(bool4, int32_t);
2296
2297#ifdef __HLSL_ENABLE_16_BIT
2298_HLSL_AVAILABILITY(shadermodel, 6.0)
2299_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2300__attribute__((convergent)) int16_t WaveReadLaneAt(int16_t, int32_t);
2301_HLSL_AVAILABILITY(shadermodel, 6.0)
2302_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2303__attribute__((convergent)) int16_t2 WaveReadLaneAt(int16_t2, int32_t);
2304_HLSL_AVAILABILITY(shadermodel, 6.0)
2305_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2306__attribute__((convergent)) int16_t3 WaveReadLaneAt(int16_t3, int32_t);
2307_HLSL_AVAILABILITY(shadermodel, 6.0)
2308_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2309__attribute__((convergent)) int16_t4 WaveReadLaneAt(int16_t4, int32_t);
2310#endif
2311
2312_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2313_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2314__attribute__((convergent)) half WaveReadLaneAt(half, int32_t);
2315_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2316_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2317__attribute__((convergent)) half2 WaveReadLaneAt(half2, int32_t);
2318_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2319_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2320__attribute__((convergent)) half3 WaveReadLaneAt(half3, int32_t);
2321_HLSL_16BIT_AVAILABILITY(shadermodel, 6.0)
2322_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2323__attribute__((convergent)) half4 WaveReadLaneAt(half4, int32_t);
2324
2325_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2326__attribute__((convergent)) int WaveReadLaneAt(int, int32_t);
2327_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2328__attribute__((convergent)) int2 WaveReadLaneAt(int2, int32_t);
2329_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2330__attribute__((convergent)) int3 WaveReadLaneAt(int3, int32_t);
2331_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2332__attribute__((convergent)) int4 WaveReadLaneAt(int4, int32_t);
2333
2334_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2335__attribute__((convergent)) float WaveReadLaneAt(float, int32_t);
2336_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2337__attribute__((convergent)) float2 WaveReadLaneAt(float2, int32_t);
2338_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2339__attribute__((convergent)) float3 WaveReadLaneAt(float3, int32_t);
2340_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2341__attribute__((convergent)) float4 WaveReadLaneAt(float4, int32_t);
2342
2343_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2344__attribute__((convergent)) int64_t WaveReadLaneAt(int64_t, int32_t);
2345_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2346__attribute__((convergent)) int64_t2 WaveReadLaneAt(int64_t2, int32_t);
2347_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2348__attribute__((convergent)) int64_t3 WaveReadLaneAt(int64_t3, int32_t);
2349_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2350__attribute__((convergent)) int64_t4 WaveReadLaneAt(int64_t4, int32_t);
2351
2352_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2353__attribute__((convergent)) double WaveReadLaneAt(double, int32_t);
2354_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2355__attribute__((convergent)) double2 WaveReadLaneAt(double2, int32_t);
2356_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2357__attribute__((convergent)) double3 WaveReadLaneAt(double3, int32_t);
2358_HLSL_BUILTIN_ALIAS(__builtin_hlsl_wave_read_lane_at)
2359__attribute__((convergent)) double4 WaveReadLaneAt(double4, int32_t);
2360
2361//===----------------------------------------------------------------------===//
2362// sign builtins
2363//===----------------------------------------------------------------------===//
2364
2365/// \fn T sign(T Val)
2366/// \brief Returns -1 if \a Val is less than zero; 0 if \a Val equals zero; and
2367/// 1 if \a Val is greater than zero. \param Val The input value.
2368
2369#ifdef __HLSL_ENABLE_16_BIT
2370_HLSL_AVAILABILITY(shadermodel, 6.2)
2371_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2372int sign(int16_t);
2373_HLSL_AVAILABILITY(shadermodel, 6.2)
2374_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2375int2 sign(int16_t2);
2376_HLSL_AVAILABILITY(shadermodel, 6.2)
2377_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2378int3 sign(int16_t3);
2379_HLSL_AVAILABILITY(shadermodel, 6.2)
2380_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2381int4 sign(int16_t4);
2382
2383_HLSL_AVAILABILITY(shadermodel, 6.2)
2384_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2385int sign(uint16_t);
2386_HLSL_AVAILABILITY(shadermodel, 6.2)
2387_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2388int2 sign(uint16_t2);
2389_HLSL_AVAILABILITY(shadermodel, 6.2)
2390_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2391int3 sign(uint16_t3);
2392_HLSL_AVAILABILITY(shadermodel, 6.2)
2393_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2394int4 sign(uint16_t4);
2395#endif
2396
2397_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2398_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2399int sign(half);
2400_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2401_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2403_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2404_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2406_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2407_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2409
2410_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2411int sign(int);
2412_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2414_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2416_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2418
2419_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2421_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2423_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2425_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2427
2428_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2429int sign(float);
2430_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2432_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2434_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2436
2437_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2439_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2441_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2443_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2445
2446_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2448_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2450_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2452_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2454
2455_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_sign)
2456int sign(double);
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
2464//===----------------------------------------------------------------------===//
2465// radians builtins
2466//===----------------------------------------------------------------------===//
2467
2468/// \fn T radians(T Val)
2469/// \brief Converts the specified value from degrees to radians.
2470
2471_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2472_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2473half radians(half);
2474_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2475_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2477_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2478_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2480_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2481_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2483
2484_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2485float radians(float);
2486_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2488_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2490_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_radians)
2492
2493//===----------------------------------------------------------------------===//
2494// GroupMemoryBarrierWithGroupSync builtins
2495//===----------------------------------------------------------------------===//
2496
2497/// \fn void GroupMemoryBarrierWithGroupSync(void)
2498/// \brief Blocks execution of all threads in a group until all group shared
2499/// accesses have been completed and all threads in the group have reached this
2500/// call.
2501
2502_HLSL_BUILTIN_ALIAS(__builtin_hlsl_group_memory_barrier_with_group_sync)
2504
2505} // namespace hlsl
2506#endif //_HLSL_HLSL_INTRINSICS_H_
#define V(N, I)
Definition: ASTContext.h:3443
_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)
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)
vector< bool, 3 > bool3
half clamp(half, half, half)
vector< uint64_t, 4 > uint64_t4
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
half length(half)
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