John Stiles | ac01aca | 2021-01-15 11:12:46 -0500 | [diff] [blame] | 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_BUILTIN_TYPES |
| 9 | #define SKSL_BUILTIN_TYPES |
| 10 | |
| 11 | #include <memory> |
| 12 | |
| 13 | #include "src/sksl/ir/SkSLType.h" |
| 14 | |
| 15 | namespace SkSL { |
| 16 | |
| 17 | /** |
| 18 | * Contains the built-in, core types for SkSL. |
| 19 | */ |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 20 | class BuiltinTypes { |
| 21 | public: |
John Stiles | ac01aca | 2021-01-15 11:12:46 -0500 | [diff] [blame] | 22 | BuiltinTypes(); |
| 23 | |
| 24 | const std::unique_ptr<Type> fFloat; |
| 25 | const std::unique_ptr<Type> fFloat2; |
| 26 | const std::unique_ptr<Type> fFloat3; |
| 27 | const std::unique_ptr<Type> fFloat4; |
| 28 | |
| 29 | const std::unique_ptr<Type> fHalf; |
| 30 | const std::unique_ptr<Type> fHalf2; |
| 31 | const std::unique_ptr<Type> fHalf3; |
| 32 | const std::unique_ptr<Type> fHalf4; |
| 33 | |
| 34 | const std::unique_ptr<Type> fInt; |
| 35 | const std::unique_ptr<Type> fInt2; |
| 36 | const std::unique_ptr<Type> fInt3; |
| 37 | const std::unique_ptr<Type> fInt4; |
| 38 | |
| 39 | const std::unique_ptr<Type> fUInt; |
| 40 | const std::unique_ptr<Type> fUInt2; |
| 41 | const std::unique_ptr<Type> fUInt3; |
| 42 | const std::unique_ptr<Type> fUInt4; |
| 43 | |
| 44 | const std::unique_ptr<Type> fShort; |
| 45 | const std::unique_ptr<Type> fShort2; |
| 46 | const std::unique_ptr<Type> fShort3; |
| 47 | const std::unique_ptr<Type> fShort4; |
| 48 | |
| 49 | const std::unique_ptr<Type> fUShort; |
| 50 | const std::unique_ptr<Type> fUShort2; |
| 51 | const std::unique_ptr<Type> fUShort3; |
| 52 | const std::unique_ptr<Type> fUShort4; |
| 53 | |
John Stiles | ac01aca | 2021-01-15 11:12:46 -0500 | [diff] [blame] | 54 | const std::unique_ptr<Type> fBool; |
| 55 | const std::unique_ptr<Type> fBool2; |
| 56 | const std::unique_ptr<Type> fBool3; |
| 57 | const std::unique_ptr<Type> fBool4; |
| 58 | |
| 59 | const std::unique_ptr<Type> fInvalid; |
| 60 | const std::unique_ptr<Type> fVoid; |
| 61 | const std::unique_ptr<Type> fFloatLiteral; |
| 62 | const std::unique_ptr<Type> fIntLiteral; |
| 63 | |
| 64 | const std::unique_ptr<Type> fFloat2x2; |
| 65 | const std::unique_ptr<Type> fFloat2x3; |
| 66 | const std::unique_ptr<Type> fFloat2x4; |
| 67 | const std::unique_ptr<Type> fFloat3x2; |
| 68 | const std::unique_ptr<Type> fFloat3x3; |
| 69 | const std::unique_ptr<Type> fFloat3x4; |
| 70 | const std::unique_ptr<Type> fFloat4x2; |
| 71 | const std::unique_ptr<Type> fFloat4x3; |
| 72 | const std::unique_ptr<Type> fFloat4x4; |
| 73 | |
| 74 | const std::unique_ptr<Type> fHalf2x2; |
| 75 | const std::unique_ptr<Type> fHalf2x3; |
| 76 | const std::unique_ptr<Type> fHalf2x4; |
| 77 | const std::unique_ptr<Type> fHalf3x2; |
| 78 | const std::unique_ptr<Type> fHalf3x3; |
| 79 | const std::unique_ptr<Type> fHalf3x4; |
| 80 | const std::unique_ptr<Type> fHalf4x2; |
| 81 | const std::unique_ptr<Type> fHalf4x3; |
| 82 | const std::unique_ptr<Type> fHalf4x4; |
| 83 | |
| 84 | const std::unique_ptr<Type> fTexture1D; |
| 85 | const std::unique_ptr<Type> fTexture2D; |
| 86 | const std::unique_ptr<Type> fTexture3D; |
| 87 | const std::unique_ptr<Type> fTextureExternalOES; |
| 88 | const std::unique_ptr<Type> fTextureCube; |
| 89 | const std::unique_ptr<Type> fTexture2DRect; |
| 90 | const std::unique_ptr<Type> fITexture2D; |
| 91 | |
| 92 | const std::unique_ptr<Type> fSampler1D; |
| 93 | const std::unique_ptr<Type> fSampler2D; |
| 94 | const std::unique_ptr<Type> fSampler3D; |
| 95 | const std::unique_ptr<Type> fSamplerExternalOES; |
| 96 | const std::unique_ptr<Type> fSampler2DRect; |
| 97 | |
| 98 | const std::unique_ptr<Type> fISampler2D; |
| 99 | const std::unique_ptr<Type> fSampler; |
| 100 | |
John Stiles | ac01aca | 2021-01-15 11:12:46 -0500 | [diff] [blame] | 101 | const std::unique_ptr<Type> fSubpassInput; |
| 102 | const std::unique_ptr<Type> fSubpassInputMS; |
| 103 | |
| 104 | const std::unique_ptr<Type> fGenType; |
| 105 | const std::unique_ptr<Type> fGenHType; |
| 106 | const std::unique_ptr<Type> fGenIType; |
| 107 | const std::unique_ptr<Type> fGenUType; |
| 108 | const std::unique_ptr<Type> fGenBType; |
| 109 | |
| 110 | const std::unique_ptr<Type> fMat; |
| 111 | const std::unique_ptr<Type> fHMat; |
| 112 | const std::unique_ptr<Type> fSquareMat; |
| 113 | const std::unique_ptr<Type> fSquareHMat; |
| 114 | |
| 115 | const std::unique_ptr<Type> fVec; |
| 116 | |
| 117 | const std::unique_ptr<Type> fHVec; |
| 118 | const std::unique_ptr<Type> fDVec; |
| 119 | const std::unique_ptr<Type> fIVec; |
| 120 | const std::unique_ptr<Type> fUVec; |
| 121 | const std::unique_ptr<Type> fSVec; |
| 122 | const std::unique_ptr<Type> fUSVec; |
| 123 | const std::unique_ptr<Type> fByteVec; |
| 124 | const std::unique_ptr<Type> fUByteVec; |
| 125 | |
| 126 | const std::unique_ptr<Type> fBVec; |
| 127 | |
| 128 | const std::unique_ptr<Type> fSkCaps; |
| 129 | const std::unique_ptr<Type> fFragmentProcessor; |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 130 | |
Brian Osman | 14d0096 | 2021-04-02 17:04:35 -0400 | [diff] [blame] | 131 | const std::unique_ptr<Type> fColorFilter; |
| 132 | const std::unique_ptr<Type> fShader; |
| 133 | |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 134 | private: |
John Stiles | ce1a088 | 2021-03-22 10:56:08 -0400 | [diff] [blame] | 135 | static std::unique_ptr<Type> MakeScalarType(const char* name, const char* abbrev, |
John Stiles | 7377afb | 2021-05-27 11:03:33 -0400 | [diff] [blame^] | 136 | Type::NumberKind numberKind, int8_t priority, |
| 137 | int8_t bitWidth); |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 138 | static std::unique_ptr<Type> MakeLiteralType(const char* name, const Type& scalarType, |
John Stiles | 7377afb | 2021-05-27 11:03:33 -0400 | [diff] [blame^] | 139 | int8_t priority); |
John Stiles | ce1a088 | 2021-03-22 10:56:08 -0400 | [diff] [blame] | 140 | static std::unique_ptr<Type> MakeVectorType(const char* name, const char* abbrev, |
| 141 | const Type& componentType, int columns); |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 142 | static std::unique_ptr<Type> MakeGenericType(const char* name, std::vector<const Type*> types); |
John Stiles | ce1a088 | 2021-03-22 10:56:08 -0400 | [diff] [blame] | 143 | static std::unique_ptr<Type> MakeMatrixType(const char* name, const char* abbrev, |
John Stiles | 7377afb | 2021-05-27 11:03:33 -0400 | [diff] [blame^] | 144 | const Type& componentType, int columns, |
| 145 | int8_t rows); |
John Stiles | e6c67c5 | 2021-01-15 12:01:00 -0500 | [diff] [blame] | 146 | static std::unique_ptr<Type> MakeTextureType(const char* name, SpvDim_ dimensions, |
| 147 | bool isDepth, bool isArrayedTexture, |
| 148 | bool isMultisampled, bool isSampled); |
| 149 | static std::unique_ptr<Type> MakeSamplerType(const char* name, const Type& textureType); |
Brian Osman | 42de99b | 2021-04-02 15:28:04 -0400 | [diff] [blame] | 150 | static std::unique_ptr<Type> MakeSpecialType(const char* name, const char* abbrev, |
| 151 | Type::TypeKind typeKind); |
John Stiles | ac01aca | 2021-01-15 11:12:46 -0500 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | } // namespace SkSL |
| 155 | |
| 156 | #endif |