• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SKSL_INTRINSIC_LIST_DEFINED
9 #define SKSL_INTRINSIC_LIST_DEFINED
10 
11 #include "src/core/SkTHash.h"
12 
13 #include <cstdint>
14 #include <initializer_list>
15 #include <string_view>
16 
17 // A list of every intrinsic supported by SkSL.
18 // Using an X-Macro (https://en.wikipedia.org/wiki/X_Macro) to manage the list.
19 #define SKSL_INTRINSIC_LIST          \
20     SKSL_INTRINSIC(abs)              \
21     SKSL_INTRINSIC(acosh)            \
22     SKSL_INTRINSIC(acos)             \
23     SKSL_INTRINSIC(all)              \
24     SKSL_INTRINSIC(any)              \
25     SKSL_INTRINSIC(asinh)            \
26     SKSL_INTRINSIC(asin)             \
27     SKSL_INTRINSIC(atanh)            \
28     SKSL_INTRINSIC(atan)             \
29     SKSL_INTRINSIC(atomicAdd)        \
30     SKSL_INTRINSIC(atomicLoad)       \
31     SKSL_INTRINSIC(atomicStore)      \
32     SKSL_INTRINSIC(bitCount)         \
33     SKSL_INTRINSIC(ceil)             \
34     SKSL_INTRINSIC(clamp)            \
35     SKSL_INTRINSIC(cosh)             \
36     SKSL_INTRINSIC(cos)              \
37     SKSL_INTRINSIC(cross)            \
38     SKSL_INTRINSIC(degrees)          \
39     SKSL_INTRINSIC(determinant)      \
40     SKSL_INTRINSIC(dFdx)             \
41     SKSL_INTRINSIC(dFdy)             \
42     SKSL_INTRINSIC(distance)         \
43     SKSL_INTRINSIC(dot)              \
44     SKSL_INTRINSIC(equal)            \
45     SKSL_INTRINSIC(eval)             \
46     SKSL_INTRINSIC(exp2)             \
47     SKSL_INTRINSIC(exp)              \
48     SKSL_INTRINSIC(faceforward)      \
49     SKSL_INTRINSIC(findLSB)          \
50     SKSL_INTRINSIC(findMSB)          \
51     SKSL_INTRINSIC(floatBitsToInt)   \
52     SKSL_INTRINSIC(floatBitsToUint)  \
53     SKSL_INTRINSIC(floor)            \
54     SKSL_INTRINSIC(fma)              \
55     SKSL_INTRINSIC(fract)            \
56     SKSL_INTRINSIC(frexp)            \
57     SKSL_INTRINSIC(fromLinearSrgb)   \
58     SKSL_INTRINSIC(fwidth)           \
59     SKSL_INTRINSIC(greaterThanEqual) \
60     SKSL_INTRINSIC(greaterThan)      \
61     SKSL_INTRINSIC(height)           \
62     SKSL_INTRINSIC(intBitsToFloat)   \
63     SKSL_INTRINSIC(inversesqrt)      \
64     SKSL_INTRINSIC(inverse)          \
65     SKSL_INTRINSIC(isinf)            \
66     SKSL_INTRINSIC(isnan)            \
67     SKSL_INTRINSIC(ldexp)            \
68     SKSL_INTRINSIC(length)           \
69     SKSL_INTRINSIC(lessThanEqual)    \
70     SKSL_INTRINSIC(lessThan)         \
71     SKSL_INTRINSIC(log2)             \
72     SKSL_INTRINSIC(log)              \
73     SKSL_INTRINSIC(makeSampler2D)    \
74     SKSL_INTRINSIC(matrixCompMult)   \
75     SKSL_INTRINSIC(matrixInverse)    \
76     SKSL_INTRINSIC(max)              \
77     SKSL_INTRINSIC(min)              \
78     SKSL_INTRINSIC(mix)              \
79     SKSL_INTRINSIC(modf)             \
80     SKSL_INTRINSIC(mod)              \
81     SKSL_INTRINSIC(normalize)        \
82     SKSL_INTRINSIC(notEqual)         \
83     SKSL_INTRINSIC(not )             \
84     SKSL_INTRINSIC(outerProduct)     \
85     SKSL_INTRINSIC(packDouble2x32)   \
86     SKSL_INTRINSIC(packHalf2x16)     \
87     SKSL_INTRINSIC(packSnorm2x16)    \
88     SKSL_INTRINSIC(packSnorm4x8)     \
89     SKSL_INTRINSIC(packUnorm2x16)    \
90     SKSL_INTRINSIC(packUnorm4x8)     \
91     SKSL_INTRINSIC(pow)              \
92     SKSL_INTRINSIC(radians)          \
93     SKSL_INTRINSIC(read)             \
94     SKSL_INTRINSIC(reflect)          \
95     SKSL_INTRINSIC(refract)          \
96     SKSL_INTRINSIC(roundEven)        \
97     SKSL_INTRINSIC(round)            \
98     SKSL_INTRINSIC(sample)           \
99     SKSL_INTRINSIC(sampleGrad)       \
100     SKSL_INTRINSIC(sampleLod)        \
101     SKSL_INTRINSIC(saturate)         \
102     SKSL_INTRINSIC(sign)             \
103     SKSL_INTRINSIC(sinh)             \
104     SKSL_INTRINSIC(sin)              \
105     SKSL_INTRINSIC(smoothstep)       \
106     SKSL_INTRINSIC(sqrt)             \
107     SKSL_INTRINSIC(step)             \
108     SKSL_INTRINSIC(storageBarrier)   \
109     SKSL_INTRINSIC(subpassLoad)      \
110     SKSL_INTRINSIC(tanh)             \
111     SKSL_INTRINSIC(tan)              \
112     SKSL_INTRINSIC(toLinearSrgb)     \
113     SKSL_INTRINSIC(transpose)        \
114     SKSL_INTRINSIC(trunc)            \
115     SKSL_INTRINSIC(uintBitsToFloat)  \
116     SKSL_INTRINSIC(unpackDouble2x32) \
117     SKSL_INTRINSIC(unpackHalf2x16)   \
118     SKSL_INTRINSIC(unpackSnorm2x16)  \
119     SKSL_INTRINSIC(unpackSnorm4x8)   \
120     SKSL_INTRINSIC(unpackUnorm2x16)  \
121     SKSL_INTRINSIC(unpackUnorm4x8)   \
122     SKSL_INTRINSIC(width)            \
123     SKSL_INTRINSIC(workgroupBarrier) \
124     SKSL_INTRINSIC(write)
125 
126 namespace SkSL {
127 
128 // The `IntrinsicKind` enum holds every intrinsic supported by SkSL.
129 #define SKSL_INTRINSIC(name) k_##name##_IntrinsicKind,
130 enum IntrinsicKind : int8_t {
131     kNotIntrinsic = -1,
132     SKSL_INTRINSIC_LIST
133 };
134 #undef SKSL_INTRINSIC
135 
136 // Returns a map which allows IntrinsicKind values to be looked up by name.
137 using IntrinsicMap = SkTHashMap<std::string_view, IntrinsicKind>;
138 const IntrinsicMap& GetIntrinsicMap();
139 
140 // Looks up intrinsic functions by name.
141 IntrinsicKind FindIntrinsicKind(std::string_view functionName);
142 
143 }
144 
145 #endif
146