ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 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 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 8 | #ifndef SKSL_CONTEXT |
| 9 | #define SKSL_CONTEXT |
| 10 | |
| 11 | #include "ir/SkSLType.h" |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 12 | #include "ir/SkSLExpression.h" |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
| 17 | * Contains compiler-wide objects, which currently means the core types. |
| 18 | */ |
| 19 | class Context { |
| 20 | public: |
| 21 | Context() |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 22 | : fInvalid_Type(new Type("<INVALID>")) |
| 23 | , fVoid_Type(new Type("void")) |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 24 | , fFloatLiteral_Type(new Type("$floatLiteral", Type::kFloat_NumberKind, 3)) |
| 25 | , fIntLiteral_Type(new Type("$intLiteral", Type::kSigned_NumberKind, 1)) |
| 26 | , fDouble_Type(new Type("double", Type::kFloat_NumberKind, 6)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 27 | , fDouble2_Type(new Type("double2", *fDouble_Type, 2)) |
| 28 | , fDouble3_Type(new Type("double3", *fDouble_Type, 3)) |
| 29 | , fDouble4_Type(new Type("double4", *fDouble_Type, 4)) |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 30 | , fFloat_Type(new Type("float", Type::kFloat_NumberKind, 5)) |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 31 | , fFloat2_Type(new Type("float2", *fFloat_Type, 2)) |
| 32 | , fFloat3_Type(new Type("float3", *fFloat_Type, 3)) |
| 33 | , fFloat4_Type(new Type("float4", *fFloat_Type, 4)) |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 34 | , fHalf_Type(new Type("half", Type::kFloat_NumberKind, 4)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 35 | , fHalf2_Type(new Type("half2", *fHalf_Type, 2)) |
| 36 | , fHalf3_Type(new Type("half3", *fHalf_Type, 3)) |
| 37 | , fHalf4_Type(new Type("half4", *fHalf_Type, 4)) |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 38 | , fUInt_Type(new Type("uint", Type::kUnsigned_NumberKind, 2)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 39 | , fUInt2_Type(new Type("uint2", *fUInt_Type, 2)) |
| 40 | , fUInt3_Type(new Type("uint3", *fUInt_Type, 3)) |
| 41 | , fUInt4_Type(new Type("uint4", *fUInt_Type, 4)) |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 42 | , fInt_Type(new Type("int", Type::kSigned_NumberKind, 2)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 43 | , fInt2_Type(new Type("int2", *fInt_Type, 2)) |
| 44 | , fInt3_Type(new Type("int3", *fInt_Type, 3)) |
| 45 | , fInt4_Type(new Type("int4", *fInt_Type, 4)) |
Ethan Nicholas | f7b8820 | 2017-09-18 14:10:39 -0400 | [diff] [blame] | 46 | , fUShort_Type(new Type("ushort", Type::kUnsigned_NumberKind, 0)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 47 | , fUShort2_Type(new Type("ushort2", *fUShort_Type, 2)) |
| 48 | , fUShort3_Type(new Type("ushort3", *fUShort_Type, 3)) |
| 49 | , fUShort4_Type(new Type("ushort4", *fUShort_Type, 4)) |
Ethan Nicholas | f7b8820 | 2017-09-18 14:10:39 -0400 | [diff] [blame] | 50 | , fShort_Type(new Type("short", Type::kSigned_NumberKind, 0)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 51 | , fShort2_Type(new Type("short2", *fShort_Type, 2)) |
| 52 | , fShort3_Type(new Type("short3", *fShort_Type, 3)) |
| 53 | , fShort4_Type(new Type("short4", *fShort_Type, 4)) |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame] | 54 | , fUByte_Type(new Type("ubyte", Type::kUnsigned_NumberKind, 0)) |
| 55 | , fUByte2_Type(new Type("ubyte2", *fUByte_Type, 2)) |
| 56 | , fUByte3_Type(new Type("ubyte3", *fUByte_Type, 3)) |
| 57 | , fUByte4_Type(new Type("ubyte4", *fUByte_Type, 4)) |
| 58 | , fByte_Type(new Type("byte", Type::kSigned_NumberKind, 0)) |
| 59 | , fByte2_Type(new Type("byte2", *fByte_Type, 2)) |
| 60 | , fByte3_Type(new Type("byte3", *fByte_Type, 3)) |
| 61 | , fByte4_Type(new Type("byte4", *fByte_Type, 4)) |
Ethan Nicholas | f7b8820 | 2017-09-18 14:10:39 -0400 | [diff] [blame] | 62 | , fBool_Type(new Type("bool", Type::kNonnumeric_NumberKind, -1)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 63 | , fBool2_Type(new Type("bool2", *fBool_Type, 2)) |
| 64 | , fBool3_Type(new Type("bool3", *fBool_Type, 3)) |
| 65 | , fBool4_Type(new Type("bool4", *fBool_Type, 4)) |
Ethan Nicholas | 8aa4569 | 2017-09-20 11:24:15 -0400 | [diff] [blame] | 66 | , fFloat2x2_Type(new Type("float2x2", *fFloat_Type, 2, 2)) |
| 67 | , fFloat2x3_Type(new Type("float2x3", *fFloat_Type, 2, 3)) |
| 68 | , fFloat2x4_Type(new Type("float2x4", *fFloat_Type, 2, 4)) |
| 69 | , fFloat3x2_Type(new Type("float3x2", *fFloat_Type, 3, 2)) |
| 70 | , fFloat3x3_Type(new Type("float3x3", *fFloat_Type, 3, 3)) |
| 71 | , fFloat3x4_Type(new Type("float3x4", *fFloat_Type, 3, 4)) |
| 72 | , fFloat4x2_Type(new Type("float4x2", *fFloat_Type, 4, 2)) |
| 73 | , fFloat4x3_Type(new Type("float4x3", *fFloat_Type, 4, 3)) |
| 74 | , fFloat4x4_Type(new Type("float4x4", *fFloat_Type, 4, 4)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 75 | , fHalf2x2_Type(new Type("half2x2", *fHalf_Type, 2, 2)) |
| 76 | , fHalf2x3_Type(new Type("half2x3", *fHalf_Type, 2, 3)) |
| 77 | , fHalf2x4_Type(new Type("half2x4", *fHalf_Type, 2, 4)) |
| 78 | , fHalf3x2_Type(new Type("half3x2", *fHalf_Type, 3, 2)) |
| 79 | , fHalf3x3_Type(new Type("half3x3", *fHalf_Type, 3, 3)) |
| 80 | , fHalf3x4_Type(new Type("half3x4", *fHalf_Type, 3, 4)) |
| 81 | , fHalf4x2_Type(new Type("half4x2", *fHalf_Type, 4, 2)) |
| 82 | , fHalf4x3_Type(new Type("half4x3", *fHalf_Type, 4, 3)) |
| 83 | , fHalf4x4_Type(new Type("half4x4", *fHalf_Type, 4, 4)) |
| 84 | , fDouble2x2_Type(new Type("double2x2", *fDouble_Type, 2, 2)) |
| 85 | , fDouble2x3_Type(new Type("double2x3", *fDouble_Type, 2, 3)) |
| 86 | , fDouble2x4_Type(new Type("double2x4", *fDouble_Type, 2, 4)) |
| 87 | , fDouble3x2_Type(new Type("double3x2", *fDouble_Type, 3, 2)) |
| 88 | , fDouble3x3_Type(new Type("double3x3", *fDouble_Type, 3, 3)) |
| 89 | , fDouble3x4_Type(new Type("double3x4", *fDouble_Type, 3, 4)) |
| 90 | , fDouble4x2_Type(new Type("double4x2", *fDouble_Type, 4, 2)) |
| 91 | , fDouble4x3_Type(new Type("double4x3", *fDouble_Type, 4, 3)) |
| 92 | , fDouble4x4_Type(new Type("double4x4", *fDouble_Type, 4, 4)) |
| 93 | , fSampler1D_Type(new Type("sampler1D", SpvDim1D, false, false, false, true)) |
| 94 | , fSampler2D_Type(new Type("sampler2D", SpvDim2D, false, false, false, true)) |
| 95 | , fSampler3D_Type(new Type("sampler3D", SpvDim3D, false, false, false, true)) |
| 96 | , fSamplerExternalOES_Type(new Type("samplerExternalOES", SpvDim2D, false, false, |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame] | 97 | false, true)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 98 | , fSamplerCube_Type(new Type("samplerCube", SpvDimCube, false, false, false, true)) |
| 99 | , fSampler2DRect_Type(new Type("sampler2DRect", SpvDimRect, false, false, false, true)) |
| 100 | , fSampler1DArray_Type(new Type("sampler1DArray")) |
| 101 | , fSampler2DArray_Type(new Type("sampler2DArray")) |
| 102 | , fSamplerCubeArray_Type(new Type("samplerCubeArray")) |
| 103 | , fSamplerBuffer_Type(new Type("samplerBuffer", SpvDimBuffer, false, false, false, |
Ethan Nicholas | 0187ae6 | 2017-05-03 11:03:44 -0400 | [diff] [blame] | 104 | true)) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 105 | , fSampler2DMS_Type(new Type("sampler2DMS")) |
| 106 | , fSampler2DMSArray_Type(new Type("sampler2DMSArray")) |
| 107 | , fSampler1DShadow_Type(new Type("sampler1DShadow")) |
| 108 | , fSampler2DShadow_Type(new Type("sampler2DShadow")) |
| 109 | , fSamplerCubeShadow_Type(new Type("samplerCubeShadow")) |
| 110 | , fSampler2DRectShadow_Type(new Type("sampler2DRectShadow")) |
| 111 | , fSampler1DArrayShadow_Type(new Type("sampler1DArrayShadow")) |
| 112 | , fSampler2DArrayShadow_Type(new Type("sampler2DArrayShadow")) |
| 113 | , fSamplerCubeArrayShadow_Type(new Type("samplerCubeArrayShadow")) |
Brian Salomon | 2a51de8 | 2016-11-16 12:06:01 -0500 | [diff] [blame] | 114 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 115 | // Related to below FIXME, gsampler*s don't currently expand to cover integer case. |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 116 | , fISampler2D_Type(new Type("isampler2D", SpvDim2D, false, false, false, true)) |
Brian Salomon | 2a51de8 | 2016-11-16 12:06:01 -0500 | [diff] [blame] | 117 | |
| 118 | // FIXME express these as "gimage2D" that expand to image2D, iimage2D, and uimage2D. |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 119 | , fImage2D_Type(new Type("image2D", SpvDim2D, false, false, false, true)) |
| 120 | , fIImage2D_Type(new Type("iimage2D", SpvDim2D, false, false, false, true)) |
Brian Salomon | 2a51de8 | 2016-11-16 12:06:01 -0500 | [diff] [blame] | 121 | |
Greg Daniel | 64773e6 | 2016-11-22 09:44:03 -0500 | [diff] [blame] | 122 | // FIXME express these as "gsubpassInput" that expand to subpassInput, isubpassInput, |
| 123 | // and usubpassInput. |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 124 | , fSubpassInput_Type(new Type("subpassInput", SpvDimSubpassData, false, false, |
| 125 | false, false)) |
| 126 | , fSubpassInputMS_Type(new Type("subpassInputMS", SpvDimSubpassData, false, false, |
| 127 | true, false)) |
Greg Daniel | 64773e6 | 2016-11-22 09:44:03 -0500 | [diff] [blame] | 128 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 129 | // FIXME figure out what we're supposed to do with the gsampler et al. types) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 130 | , fGSampler1D_Type(new Type("$gsampler1D", static_type(*fSampler1D_Type))) |
| 131 | , fGSampler2D_Type(new Type("$gsampler2D", static_type(*fSampler2D_Type))) |
| 132 | , fGSampler3D_Type(new Type("$gsampler3D", static_type(*fSampler3D_Type))) |
| 133 | , fGSamplerCube_Type(new Type("$gsamplerCube", static_type(*fSamplerCube_Type))) |
| 134 | , fGSampler2DRect_Type(new Type("$gsampler2DRect", static_type(*fSampler2DRect_Type))) |
| 135 | , fGSampler1DArray_Type(new Type("$gsampler1DArray", |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame] | 136 | static_type(*fSampler1DArray_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 137 | , fGSampler2DArray_Type(new Type("$gsampler2DArray", |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame] | 138 | static_type(*fSampler2DArray_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 139 | , fGSamplerCubeArray_Type(new Type("$gsamplerCubeArray", |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame] | 140 | static_type(*fSamplerCubeArray_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 141 | , fGSamplerBuffer_Type(new Type("$gsamplerBuffer", static_type(*fSamplerBuffer_Type))) |
| 142 | , fGSampler2DMS_Type(new Type("$gsampler2DMS", static_type(*fSampler2DMS_Type))) |
| 143 | , fGSampler2DMSArray_Type(new Type("$gsampler2DMSArray", |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame] | 144 | static_type(*fSampler2DMSArray_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 145 | , fGSampler2DArrayShadow_Type(new Type("$gsampler2DArrayShadow", |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 146 | static_type(*fSampler2DArrayShadow_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 147 | , fGSamplerCubeArrayShadow_Type(new Type("$gsamplerCubeArrayShadow", |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 148 | static_type(*fSamplerCubeArrayShadow_Type))) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 149 | , fGenType_Type(new Type("$genType", { fFloat_Type.get(), fFloat2_Type.get(), |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 150 | fFloat3_Type.get(), fFloat4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 151 | , fGenHType_Type(new Type("$genHType", { fHalf_Type.get(), fHalf2_Type.get(), |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 152 | fHalf3_Type.get(), fHalf4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 153 | , fGenDType_Type(new Type("$genDType", { fDouble_Type.get(), fDouble2_Type.get(), |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 154 | fDouble3_Type.get(), fDouble4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 155 | , fGenIType_Type(new Type("$genIType", { fInt_Type.get(), fInt2_Type.get(), |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 156 | fInt3_Type.get(), fInt4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 157 | , fGenUType_Type(new Type("$genUType", { fUInt_Type.get(), fUInt2_Type.get(), |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 158 | fUInt3_Type.get(), fUInt4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 159 | , fGenBType_Type(new Type("$genBType", { fBool_Type.get(), fBool2_Type.get(), |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 160 | fBool3_Type.get(), fBool4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 161 | , fMat_Type(new Type("$mat", { fFloat2x2_Type.get(), fFloat2x3_Type.get(), |
| 162 | fFloat2x4_Type.get(), fFloat3x2_Type.get(), |
| 163 | fFloat3x3_Type.get(), fFloat3x4_Type.get(), |
| 164 | fFloat4x2_Type.get(), fFloat4x3_Type.get(), |
| 165 | fFloat4x4_Type.get(), fHalf2x2_Type.get(), |
| 166 | fHalf2x3_Type.get(), fHalf2x4_Type.get(), |
| 167 | fHalf3x2_Type.get(), fHalf3x3_Type.get(), |
| 168 | fHalf3x4_Type.get(), fHalf4x2_Type.get(), |
| 169 | fHalf4x3_Type.get(), fHalf4x4_Type.get(), |
| 170 | fDouble2x2_Type.get(), fDouble2x3_Type.get(), |
| 171 | fDouble2x4_Type.get(), fDouble3x2_Type.get(), |
| 172 | fDouble3x3_Type.get(), fDouble3x4_Type.get(), |
| 173 | fDouble4x2_Type.get(), fDouble4x3_Type.get(), |
| 174 | fDouble4x4_Type.get() })) |
| 175 | , fVec_Type(new Type("$vec", { fInvalid_Type.get(), fFloat2_Type.get(), |
| 176 | fFloat3_Type.get(), fFloat4_Type.get() })) |
| 177 | , fGVec_Type(new Type("$gvec")) |
| 178 | , fGVec2_Type(new Type("$gfloat2")) |
| 179 | , fGVec3_Type(new Type("$gfloat3")) |
| 180 | , fGVec4_Type(new Type("$gfloat4", static_type(*fFloat4_Type))) |
| 181 | , fHVec_Type(new Type("$hvec", { fInvalid_Type.get(), fHalf2_Type.get(), |
| 182 | fHalf3_Type.get(), fHalf4_Type.get() })) |
| 183 | , fDVec_Type(new Type("$dvec", { fInvalid_Type.get(), fDouble2_Type.get(), |
| 184 | fDouble3_Type.get(), fDouble4_Type.get() })) |
| 185 | , fIVec_Type(new Type("$ivec", { fInvalid_Type.get(), fInt2_Type.get(), |
| 186 | fInt3_Type.get(), fInt4_Type.get() })) |
| 187 | , fUVec_Type(new Type("$uvec", { fInvalid_Type.get(), fUInt2_Type.get(), |
| 188 | fUInt3_Type.get(), fUInt4_Type.get() })) |
| 189 | , fSVec_Type(new Type("$svec", { fInvalid_Type.get(), fShort2_Type.get(), |
| 190 | fShort3_Type.get(), fShort4_Type.get() })) |
| 191 | , fUSVec_Type(new Type("$usvec", { fInvalid_Type.get(), fUShort2_Type.get(), |
| 192 | fUShort3_Type.get(), fUShort4_Type.get() })) |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame] | 193 | , fByteVec_Type(new Type("$bytevec", { fInvalid_Type.get(), fByte2_Type.get(), |
| 194 | fByte3_Type.get(), fByte4_Type.get() })) |
| 195 | , fUByteVec_Type(new Type("$ubytevec", { fInvalid_Type.get(), fUByte2_Type.get(), |
| 196 | fUByte3_Type.get(), fUByte4_Type.get() })) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 197 | , fBVec_Type(new Type("$bvec", { fInvalid_Type.get(), fBool2_Type.get(), |
| 198 | fBool3_Type.get(), fBool4_Type.get() })) |
| 199 | , fSkCaps_Type(new Type("$sk_Caps")) |
| 200 | , fSkArgs_Type(new Type("$sk_Args")) |
Michael Ludwig | 9094f2c | 2018-09-07 13:44:21 -0400 | [diff] [blame] | 201 | , fFragmentProcessor_Type(fp_type(fInt_Type.get(), fBool_Type.get())) |
Ethan Nicholas | 26a9aad | 2018-03-27 14:10:52 -0400 | [diff] [blame] | 202 | , fSkRasterPipeline_Type(new Type("SkRasterPipeline")) |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 203 | , fDefined_Expression(new Defined(*fInvalid_Type)) {} |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 204 | |
| 205 | static std::vector<const Type*> static_type(const Type& t) { |
Greg Daniel | 64773e6 | 2016-11-22 09:44:03 -0500 | [diff] [blame] | 206 | return { &t, &t, &t, &t }; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 207 | } |
| 208 | |
ethannicholas | 471e894 | 2016-10-28 09:02:46 -0700 | [diff] [blame] | 209 | const std::unique_ptr<Type> fInvalid_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 210 | const std::unique_ptr<Type> fVoid_Type; |
Ethan Nicholas | e1f5502 | 2019-02-05 17:17:40 -0500 | [diff] [blame] | 211 | const std::unique_ptr<Type> fFloatLiteral_Type; |
| 212 | const std::unique_ptr<Type> fIntLiteral_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 213 | |
| 214 | const std::unique_ptr<Type> fDouble_Type; |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 215 | const std::unique_ptr<Type> fDouble2_Type; |
| 216 | const std::unique_ptr<Type> fDouble3_Type; |
| 217 | const std::unique_ptr<Type> fDouble4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 218 | |
| 219 | const std::unique_ptr<Type> fFloat_Type; |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 220 | const std::unique_ptr<Type> fFloat2_Type; |
| 221 | const std::unique_ptr<Type> fFloat3_Type; |
| 222 | const std::unique_ptr<Type> fFloat4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 223 | |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 224 | const std::unique_ptr<Type> fHalf_Type; |
| 225 | const std::unique_ptr<Type> fHalf2_Type; |
| 226 | const std::unique_ptr<Type> fHalf3_Type; |
| 227 | const std::unique_ptr<Type> fHalf4_Type; |
| 228 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 229 | const std::unique_ptr<Type> fUInt_Type; |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 230 | const std::unique_ptr<Type> fUInt2_Type; |
| 231 | const std::unique_ptr<Type> fUInt3_Type; |
| 232 | const std::unique_ptr<Type> fUInt4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 233 | |
| 234 | const std::unique_ptr<Type> fInt_Type; |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 235 | const std::unique_ptr<Type> fInt2_Type; |
| 236 | const std::unique_ptr<Type> fInt3_Type; |
| 237 | const std::unique_ptr<Type> fInt4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 238 | |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 239 | const std::unique_ptr<Type> fUShort_Type; |
| 240 | const std::unique_ptr<Type> fUShort2_Type; |
| 241 | const std::unique_ptr<Type> fUShort3_Type; |
| 242 | const std::unique_ptr<Type> fUShort4_Type; |
| 243 | |
| 244 | const std::unique_ptr<Type> fShort_Type; |
| 245 | const std::unique_ptr<Type> fShort2_Type; |
| 246 | const std::unique_ptr<Type> fShort3_Type; |
| 247 | const std::unique_ptr<Type> fShort4_Type; |
| 248 | |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame] | 249 | const std::unique_ptr<Type> fUByte_Type; |
| 250 | const std::unique_ptr<Type> fUByte2_Type; |
| 251 | const std::unique_ptr<Type> fUByte3_Type; |
| 252 | const std::unique_ptr<Type> fUByte4_Type; |
| 253 | |
| 254 | const std::unique_ptr<Type> fByte_Type; |
| 255 | const std::unique_ptr<Type> fByte2_Type; |
| 256 | const std::unique_ptr<Type> fByte3_Type; |
| 257 | const std::unique_ptr<Type> fByte4_Type; |
| 258 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 259 | const std::unique_ptr<Type> fBool_Type; |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 260 | const std::unique_ptr<Type> fBool2_Type; |
| 261 | const std::unique_ptr<Type> fBool3_Type; |
| 262 | const std::unique_ptr<Type> fBool4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 263 | |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 264 | const std::unique_ptr<Type> fFloat2x2_Type; |
| 265 | const std::unique_ptr<Type> fFloat2x3_Type; |
| 266 | const std::unique_ptr<Type> fFloat2x4_Type; |
| 267 | const std::unique_ptr<Type> fFloat3x2_Type; |
| 268 | const std::unique_ptr<Type> fFloat3x3_Type; |
| 269 | const std::unique_ptr<Type> fFloat3x4_Type; |
| 270 | const std::unique_ptr<Type> fFloat4x2_Type; |
| 271 | const std::unique_ptr<Type> fFloat4x3_Type; |
| 272 | const std::unique_ptr<Type> fFloat4x4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 273 | |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 274 | const std::unique_ptr<Type> fHalf2x2_Type; |
| 275 | const std::unique_ptr<Type> fHalf2x3_Type; |
| 276 | const std::unique_ptr<Type> fHalf2x4_Type; |
| 277 | const std::unique_ptr<Type> fHalf3x2_Type; |
| 278 | const std::unique_ptr<Type> fHalf3x3_Type; |
| 279 | const std::unique_ptr<Type> fHalf3x4_Type; |
| 280 | const std::unique_ptr<Type> fHalf4x2_Type; |
| 281 | const std::unique_ptr<Type> fHalf4x3_Type; |
| 282 | const std::unique_ptr<Type> fHalf4x4_Type; |
| 283 | |
Ethan Nicholas | 5af9ea3 | 2017-07-28 15:19:46 -0400 | [diff] [blame] | 284 | const std::unique_ptr<Type> fDouble2x2_Type; |
| 285 | const std::unique_ptr<Type> fDouble2x3_Type; |
| 286 | const std::unique_ptr<Type> fDouble2x4_Type; |
| 287 | const std::unique_ptr<Type> fDouble3x2_Type; |
| 288 | const std::unique_ptr<Type> fDouble3x3_Type; |
| 289 | const std::unique_ptr<Type> fDouble3x4_Type; |
| 290 | const std::unique_ptr<Type> fDouble4x2_Type; |
| 291 | const std::unique_ptr<Type> fDouble4x3_Type; |
| 292 | const std::unique_ptr<Type> fDouble4x4_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 293 | |
| 294 | const std::unique_ptr<Type> fSampler1D_Type; |
| 295 | const std::unique_ptr<Type> fSampler2D_Type; |
| 296 | const std::unique_ptr<Type> fSampler3D_Type; |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 297 | const std::unique_ptr<Type> fSamplerExternalOES_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 298 | const std::unique_ptr<Type> fSamplerCube_Type; |
| 299 | const std::unique_ptr<Type> fSampler2DRect_Type; |
| 300 | const std::unique_ptr<Type> fSampler1DArray_Type; |
| 301 | const std::unique_ptr<Type> fSampler2DArray_Type; |
| 302 | const std::unique_ptr<Type> fSamplerCubeArray_Type; |
| 303 | const std::unique_ptr<Type> fSamplerBuffer_Type; |
| 304 | const std::unique_ptr<Type> fSampler2DMS_Type; |
| 305 | const std::unique_ptr<Type> fSampler2DMSArray_Type; |
| 306 | const std::unique_ptr<Type> fSampler1DShadow_Type; |
| 307 | const std::unique_ptr<Type> fSampler2DShadow_Type; |
| 308 | const std::unique_ptr<Type> fSamplerCubeShadow_Type; |
| 309 | const std::unique_ptr<Type> fSampler2DRectShadow_Type; |
| 310 | const std::unique_ptr<Type> fSampler1DArrayShadow_Type; |
| 311 | const std::unique_ptr<Type> fSampler2DArrayShadow_Type; |
| 312 | const std::unique_ptr<Type> fSamplerCubeArrayShadow_Type; |
| 313 | |
Brian Salomon | bf7b620 | 2016-11-11 16:08:03 -0500 | [diff] [blame] | 314 | const std::unique_ptr<Type> fISampler2D_Type; |
| 315 | |
Brian Salomon | 2a51de8 | 2016-11-16 12:06:01 -0500 | [diff] [blame] | 316 | const std::unique_ptr<Type> fImage2D_Type; |
| 317 | const std::unique_ptr<Type> fIImage2D_Type; |
| 318 | |
Greg Daniel | 64773e6 | 2016-11-22 09:44:03 -0500 | [diff] [blame] | 319 | const std::unique_ptr<Type> fSubpassInput_Type; |
| 320 | const std::unique_ptr<Type> fSubpassInputMS_Type; |
| 321 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 322 | const std::unique_ptr<Type> fGSampler1D_Type; |
| 323 | const std::unique_ptr<Type> fGSampler2D_Type; |
| 324 | const std::unique_ptr<Type> fGSampler3D_Type; |
| 325 | const std::unique_ptr<Type> fGSamplerCube_Type; |
| 326 | const std::unique_ptr<Type> fGSampler2DRect_Type; |
| 327 | const std::unique_ptr<Type> fGSampler1DArray_Type; |
| 328 | const std::unique_ptr<Type> fGSampler2DArray_Type; |
| 329 | const std::unique_ptr<Type> fGSamplerCubeArray_Type; |
| 330 | const std::unique_ptr<Type> fGSamplerBuffer_Type; |
| 331 | const std::unique_ptr<Type> fGSampler2DMS_Type; |
| 332 | const std::unique_ptr<Type> fGSampler2DMSArray_Type; |
| 333 | const std::unique_ptr<Type> fGSampler2DArrayShadow_Type; |
| 334 | const std::unique_ptr<Type> fGSamplerCubeArrayShadow_Type; |
| 335 | |
| 336 | const std::unique_ptr<Type> fGenType_Type; |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 337 | const std::unique_ptr<Type> fGenHType_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 338 | const std::unique_ptr<Type> fGenDType_Type; |
| 339 | const std::unique_ptr<Type> fGenIType_Type; |
| 340 | const std::unique_ptr<Type> fGenUType_Type; |
| 341 | const std::unique_ptr<Type> fGenBType_Type; |
| 342 | |
| 343 | const std::unique_ptr<Type> fMat_Type; |
| 344 | |
| 345 | const std::unique_ptr<Type> fVec_Type; |
| 346 | |
| 347 | const std::unique_ptr<Type> fGVec_Type; |
| 348 | const std::unique_ptr<Type> fGVec2_Type; |
| 349 | const std::unique_ptr<Type> fGVec3_Type; |
| 350 | const std::unique_ptr<Type> fGVec4_Type; |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 351 | const std::unique_ptr<Type> fHVec_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 352 | const std::unique_ptr<Type> fDVec_Type; |
| 353 | const std::unique_ptr<Type> fIVec_Type; |
| 354 | const std::unique_ptr<Type> fUVec_Type; |
Ethan Nicholas | dcba08e | 2017-08-02 10:52:54 -0400 | [diff] [blame] | 355 | const std::unique_ptr<Type> fSVec_Type; |
| 356 | const std::unique_ptr<Type> fUSVec_Type; |
Ruiqi Mao | b609e6d | 2018-07-17 10:19:38 -0400 | [diff] [blame] | 357 | const std::unique_ptr<Type> fByteVec_Type; |
| 358 | const std::unique_ptr<Type> fUByteVec_Type; |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 359 | |
| 360 | const std::unique_ptr<Type> fBVec_Type; |
| 361 | |
Ethan Nicholas | 3605ace | 2016-11-21 15:59:48 -0500 | [diff] [blame] | 362 | const std::unique_ptr<Type> fSkCaps_Type; |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 363 | const std::unique_ptr<Type> fSkArgs_Type; |
Ethan Nicholas | c9472af | 2017-10-10 16:30:21 -0400 | [diff] [blame] | 364 | const std::unique_ptr<Type> fFragmentProcessor_Type; |
Ethan Nicholas | 26a9aad | 2018-03-27 14:10:52 -0400 | [diff] [blame] | 365 | const std::unique_ptr<Type> fSkRasterPipeline_Type; |
Ethan Nicholas | 3605ace | 2016-11-21 15:59:48 -0500 | [diff] [blame] | 366 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 367 | // dummy expression used to mark that a variable has a value during dataflow analysis (when it |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 368 | // could have several different values, or the analyzer is otherwise unable to assign it a |
| 369 | // specific expression) |
| 370 | const std::unique_ptr<Expression> fDefined_Expression; |
| 371 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 372 | private: |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 373 | class Defined : public Expression { |
| 374 | public: |
| 375 | Defined(const Type& type) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 376 | : INHERITED(-1, kDefined_Kind, type) {} |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 377 | |
Ethan Nicholas | cb67096 | 2017-04-20 19:31:52 -0400 | [diff] [blame] | 378 | bool hasSideEffects() const override { |
| 379 | return false; |
| 380 | } |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 381 | |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 382 | String description() const override { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 383 | return "<defined>"; |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 384 | } |
| 385 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 386 | std::unique_ptr<Expression> clone() const override { |
| 387 | return std::unique_ptr<Expression>(new Defined(fType)); |
| 388 | } |
| 389 | |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 390 | typedef Expression INHERITED; |
| 391 | }; |
Michael Ludwig | 9094f2c | 2018-09-07 13:44:21 -0400 | [diff] [blame] | 392 | |
| 393 | static std::unique_ptr<Type> fp_type(const Type* intType, const Type* boolType) { |
| 394 | // Build fields for FragmentProcessors, which should parallel the |
| 395 | // C++ API for GrFragmentProcessor. |
| 396 | Modifiers mods(Layout(), Modifiers::kConst_Flag); |
| 397 | std::vector<Type::Field> fields = { |
| 398 | Type::Field(mods, "numTextureSamplers", intType), |
| 399 | Type::Field(mods, "numCoordTransforms", intType), |
| 400 | Type::Field(mods, "numChildProcessors", intType), |
| 401 | Type::Field(mods, "usesLocalCoords", boolType), |
| 402 | Type::Field(mods, "compatibleWithCoverageAsAlpha", boolType), |
| 403 | Type::Field(mods, "preservesOpaqueInput", boolType), |
| 404 | Type::Field(mods, "hasConstantOutputForConstantInput", boolType) |
| 405 | }; |
| 406 | return std::unique_ptr<Type>(new Type("fragmentProcessor", fields)); |
| 407 | } |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 408 | }; |
| 409 | |
| 410 | } // namespace |
| 411 | |
| 412 | #endif |