Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright 2016 Google Inc. | |
| 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_CONTEXT | |
| 9 #define SKSL_CONTEXT | |
| 10 | |
| 11 #include "ir/SkSLType.h" | |
| 12 | |
| 13 namespace SkSL { | |
| 14 | |
| 15 static std::vector<const Type*> type(const Type& t) { | |
|
dogben
2016/07/14 21:30:04
nit: maybe make this a static method of Context, s
| |
| 16 return { &t, &t, &t, &t }; | |
| 17 } | |
| 18 | |
| 19 /** | |
| 20 * Contains compiler-wide objects, which currently means the core types. | |
| 21 */ | |
| 22 class Context { | |
| 23 public: | |
| 24 Context() | |
| 25 : fVoid_Type(new Type("void")) | |
| 26 , fDouble_Type(new Type("double", true)) | |
| 27 , fDVec2_Type(new Type("dvec2", *fDouble_Type, 2)) | |
| 28 , fDVec3_Type(new Type("dvec3", *fDouble_Type, 3)) | |
| 29 , fDVec4_Type(new Type("dvec4", *fDouble_Type, 4)) | |
| 30 , fFloat_Type(new Type("float", true, { fDouble_Type.get() })) | |
| 31 , fVec2_Type(new Type("vec2", *fFloat_Type, 2)) | |
| 32 , fVec3_Type(new Type("vec3", *fFloat_Type, 3)) | |
| 33 , fVec4_Type(new Type("vec4", *fFloat_Type, 4)) | |
| 34 , fUInt_Type(new Type("uint", true, { fFloat_Type.get(), fDouble_Type.get() })) | |
| 35 , fUVec2_Type(new Type("uvec2", *fUInt_Type, 2)) | |
| 36 , fUVec3_Type(new Type("uvec3", *fUInt_Type, 3)) | |
| 37 , fUVec4_Type(new Type("uvec4", *fUInt_Type, 4)) | |
| 38 , fInt_Type(new Type("int", true, { fUInt_Type.get(), fFloat_Type.get(), fDo uble_Type.get() })) | |
| 39 , fIVec2_Type(new Type("ivec2", *fInt_Type, 2)) | |
| 40 , fIVec3_Type(new Type("ivec3", *fInt_Type, 3)) | |
| 41 , fIVec4_Type(new Type("ivec4", *fInt_Type, 4)) | |
| 42 , fBool_Type(new Type("bool", false)) | |
| 43 , fBVec2_Type(new Type("bvec2", *fBool_Type, 2)) | |
| 44 , fBVec3_Type(new Type("bvec3", *fBool_Type, 3)) | |
| 45 , fBVec4_Type(new Type("bvec4", *fBool_Type, 4)) | |
| 46 , fMat2x2_Type(new Type("mat2", *fFloat_Type, 2, 2)) | |
| 47 , fMat2x3_Type(new Type("mat2x3", *fFloat_Type, 2, 3)) | |
| 48 , fMat2x4_Type(new Type("mat2x4", *fFloat_Type, 2, 4)) | |
| 49 , fMat3x2_Type(new Type("mat3x2", *fFloat_Type, 3, 2)) | |
| 50 , fMat3x3_Type(new Type("mat3", *fFloat_Type, 3, 3)) | |
| 51 , fMat3x4_Type(new Type("mat3x4", *fFloat_Type, 3, 4)) | |
| 52 , fMat4x2_Type(new Type("mat4x2", *fFloat_Type, 4, 2)) | |
| 53 , fMat4x3_Type(new Type("mat4x3", *fFloat_Type, 4, 3)) | |
| 54 , fMat4x4_Type(new Type("mat4", *fFloat_Type, 4, 4)) | |
| 55 , fDMat2x2_Type(new Type("dmat2", *fFloat_Type, 2, 2)) | |
| 56 , fDMat2x3_Type(new Type("dmat2x3", *fFloat_Type, 2, 3)) | |
| 57 , fDMat2x4_Type(new Type("dmat2x4", *fFloat_Type, 2, 4)) | |
| 58 , fDMat3x2_Type(new Type("dmat3x2", *fFloat_Type, 3, 2)) | |
| 59 , fDMat3x3_Type(new Type("dmat3", *fFloat_Type, 3, 3)) | |
| 60 , fDMat3x4_Type(new Type("dmat3x4", *fFloat_Type, 3, 4)) | |
| 61 , fDMat4x2_Type(new Type("dmat4x2", *fFloat_Type, 4, 2)) | |
| 62 , fDMat4x3_Type(new Type("dmat4x3", *fFloat_Type, 4, 3)) | |
| 63 , fDMat4x4_Type(new Type("dmat4", *fFloat_Type, 4, 4)) | |
| 64 , fSampler1D_Type(new Type("sampler1D", SpvDim1D, false, false, false, true) ) | |
| 65 , fSampler2D_Type(new Type("sampler2D", SpvDim2D, false, false, false, true) ) | |
| 66 , fSampler3D_Type(new Type("sampler3D", SpvDim3D, false, false, false, true) ) | |
| 67 , fSamplerCube_Type(new Type("samplerCube")) | |
| 68 , fSampler2DRect_Type(new Type("sampler2DRect")) | |
| 69 , fSampler1DArray_Type(new Type("sampler1DArray")) | |
| 70 , fSampler2DArray_Type(new Type("sampler2DArray")) | |
| 71 , fSamplerCubeArray_Type(new Type("samplerCubeArray")) | |
| 72 , fSamplerBuffer_Type(new Type("samplerBuffer")) | |
| 73 , fSampler2DMS_Type(new Type("sampler2DMS")) | |
| 74 , fSampler2DMSArray_Type(new Type("sampler2DMSArray")) | |
| 75 , fSampler1DShadow_Type(new Type("sampler1DShadow")) | |
| 76 , fSampler2DShadow_Type(new Type("sampler2DShadow")) | |
| 77 , fSamplerCubeShadow_Type(new Type("samplerCubeShadow")) | |
| 78 , fSampler2DRectShadow_Type(new Type("sampler2DRectShadow")) | |
| 79 , fSampler1DArrayShadow_Type(new Type("sampler1DArrayShadow")) | |
| 80 , fSampler2DArrayShadow_Type(new Type("sampler2DArrayShadow")) | |
| 81 , fSamplerCubeArrayShadow_Type(new Type("samplerCubeArrayShadow")) | |
| 82 // FIXME figure out what we're supposed to do with the gsampler et al. types ) | |
| 83 , fGSampler1D_Type(new Type("$gsampler1D", type(*fSampler1D_Type))) | |
| 84 , fGSampler2D_Type(new Type("$gsampler2D", type(*fSampler2D_Type))) | |
| 85 , fGSampler3D_Type(new Type("$gsampler3D", type(*fSampler3D_Type))) | |
| 86 , fGSamplerCube_Type(new Type("$gsamplerCube", type(*fSamplerCube_Type))) | |
| 87 , fGSampler2DRect_Type(new Type("$gsampler2DRect", type(*fSampler2DRect_Type ))) | |
| 88 , fGSampler1DArray_Type(new Type("$gsampler1DArray", type(*fSampler1DArray_T ype))) | |
| 89 , fGSampler2DArray_Type(new Type("$gsampler2DArray", type(*fSampler2DArray_T ype))) | |
| 90 , fGSamplerCubeArray_Type(new Type("$gsamplerCubeArray", type(*fSamplerCubeA rray_Type))) | |
| 91 , fGSamplerBuffer_Type(new Type("$gsamplerBuffer", type(*fSamplerBuffer_Type ))) | |
| 92 , fGSampler2DMS_Type(new Type("$gsampler2DMS", type(*fSampler2DMS_Type))) | |
| 93 , fGSampler2DMSArray_Type(new Type("$gsampler2DMSArray", type(*fSampler2DMSA rray_Type))) | |
| 94 , fGSampler2DArrayShadow_Type(new Type("$gsampler2DArrayShadow", | |
| 95 type(*fSampler2DArrayShadow_Type))) | |
| 96 , fGSamplerCubeArrayShadow_Type(new Type("$gsamplerCubeArrayShadow", | |
| 97 type(*fSamplerCubeArrayShadow_Type) )) | |
| 98 , fGenType_Type(new Type("$genType", { fFloat_Type.get(), fVec2_Type.get(), fVec3_Type.get(), | |
| 99 fVec4_Type.get() })) | |
| 100 , fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDVec2_Type.get (), | |
| 101 fDVec3_Type.get(), fDVec4_Type.get( ) })) | |
| 102 , fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fIVec2_Type.get(), fIVec3_Type.get(), | |
| 103 fIVec4_Type.get() })) | |
| 104 , fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUVec2_Type.get() , fUVec3_Type.get(), | |
| 105 fUVec4_Type.get() })) | |
| 106 , fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBVec2_Type.get() , fBVec3_Type.get(), | |
| 107 fBVec4_Type.get() })) | |
| 108 , fMat_Type(new Type("$mat")) | |
| 109 , fVec_Type(new Type("$vec", { fVec2_Type.get(), fVec2_Type.get(), fVec3_Typ e.get(), | |
| 110 fVec4_Type.get() })) | |
| 111 , fGVec_Type(new Type("$gvec")) | |
| 112 , fGVec2_Type(new Type("$gvec2")) | |
| 113 , fGVec3_Type(new Type("$gvec3")) | |
| 114 , fGVec4_Type(new Type("$gvec4", type(*fVec4_Type))) | |
| 115 , fDVec_Type(new Type("$dvec")) | |
| 116 , fIVec_Type(new Type("$ivec")) | |
| 117 , fUVec_Type(new Type("$uvec")) | |
| 118 , fBVec_Type(new Type("$bvec", { fBVec2_Type.get(), fBVec2_Type.get(), fBVec 3_Type.get(), | |
| 119 fBVec4_Type.get() })) | |
| 120 , fInvalid_Type(new Type("<INVALID>")) {} | |
| 121 | |
| 122 const std::unique_ptr<Type> fVoid_Type; | |
| 123 | |
| 124 const std::unique_ptr<Type> fDouble_Type; | |
| 125 const std::unique_ptr<Type> fDVec2_Type; | |
| 126 const std::unique_ptr<Type> fDVec3_Type; | |
| 127 const std::unique_ptr<Type> fDVec4_Type; | |
| 128 | |
| 129 const std::unique_ptr<Type> fFloat_Type; | |
| 130 const std::unique_ptr<Type> fVec2_Type; | |
| 131 const std::unique_ptr<Type> fVec3_Type; | |
| 132 const std::unique_ptr<Type> fVec4_Type; | |
| 133 | |
| 134 const std::unique_ptr<Type> fUInt_Type; | |
| 135 const std::unique_ptr<Type> fUVec2_Type; | |
| 136 const std::unique_ptr<Type> fUVec3_Type; | |
| 137 const std::unique_ptr<Type> fUVec4_Type; | |
| 138 | |
| 139 const std::unique_ptr<Type> fInt_Type; | |
| 140 const std::unique_ptr<Type> fIVec2_Type; | |
| 141 const std::unique_ptr<Type> fIVec3_Type; | |
| 142 const std::unique_ptr<Type> fIVec4_Type; | |
| 143 | |
| 144 const std::unique_ptr<Type> fBool_Type; | |
| 145 const std::unique_ptr<Type> fBVec2_Type; | |
| 146 const std::unique_ptr<Type> fBVec3_Type; | |
| 147 const std::unique_ptr<Type> fBVec4_Type; | |
| 148 | |
| 149 const std::unique_ptr<Type> fMat2x2_Type; | |
| 150 const std::unique_ptr<Type> fMat2x3_Type; | |
| 151 const std::unique_ptr<Type> fMat2x4_Type; | |
| 152 const std::unique_ptr<Type> fMat3x2_Type; | |
| 153 const std::unique_ptr<Type> fMat3x3_Type; | |
| 154 const std::unique_ptr<Type> fMat3x4_Type; | |
| 155 const std::unique_ptr<Type> fMat4x2_Type; | |
| 156 const std::unique_ptr<Type> fMat4x3_Type; | |
| 157 const std::unique_ptr<Type> fMat4x4_Type; | |
| 158 | |
| 159 const std::unique_ptr<Type> fDMat2x2_Type; | |
| 160 const std::unique_ptr<Type> fDMat2x3_Type; | |
| 161 const std::unique_ptr<Type> fDMat2x4_Type; | |
| 162 const std::unique_ptr<Type> fDMat3x2_Type; | |
| 163 const std::unique_ptr<Type> fDMat3x3_Type; | |
| 164 const std::unique_ptr<Type> fDMat3x4_Type; | |
| 165 const std::unique_ptr<Type> fDMat4x2_Type; | |
| 166 const std::unique_ptr<Type> fDMat4x3_Type; | |
| 167 const std::unique_ptr<Type> fDMat4x4_Type; | |
| 168 | |
| 169 const std::unique_ptr<Type> fSampler1D_Type; | |
| 170 const std::unique_ptr<Type> fSampler2D_Type; | |
| 171 const std::unique_ptr<Type> fSampler3D_Type; | |
| 172 const std::unique_ptr<Type> fSamplerCube_Type; | |
| 173 const std::unique_ptr<Type> fSampler2DRect_Type; | |
| 174 const std::unique_ptr<Type> fSampler1DArray_Type; | |
| 175 const std::unique_ptr<Type> fSampler2DArray_Type; | |
| 176 const std::unique_ptr<Type> fSamplerCubeArray_Type; | |
| 177 const std::unique_ptr<Type> fSamplerBuffer_Type; | |
| 178 const std::unique_ptr<Type> fSampler2DMS_Type; | |
| 179 const std::unique_ptr<Type> fSampler2DMSArray_Type; | |
| 180 const std::unique_ptr<Type> fSampler1DShadow_Type; | |
| 181 const std::unique_ptr<Type> fSampler2DShadow_Type; | |
| 182 const std::unique_ptr<Type> fSamplerCubeShadow_Type; | |
| 183 const std::unique_ptr<Type> fSampler2DRectShadow_Type; | |
| 184 const std::unique_ptr<Type> fSampler1DArrayShadow_Type; | |
| 185 const std::unique_ptr<Type> fSampler2DArrayShadow_Type; | |
| 186 const std::unique_ptr<Type> fSamplerCubeArrayShadow_Type; | |
| 187 | |
| 188 const std::unique_ptr<Type> fGSampler1D_Type; | |
| 189 const std::unique_ptr<Type> fGSampler2D_Type; | |
| 190 const std::unique_ptr<Type> fGSampler3D_Type; | |
| 191 const std::unique_ptr<Type> fGSamplerCube_Type; | |
| 192 const std::unique_ptr<Type> fGSampler2DRect_Type; | |
| 193 const std::unique_ptr<Type> fGSampler1DArray_Type; | |
| 194 const std::unique_ptr<Type> fGSampler2DArray_Type; | |
| 195 const std::unique_ptr<Type> fGSamplerCubeArray_Type; | |
| 196 const std::unique_ptr<Type> fGSamplerBuffer_Type; | |
| 197 const std::unique_ptr<Type> fGSampler2DMS_Type; | |
| 198 const std::unique_ptr<Type> fGSampler2DMSArray_Type; | |
| 199 const std::unique_ptr<Type> fGSampler2DArrayShadow_Type; | |
| 200 const std::unique_ptr<Type> fGSamplerCubeArrayShadow_Type; | |
| 201 | |
| 202 const std::unique_ptr<Type> fGenType_Type; | |
| 203 const std::unique_ptr<Type> fGenDType_Type; | |
| 204 const std::unique_ptr<Type> fGenIType_Type; | |
| 205 const std::unique_ptr<Type> fGenUType_Type; | |
| 206 const std::unique_ptr<Type> fGenBType_Type; | |
| 207 | |
| 208 const std::unique_ptr<Type> fMat_Type; | |
| 209 | |
| 210 const std::unique_ptr<Type> fVec_Type; | |
| 211 | |
| 212 const std::unique_ptr<Type> fGVec_Type; | |
| 213 const std::unique_ptr<Type> fGVec2_Type; | |
| 214 const std::unique_ptr<Type> fGVec3_Type; | |
| 215 const std::unique_ptr<Type> fGVec4_Type; | |
| 216 const std::unique_ptr<Type> fDVec_Type; | |
| 217 const std::unique_ptr<Type> fIVec_Type; | |
| 218 const std::unique_ptr<Type> fUVec_Type; | |
| 219 | |
| 220 const std::unique_ptr<Type> fBVec_Type; | |
| 221 | |
| 222 const std::unique_ptr<Type> fInvalid_Type; | |
| 223 }; | |
| 224 | |
| 225 } // namespace | |
| 226 | |
| 227 #endif | |
| OLD | NEW |