diff --git a/glslang/Include/BaseTypes.h b/glslang/Include/BaseTypes.h index c1279238..c04fb6fa 100644 --- a/glslang/Include/BaseTypes.h +++ b/glslang/Include/BaseTypes.h @@ -38,33 +38,20 @@ #define _BASICTYPES_INCLUDED_ // -// Basic type. Arrays, vectors, etc., are orthogonal to this. +// Basic type. Arrays, vectors, sampler details, etc., are orthogonal to this. // enum TBasicType { EbtVoid, EbtFloat, EbtDouble, EbtInt, + EbtUint, EbtBool, - EbtGuardSamplerBegin, // non type: see implementation of IsSampler() - EbtSampler1D, - EbtSampler2D, - EbtSampler3D, - EbtSamplerCube, - EbtSampler1DShadow, - EbtSampler2DShadow, - EbtSamplerRect, // ARB_texture_rectangle - EbtSamplerRectShadow, // ARB_texture_rectangle - EbtGuardSamplerEnd, // non type: see implementation of IsSampler() + EbtSampler, EbtStruct, EbtNumTypes }; -__inline bool IsSampler(TBasicType type) -{ - return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd; -} - // // Qualifiers and built-ins. These are mainly used to see what can be read // or written, and by the machine dependent translator to know which registers diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index b98d3254..c1710914 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -40,6 +40,68 @@ #include "../Include/Common.h" #include "../Include/BaseTypes.h" +// +// Details within a sampler type +// +enum TSamplerDim { + EsdNone, + Esd1D, + Esd2D, + Esd3D, + EsdCube, + EsdRect, + EsdBuffer +}; + +struct TSampler { + TBasicType type : 8; // type returned by sampler + TSamplerDim dim : 8; + bool arrayed : 1; + bool shadow : 1; + bool ms : 1; + bool image : 1; + + void clear() + { + type = EbtVoid; + dim = EsdNone; + arrayed = false; + shadow = false; + ms = false; + image = false; + } + + void set(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false) + { + type = t; + dim = d; + arrayed = a; + shadow = s; + ms = m; + image = false; + } + + void setImage(TBasicType t, TSamplerDim d, bool a = false, bool s = false, bool m = false) + { + type = t; + dim = d; + arrayed = a; + shadow = s; + ms = m; + image = true; + } + + bool operator==(const TSampler& right) const + { + return type == right.type && + dim == right.dim && + arrayed == right.arrayed && + shadow == right.shadow && + ms == right.ms && + image == right.image; + } +}; + // // Need to have association of line numbers to types in a list for building structs. // @@ -93,6 +155,7 @@ public: class TPublicType { public: TBasicType type; + TSampler sampler; TQualifier qualifier; int vectorSize : 4; int matrixCols : 4; @@ -121,6 +184,7 @@ public: void init(int line = 0, bool global = false) { initType(line); + sampler.clear(); initQualifiers(global); } @@ -150,16 +214,18 @@ public: explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) : type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0), structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), - fieldName(0), mangled(0), typeName(0) + fieldName(0), mangled(0), typeName(0) { + sampler.clear(); qualifier.storage = q; qualifier.precision = EpqNone; } TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0) : type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0), structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), - fieldName(0), mangled(0), typeName(0) + fieldName(0), mangled(0), typeName(0) { + sampler.clear(); qualifier.storage = q; qualifier.precision = p; assert(p >= 0 && p <= EpqHigh); @@ -168,6 +234,7 @@ public: type(p.type), vectorSize(p.vectorSize), matrixCols(p.matrixCols), matrixRows(p.matrixRows), arraySizes(p.arraySizes), structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0) { + sampler = p.sampler; qualifier = p.qualifier; if (p.userDef) { structure = p.userDef->getStruct(); @@ -176,8 +243,9 @@ public: } explicit TType(TTypeList* userDef, const TString& n) : type(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), arraySizes(0), - structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) + structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) { + sampler.clear(); qualifier.storage = EvqTemporary; qualifier.precision = EpqNone; typeName = NewPoolTString(n.c_str()); @@ -190,6 +258,7 @@ public: void copyType(const TType& copyOf, const TStructureMap& remapper) { type = copyOf.type; + sampler = copyOf.sampler; qualifier = copyOf.qualifier; vectorSize = copyOf.vectorSize; matrixCols = copyOf.matrixCols; @@ -257,7 +326,7 @@ public: } virtual void setElementType(TBasicType t, int s, int mc, int mr, const TType* userDef) - { + { type = t; vectorSize = s; matrixCols = mc; @@ -283,7 +352,7 @@ public: virtual TBasicType getBasicType() const { return type; } virtual TQualifier& getQualifier() { return qualifier; } virtual const TQualifier& getQualifier() const { return qualifier; } - + virtual int getVectorSize() const { return vectorSize; } virtual int getMatrixCols() const { return matrixCols; } virtual int getMatrixRows() const { return matrixRows; } @@ -305,20 +374,13 @@ public: virtual bool isVector() const { return vectorSize > 1; } static const char* getBasicString(TBasicType t) { switch (t) { - case EbtVoid: return "void"; break; - case EbtFloat: return "float"; break; - case EbtDouble: return "double"; break; - case EbtInt: return "int"; break; - case EbtBool: return "bool"; break; - case EbtSampler1D: return "sampler1D"; break; - case EbtSampler2D: return "sampler2D"; break; - case EbtSampler3D: return "sampler3D"; break; - case EbtSamplerCube: return "samplerCube"; break; - case EbtSampler1DShadow: return "sampler1DShadow"; break; - case EbtSampler2DShadow: return "sampler2DShadow"; break; - case EbtSamplerRect: return "samplerRect"; break; // ARB_texture_rectangle - case EbtSamplerRectShadow: return "samplerRectShadow"; break; // ARB_texture_rectangle - case EbtStruct: return "structure"; break; + case EbtVoid: return "void"; + case EbtFloat: return "float"; + case EbtDouble: return "double"; + case EbtInt: return "int"; + case EbtBool: return "bool"; + case EbtSampler: return "sampler/image"; + case EbtStruct: return "structure"; default: return "unknown type"; } } @@ -345,7 +407,8 @@ public: } TTypeList* getStruct() const { return structure; } - TString& getMangledName() { + TString& getMangledName() + { if (!mangled) { mangled = NewPoolTString(""); buildMangledName(*mangled); @@ -354,25 +417,30 @@ public: return *mangled; } - bool sameElementType(const TType& right) const { + + bool sameElementType(const TType& right) const + { return type == right.type && + sampler == right.sampler && vectorSize == right.vectorSize && matrixCols == right.matrixCols && matrixRows == right.matrixRows && structure == right.structure; } - bool operator==(const TType& right) const { - return type == right.type && - vectorSize == right.vectorSize && - matrixCols == right.matrixCols && - matrixRows == right.matrixRows && - (arraySizes == 0 && right.arraySizes == 0 || (arraySizes && right.arraySizes && *arraySizes == *right.arraySizes)) && - structure == right.structure; + + bool operator==(const TType& right) const + { + return sameElementType(right) && + (arraySizes == 0 && right.arraySizes == 0 || + (arraySizes && right.arraySizes && *arraySizes == *right.arraySizes)); // don't check the qualifier, it's not ever what's being sought after } - bool operator!=(const TType& right) const { + + bool operator!=(const TType& right) const + { return !operator==(right); } + TString getCompleteString() const; protected: @@ -383,6 +451,7 @@ protected: int vectorSize : 4; int matrixCols : 4; int matrixRows : 4; + TSampler sampler; TQualifier qualifier; TArraySizes arraySizes; diff --git a/glslang/MachineIndependent/Intermediate.cpp b/glslang/MachineIndependent/Intermediate.cpp index 551454c5..8273bf41 100644 --- a/glslang/MachineIndependent/Intermediate.cpp +++ b/glslang/MachineIndependent/Intermediate.cpp @@ -347,14 +347,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt // switch (node->getBasicType()) { case EbtVoid: - case EbtSampler1D: - case EbtSampler2D: - case EbtSampler3D: - case EbtSamplerCube: - case EbtSampler1DShadow: - case EbtSampler2DShadow: - case EbtSamplerRect: // ARB_texture_rectangle - case EbtSamplerRectShadow: // ARB_texture_rectangle + case EbtSampler: return 0; default: break; } diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 4814fbec..497a9b7c 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -54,13 +54,12 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, E case EShLangVertex: defaultPrecision[EbtInt] = EpqHigh; defaultPrecision[EbtFloat] = EpqHigh; - defaultPrecision[EbtSampler2D] = EpqLow; - defaultPrecision[EbtSamplerCube] = EpqLow; + defaultPrecision[EbtSampler] = EpqLow; + //?? what about different sampler types? break; case EShLangFragment: defaultPrecision[EbtInt] = EpqMedium; - defaultPrecision[EbtSampler2D] = EpqLow; - defaultPrecision[EbtSamplerCube] = EpqLow; + defaultPrecision[EbtSampler] = EpqLow; // TODO: give error when using float in frag shader without default precision break; default: @@ -339,14 +338,7 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod // Type that can't be written to? // switch (node->getBasicType()) { - case EbtSampler1D: - case EbtSampler2D: - case EbtSampler3D: - case EbtSamplerCube: - case EbtSampler1DShadow: - case EbtSampler2DShadow: - case EbtSamplerRect: // ARB_texture_rectangle - case EbtSamplerRectShadow: // ARB_texture_rectangle + case EbtSampler: message = "can't modify a sampler"; break; case EbtVoid: @@ -562,7 +554,7 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction error(line, "constructor argument does not have a type", "constructor", ""); return true; } - if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) { + if (op != EOpConstructStruct && typed->getBasicType() == EbtSampler) { error(line, "cannot convert a sampler", "constructor", ""); return true; } @@ -626,7 +618,7 @@ bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const } return false; - } else if (IsSampler(pType.type)) { + } else if (pType.type == EbtSampler) { error(line, reason, TType::getBasicString(pType.type), ""); return true; @@ -670,7 +662,7 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType return true; } - if (pType.qualifier.storage != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform")) + if (pType.qualifier.storage != EvqUniform && samplerErrorCheck(line, pType, "samplers and images must be uniform")) return true; return false; @@ -678,7 +670,8 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType void TParseContext::setDefaultPrecision(int line, TBasicType type, TPrecisionQualifier qualifier) { - if (IsSampler(type) || type == EbtInt || type == EbtFloat) { + //?? what about different sampler types? + if (type == EbtSampler || type == EbtInt || type == EbtFloat) { defaultPrecision[type] = qualifier; } else { error(line, "cannot apply precision statement to this type", TType::getBasicString(type), ""); @@ -689,7 +682,7 @@ void TParseContext::setDefaultPrecision(int line, TBasicType type, TPrecisionQua bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type) { if ((qualifier == EvqOut || qualifier == EvqInOut) && - type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) { + type.getBasicType() != EbtStruct && type.getBasicType() == EbtSampler) { error(line, "samplers cannot be output parameters", type.getBasicString(), ""); return true; } @@ -699,7 +692,7 @@ bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier quali bool TParseContext::containsSampler(const TType& type) { - if (IsSampler(type.getBasicType())) + if (type.getBasicType() == EbtSampler) return true; if (type.getBasicType() == EbtStruct) { diff --git a/glslang/MachineIndependent/SymbolTable.cpp b/glslang/MachineIndependent/SymbolTable.cpp index 6e731c6d..038c55da 100644 --- a/glslang/MachineIndependent/SymbolTable.cpp +++ b/glslang/MachineIndependent/SymbolTable.cpp @@ -60,14 +60,28 @@ void TType::buildMangledName(TString& mangledName) case EbtDouble: mangledName += 'd'; break; case EbtInt: mangledName += 'i'; break; case EbtBool: mangledName += 'b'; break; - case EbtSampler1D: mangledName += "s1"; break; - case EbtSampler2D: mangledName += "s2"; break; - case EbtSampler3D: mangledName += "s3"; break; - case EbtSamplerCube: mangledName += "sC"; break; - case EbtSampler1DShadow: mangledName += "sS1"; break; - case EbtSampler2DShadow: mangledName += "sS2"; break; - case EbtSamplerRect: mangledName += "sR2"; break; // ARB_texture_rectangle - case EbtSamplerRectShadow: mangledName += "sSR2"; break; // ARB_texture_rectangle + case EbtSampler: + switch (sampler.type) { + case EbtInt: mangledName += "i"; break; + case EbtUint: mangledName += "u"; break; + } + if (sampler.image) + mangledName += "I"; + else + mangledName += "s"; + if (sampler.arrayed) + mangledName += "A"; + if (sampler.shadow) + mangledName += "S"; + switch (sampler.dim) { + case Esd1D: mangledName += "1"; break; + case Esd2D: mangledName += "2"; break; + case Esd3D: mangledName += "3"; break; + case EsdCube: mangledName += "C"; break; + case EsdRect: mangledName += "R2"; break; + case EsdBuffer: mangledName += "B"; break; + } + break; case EbtStruct: mangledName += "struct-"; if (typeName) diff --git a/glslang/MachineIndependent/glslang.y b/glslang/MachineIndependent/glslang.y index ecc856b8..2ba802d3 100644 --- a/glslang/MachineIndependent/glslang.y +++ b/glslang/MachineIndependent/glslang.y @@ -2110,345 +2110,376 @@ type_specifier_nonarray } | SAMPLER1D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler1D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd1D); } | SAMPLER2D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D); } | SAMPLER3D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler3D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd3D); } | SAMPLERCUBE { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSamplerCube; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdCube); } | SAMPLER1DSHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler1DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd1D, false, true); } | SAMPLER2DSHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D, false, true); } | SAMPLERCUBESHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdCube, false, true); } | SAMPLER1DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd1D, true); } | SAMPLER2DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D, true); } | SAMPLER1DARRAYSHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd1D, true, true); } | SAMPLER2DARRAYSHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D, true, true); } | SAMPLERCUBEARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdCube, true); } | SAMPLERCUBEARRAYSHADOW { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdCube, true, true); } | ISAMPLER1D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd1D); } | ISAMPLER2D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd2D); } | ISAMPLER3D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd3D); } | ISAMPLERCUBE { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, EsdCube); } | ISAMPLER1DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd1D, true); } | ISAMPLER2DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd2D, true); } | ISAMPLERCUBEARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd3D, true); } | USAMPLER1D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd1D); } | USAMPLER2D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd2D); } | USAMPLER3D { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd3D); } | USAMPLERCUBE { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, EsdCube); } | USAMPLER1DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd1D, true); } | USAMPLER2DARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd2D, true); } | USAMPLERCUBEARRAY { $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2DShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, EsdCube, true); } | SAMPLER2DRECT { parseContext.profileRequires($1.line, ENoProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSamplerRect; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdRect); } | SAMPLER2DRECTSHADOW { parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSamplerRectShadow; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdRect, false, true); } | ISAMPLER2DRECT { parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSamplerRect; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, EsdRect); } | USAMPLER2DRECT { parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSamplerRect; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, EsdRect); } | SAMPLERBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, EsdBuffer); } | ISAMPLERBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, EsdBuffer); } | USAMPLERBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, EsdBuffer); } | SAMPLER2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D, false, false, true); } | ISAMPLER2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd2D, false, false, true); } | USAMPLER2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd2D, false, false, true); } | SAMPLER2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtFloat, Esd2D, true, false, true); } | ISAMPLER2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtInt, Esd2D, true, false, true); } | USAMPLER2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.set(EbtUint, Esd2D, true, false, true); } | IMAGE1D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd1D); } | IIMAGE1D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd1D); } | UIMAGE1D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd1D); } | IMAGE2D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd2D); } | IIMAGE2D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd2D); } | UIMAGE2D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd2D); } | IMAGE3D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd3D); } | IIMAGE3D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd3D); } | UIMAGE3D { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd3D); } | IMAGE2DRECT { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, EsdRect); } | IIMAGE2DRECT { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, EsdRect); } | UIMAGE2DRECT { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, EsdRect); } | IMAGECUBE { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, EsdCube); } | IIMAGECUBE { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, EsdCube); } | UIMAGECUBE { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, EsdCube); } | IMAGEBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, EsdBuffer); } | IIMAGEBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, EsdBuffer); } | UIMAGEBUFFER { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, EsdBuffer); } | IMAGE1DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd1D, true); } | IIMAGE1DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd1D, true); } | UIMAGE1DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd1D, true); } | IMAGE2DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd2D, true); } | IIMAGE2DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd2D, true); } | UIMAGE2DARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd2D, true); } | IMAGECUBEARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, EsdCube, true); } | IIMAGECUBEARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, EsdCube, true); } | UIMAGECUBEARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, EsdCube, true); } | IMAGE2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd2D, false, false, true); } | IIMAGE2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd2D, false, false, true); } | UIMAGE2DMS { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd2D, false, false, true); } | IMAGE2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtFloat, Esd2D, true, false, true); } | IIMAGE2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtInt, Esd2D, true, false, true); } | UIMAGE2DMSARRAY { - // TODO: implement this type $$.init($1.line, parseContext.symbolTable.atGlobalLevel()); - $$.type = EbtSampler2D; + $$.type = EbtSampler; + $$.sampler.setImage(EbtUint, Esd2D, true, false, true); } | struct_specifier { $$ = $1; diff --git a/glslang/MachineIndependent/intermOut.cpp b/glslang/MachineIndependent/intermOut.cpp index 556c0ac5..e9e6e62a 100644 --- a/glslang/MachineIndependent/intermOut.cpp +++ b/glslang/MachineIndependent/intermOut.cpp @@ -77,9 +77,37 @@ TString TType::getCompleteString() const else if (vectorSize > 1) p += snprintf(p, end - p, "%d-component vector of ", vectorSize); - snprintf(p, end - p, "%s", getBasicString()); + *p = 0; + TString s(buf); - return TString(buf); + if (type == EbtSampler) { + switch (sampler.type) { + case EbtFloat: break; + case EbtInt: s.append("i"); break; + case EbtUint: s.append("u"); break; + } + if (sampler.image) + s.append("image"); + else + s.append("sampler"); + switch (sampler.dim) { + case Esd1D: s.append("1D"); break; + case Esd2D: s.append("2D"); break; + case Esd3D: s.append("3D"); break; + case EsdCube: s.append("Cube"); break; + case EsdRect: s.append("Rect"); break; + case EsdBuffer: s.append("Buffer"); break; + } + if (sampler.arrayed) + s.append("Array"); + if (sampler.shadow) + s.append("Shadow"); + if (sampler.ms) + s.append("MS"); + } else + s.append(getBasicString()); + + return s; } //