Commit f8a4cba0 by Nicolas Capens

Define GLSL ES 3.0 sampler types.

Bug 19331817 Change-Id: I7f7f842d01069abda953a5fe3eb8572f5dc985a9 Reviewed-on: https://swiftshader-review.googlesource.com/2370Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 70da3d43
...@@ -40,12 +40,29 @@ enum TBasicType ...@@ -40,12 +40,29 @@ enum TBasicType
EbtInt, EbtInt,
EbtUInt, EbtUInt,
EbtBool, EbtBool,
EbtGVec4, // non type: represents vec4, ivec4 and uvec4
EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D, EbtSampler2D,
EbtSamplerCube,
EbtSamplerExternalOES,
EbtSampler3D, EbtSampler3D,
EbtSamplerCube,
EbtSampler2DArray,
EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
EbtISampler2D,
EbtISampler3D,
EbtISamplerCube,
EbtISampler2DArray,
EbtUSampler2D,
EbtUSampler3D,
EbtUSamplerCube,
EbtUSampler2DArray,
EbtSampler2DShadow,
EbtSamplerCubeShadow,
EbtSampler2DArrayShadow,
EbtGuardSamplerEnd, // non type: see implementation of IsSampler() EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtGSampler2D, // non type: represents sampler2D, isampler2D and usampler2D
EbtGSampler3D, // non type: represents sampler3D, isampler3D and usampler3D
EbtGSamplerCube, // non type: represents samplerCube, isamplerCube and usamplerCube
EbtGSampler2DArray, // non type: represents sampler2DArray, isampler2DArray and usampler2DArray
EbtStruct, EbtStruct,
EbtAddress, // should be deprecated?? EbtAddress, // should be deprecated??
EbtInvariant // used as a type when qualifying a previously declared variable as being invariant EbtInvariant // used as a type when qualifying a previously declared variable as being invariant
......
...@@ -281,8 +281,41 @@ public: ...@@ -281,8 +281,41 @@ public:
return insert(level, *constant); return insert(level, *constant);
} }
bool insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0) void insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2 = 0, TType *ptype3 = 0, TType *ptype4 = 0)
{ {
if(ptype1->getBasicType() == EbtGSampler2D)
{
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4);
return;
}
else if(ptype1->getBasicType() == EbtGSampler3D)
{
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4);
return;
}
else if(ptype1->getBasicType() == EbtGSamplerCube)
{
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4);
return;
}
else if(ptype1->getBasicType() == EbtGSampler2DArray)
{
bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2DArray), ptype2, ptype3, ptype4);
insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4);
return;
}
TFunction *function = new TFunction(NewPoolTString(name), *rvalue); TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
TParameter param1 = {0, ptype1}; TParameter param1 = {0, ptype1};
...@@ -300,7 +333,7 @@ public: ...@@ -300,7 +333,7 @@ public:
function->addParameter(param3); function->addParameter(param3);
} }
return insert(level, *function); insert(level, *function);
} }
TSymbol *find(const TString &name, int shaderVersion, bool *builtIn = false, bool *sameScope = false) const; TSymbol *find(const TString &name, int shaderVersion, bool *builtIn = false, bool *sameScope = false) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment