| 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(intBitsToFloat) \ |
| 62 |
SKSL_INTRINSIC(inversesqrt) \ |
| 63 |
SKSL_INTRINSIC(inverse) \ |
| 64 |
SKSL_INTRINSIC(isinf) \ |
| 65 |
SKSL_INTRINSIC(isnan) \ |
| 66 |
SKSL_INTRINSIC(ldexp) \ |
| 67 |
SKSL_INTRINSIC(length) \ |
| 68 |
SKSL_INTRINSIC(lessThanEqual) \ |
| 69 |
SKSL_INTRINSIC(lessThan) \ |
| 70 |
SKSL_INTRINSIC(log2) \ |
| 71 |
SKSL_INTRINSIC(log) \ |
| 72 |
SKSL_INTRINSIC(matrixCompMult) \ |
| 73 |
SKSL_INTRINSIC(matrixInverse) \ |
| 74 |
SKSL_INTRINSIC(max) \ |
| 75 |
SKSL_INTRINSIC(min) \ |
| 76 |
SKSL_INTRINSIC(mix) \ |
| 77 |
SKSL_INTRINSIC(modf) \ |
| 78 |
SKSL_INTRINSIC(mod) \ |
| 79 |
SKSL_INTRINSIC(normalize) \ |
| 80 |
SKSL_INTRINSIC(notEqual) \ |
| 81 |
SKSL_INTRINSIC(not ) \ |
| 82 |
SKSL_INTRINSIC(outerProduct) \ |
| 83 |
SKSL_INTRINSIC(packHalf2x16) \ |
| 84 |
SKSL_INTRINSIC(packSnorm2x16) \ |
| 85 |
SKSL_INTRINSIC(packSnorm4x8) \ |
| 86 |
SKSL_INTRINSIC(packUnorm2x16) \ |
| 87 |
SKSL_INTRINSIC(packUnorm4x8) \ |
| 88 |
SKSL_INTRINSIC(pow) \ |
| 89 |
SKSL_INTRINSIC(radians) \ |
| 90 |
SKSL_INTRINSIC(reflect) \ |
| 91 |
SKSL_INTRINSIC(refract) \ |
| 92 |
SKSL_INTRINSIC(roundEven) \ |
| 93 |
SKSL_INTRINSIC(round) \ |
| 94 |
SKSL_INTRINSIC(sample) \ |
| 95 |
SKSL_INTRINSIC(sampleGrad) \ |
| 96 |
SKSL_INTRINSIC(sampleLod) \ |
| 97 |
SKSL_INTRINSIC(saturate) \ |
| 98 |
SKSL_INTRINSIC(sign) \ |
| 99 |
SKSL_INTRINSIC(sinh) \ |
| 100 |
SKSL_INTRINSIC(sin) \ |
| 101 |
SKSL_INTRINSIC(smoothstep) \ |
| 102 |
SKSL_INTRINSIC(sqrt) \ |
| 103 |
SKSL_INTRINSIC(step) \ |
| 104 |
SKSL_INTRINSIC(storageBarrier) \ |
| 105 |
SKSL_INTRINSIC(subpassLoad) \ |
| 106 |
SKSL_INTRINSIC(tanh) \ |
| 107 |
SKSL_INTRINSIC(tan) \ |
| 108 |
SKSL_INTRINSIC(textureHeight) \ |
| 109 |
SKSL_INTRINSIC(textureRead) \ |
| 110 |
SKSL_INTRINSIC(textureWidth) \ |
| 111 |
SKSL_INTRINSIC(textureWrite) \ |
| 112 |
SKSL_INTRINSIC(toLinearSrgb) \ |
| 113 |
SKSL_INTRINSIC(transpose) \ |
| 114 |
SKSL_INTRINSIC(trunc) \ |
| 115 |
SKSL_INTRINSIC(uintBitsToFloat) \ |
| 116 |
SKSL_INTRINSIC(unpackHalf2x16) \ |
| 117 |
SKSL_INTRINSIC(unpackSnorm2x16) \ |
| 118 |
SKSL_INTRINSIC(unpackSnorm4x8) \ |
| 119 |
SKSL_INTRINSIC(unpackUnorm2x16) \ |
| 120 |
SKSL_INTRINSIC(unpackUnorm4x8) \ |
| 121 |
SKSL_INTRINSIC(workgroupBarrier) |
| 122 |
|
| 123 |
namespace SkSL { |
| 124 |
|
| 125 |
// The `IntrinsicKind` enum holds every intrinsic supported by SkSL. |
| 126 |
#define SKSL_INTRINSIC(name) k_##name##_IntrinsicKind, |
| 127 |
enum IntrinsicKind : int8_t { |
| 128 |
kNotIntrinsic = -1, |
| 129 |
SKSL_INTRINSIC_LIST |
| 130 |
}; |
| 131 |
#undef SKSL_INTRINSIC |
| 132 |
|
| 133 |
// Returns a map which allows IntrinsicKind values to be looked up by name. |
| 134 |
using IntrinsicMap = skia_private::THashMap<std::string_view, IntrinsicKind>; |
| 135 |
const IntrinsicMap& GetIntrinsicMap(); |
| 136 |
|
| 137 |
// Looks up intrinsic functions by name. |
| 138 |
IntrinsicKind FindIntrinsicKind(std::string_view functionName); |
| 139 |
|
| 140 |
} |
| 141 |
|
| 142 |
#endif |