Replace flat 110 sampler type space with an orthogonalized 430 sampler type space. Invoke it for all the sampler types in the 4.3 grammar.

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20652 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-02-21 02:18:42 +00:00
parent e396a22632
commit e141d5c99c
7 changed files with 311 additions and 196 deletions

View File

@ -38,33 +38,20 @@
#define _BASICTYPES_INCLUDED_ #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 { enum TBasicType {
EbtVoid, EbtVoid,
EbtFloat, EbtFloat,
EbtDouble, EbtDouble,
EbtInt, EbtInt,
EbtUint,
EbtBool, EbtBool,
EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtSampler,
EbtSampler1D,
EbtSampler2D,
EbtSampler3D,
EbtSamplerCube,
EbtSampler1DShadow,
EbtSampler2DShadow,
EbtSamplerRect, // ARB_texture_rectangle
EbtSamplerRectShadow, // ARB_texture_rectangle
EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct, EbtStruct,
EbtNumTypes 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 // 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 // or written, and by the machine dependent translator to know which registers

View File

@ -40,6 +40,68 @@
#include "../Include/Common.h" #include "../Include/Common.h"
#include "../Include/BaseTypes.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. // Need to have association of line numbers to types in a list for building structs.
// //
@ -93,6 +155,7 @@ public:
class TPublicType { class TPublicType {
public: public:
TBasicType type; TBasicType type;
TSampler sampler;
TQualifier qualifier; TQualifier qualifier;
int vectorSize : 4; int vectorSize : 4;
int matrixCols : 4; int matrixCols : 4;
@ -121,6 +184,7 @@ public:
void init(int line = 0, bool global = false) void init(int line = 0, bool global = false)
{ {
initType(line); initType(line);
sampler.clear();
initQualifiers(global); initQualifiers(global);
} }
@ -150,16 +214,18 @@ public:
explicit TType(TBasicType t, TStorageQualifier q = EvqTemporary, int vs = 1, int mc = 0, int mr = 0) : 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), type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(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.storage = q;
qualifier.precision = EpqNone; qualifier.precision = EpqNone;
} }
TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0) : 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), type(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), arraySizes(0),
structure(0), structureSize(0), maxArraySize(0), arrayInformationType(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.storage = q;
qualifier.precision = p; qualifier.precision = p;
assert(p >= 0 && p <= EpqHigh); 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), 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) structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0), typeName(0)
{ {
sampler = p.sampler;
qualifier = p.qualifier; qualifier = p.qualifier;
if (p.userDef) { if (p.userDef) {
structure = p.userDef->getStruct(); structure = p.userDef->getStruct();
@ -176,8 +243,9 @@ public:
} }
explicit TType(TTypeList* userDef, const TString& n) : explicit TType(TTypeList* userDef, const TString& n) :
type(EbtStruct), vectorSize(1), matrixCols(0), matrixRows(0), arraySizes(0), 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.storage = EvqTemporary;
qualifier.precision = EpqNone; qualifier.precision = EpqNone;
typeName = NewPoolTString(n.c_str()); typeName = NewPoolTString(n.c_str());
@ -190,6 +258,7 @@ public:
void copyType(const TType& copyOf, const TStructureMap& remapper) void copyType(const TType& copyOf, const TStructureMap& remapper)
{ {
type = copyOf.type; type = copyOf.type;
sampler = copyOf.sampler;
qualifier = copyOf.qualifier; qualifier = copyOf.qualifier;
vectorSize = copyOf.vectorSize; vectorSize = copyOf.vectorSize;
matrixCols = copyOf.matrixCols; matrixCols = copyOf.matrixCols;
@ -257,7 +326,7 @@ public:
} }
virtual void setElementType(TBasicType t, int s, int mc, int mr, const TType* userDef) virtual void setElementType(TBasicType t, int s, int mc, int mr, const TType* userDef)
{ {
type = t; type = t;
vectorSize = s; vectorSize = s;
matrixCols = mc; matrixCols = mc;
@ -283,7 +352,7 @@ public:
virtual TBasicType getBasicType() const { return type; } virtual TBasicType getBasicType() const { return type; }
virtual TQualifier& getQualifier() { return qualifier; } virtual TQualifier& getQualifier() { return qualifier; }
virtual const TQualifier& getQualifier() const { return qualifier; } virtual const TQualifier& getQualifier() const { return qualifier; }
virtual int getVectorSize() const { return vectorSize; } virtual int getVectorSize() const { return vectorSize; }
virtual int getMatrixCols() const { return matrixCols; } virtual int getMatrixCols() const { return matrixCols; }
virtual int getMatrixRows() const { return matrixRows; } virtual int getMatrixRows() const { return matrixRows; }
@ -305,20 +374,13 @@ public:
virtual bool isVector() const { return vectorSize > 1; } virtual bool isVector() const { return vectorSize > 1; }
static const char* getBasicString(TBasicType t) { static const char* getBasicString(TBasicType t) {
switch (t) { switch (t) {
case EbtVoid: return "void"; break; case EbtVoid: return "void";
case EbtFloat: return "float"; break; case EbtFloat: return "float";
case EbtDouble: return "double"; break; case EbtDouble: return "double";
case EbtInt: return "int"; break; case EbtInt: return "int";
case EbtBool: return "bool"; break; case EbtBool: return "bool";
case EbtSampler1D: return "sampler1D"; break; case EbtSampler: return "sampler/image";
case EbtSampler2D: return "sampler2D"; break; case EbtStruct: return "structure";
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;
default: return "unknown type"; default: return "unknown type";
} }
} }
@ -345,7 +407,8 @@ public:
} }
TTypeList* getStruct() const { return structure; } TTypeList* getStruct() const { return structure; }
TString& getMangledName() { TString& getMangledName()
{
if (!mangled) { if (!mangled) {
mangled = NewPoolTString(""); mangled = NewPoolTString("");
buildMangledName(*mangled); buildMangledName(*mangled);
@ -354,25 +417,30 @@ public:
return *mangled; return *mangled;
} }
bool sameElementType(const TType& right) const {
bool sameElementType(const TType& right) const
{
return type == right.type && return type == right.type &&
sampler == right.sampler &&
vectorSize == right.vectorSize && vectorSize == right.vectorSize &&
matrixCols == right.matrixCols && matrixCols == right.matrixCols &&
matrixRows == right.matrixRows && matrixRows == right.matrixRows &&
structure == right.structure; structure == right.structure;
} }
bool operator==(const TType& right) const {
return type == right.type && bool operator==(const TType& right) const
vectorSize == right.vectorSize && {
matrixCols == right.matrixCols && return sameElementType(right) &&
matrixRows == right.matrixRows && (arraySizes == 0 && right.arraySizes == 0 ||
(arraySizes == 0 && right.arraySizes == 0 || (arraySizes && right.arraySizes && *arraySizes == *right.arraySizes)) && (arraySizes && right.arraySizes && *arraySizes == *right.arraySizes));
structure == right.structure;
// don't check the qualifier, it's not ever what's being sought after // 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); return !operator==(right);
} }
TString getCompleteString() const; TString getCompleteString() const;
protected: protected:
@ -383,6 +451,7 @@ protected:
int vectorSize : 4; int vectorSize : 4;
int matrixCols : 4; int matrixCols : 4;
int matrixRows : 4; int matrixRows : 4;
TSampler sampler;
TQualifier qualifier; TQualifier qualifier;
TArraySizes arraySizes; TArraySizes arraySizes;

View File

@ -347,14 +347,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
// //
switch (node->getBasicType()) { switch (node->getBasicType()) {
case EbtVoid: case EbtVoid:
case EbtSampler1D: case EbtSampler:
case EbtSampler2D:
case EbtSampler3D:
case EbtSamplerCube:
case EbtSampler1DShadow:
case EbtSampler2DShadow:
case EbtSamplerRect: // ARB_texture_rectangle
case EbtSamplerRectShadow: // ARB_texture_rectangle
return 0; return 0;
default: break; default: break;
} }

View File

@ -54,13 +54,12 @@ TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, int v, E
case EShLangVertex: case EShLangVertex:
defaultPrecision[EbtInt] = EpqHigh; defaultPrecision[EbtInt] = EpqHigh;
defaultPrecision[EbtFloat] = EpqHigh; defaultPrecision[EbtFloat] = EpqHigh;
defaultPrecision[EbtSampler2D] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
defaultPrecision[EbtSamplerCube] = EpqLow; //?? what about different sampler types?
break; break;
case EShLangFragment: case EShLangFragment:
defaultPrecision[EbtInt] = EpqMedium; defaultPrecision[EbtInt] = EpqMedium;
defaultPrecision[EbtSampler2D] = EpqLow; defaultPrecision[EbtSampler] = EpqLow;
defaultPrecision[EbtSamplerCube] = EpqLow;
// TODO: give error when using float in frag shader without default precision // TODO: give error when using float in frag shader without default precision
break; break;
default: default:
@ -339,14 +338,7 @@ bool TParseContext::lValueErrorCheck(int line, const char* op, TIntermTyped* nod
// Type that can't be written to? // Type that can't be written to?
// //
switch (node->getBasicType()) { switch (node->getBasicType()) {
case EbtSampler1D: case EbtSampler:
case EbtSampler2D:
case EbtSampler3D:
case EbtSamplerCube:
case EbtSampler1DShadow:
case EbtSampler2DShadow:
case EbtSamplerRect: // ARB_texture_rectangle
case EbtSamplerRectShadow: // ARB_texture_rectangle
message = "can't modify a sampler"; message = "can't modify a sampler";
break; break;
case EbtVoid: case EbtVoid:
@ -562,7 +554,7 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
error(line, "constructor argument does not have a type", "constructor", ""); error(line, "constructor argument does not have a type", "constructor", "");
return true; return true;
} }
if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) { if (op != EOpConstructStruct && typed->getBasicType() == EbtSampler) {
error(line, "cannot convert a sampler", "constructor", ""); error(line, "cannot convert a sampler", "constructor", "");
return true; return true;
} }
@ -626,7 +618,7 @@ bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const
} }
return false; return false;
} else if (IsSampler(pType.type)) { } else if (pType.type == EbtSampler) {
error(line, reason, TType::getBasicString(pType.type), ""); error(line, reason, TType::getBasicString(pType.type), "");
return true; return true;
@ -670,7 +662,7 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType
return true; 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 true;
return false; return false;
@ -678,7 +670,8 @@ bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType
void TParseContext::setDefaultPrecision(int line, TBasicType type, TPrecisionQualifier qualifier) 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; defaultPrecision[type] = qualifier;
} else { } else {
error(line, "cannot apply precision statement to this type", TType::getBasicString(type), ""); 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) bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier qualifier, const TType& type)
{ {
if ((qualifier == EvqOut || qualifier == EvqInOut) && 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(), ""); error(line, "samplers cannot be output parameters", type.getBasicString(), "");
return true; return true;
} }
@ -699,7 +692,7 @@ bool TParseContext::parameterSamplerErrorCheck(int line, TStorageQualifier quali
bool TParseContext::containsSampler(const TType& type) bool TParseContext::containsSampler(const TType& type)
{ {
if (IsSampler(type.getBasicType())) if (type.getBasicType() == EbtSampler)
return true; return true;
if (type.getBasicType() == EbtStruct) { if (type.getBasicType() == EbtStruct) {

View File

@ -60,14 +60,28 @@ void TType::buildMangledName(TString& mangledName)
case EbtDouble: mangledName += 'd'; break; case EbtDouble: mangledName += 'd'; break;
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
case EbtBool: mangledName += 'b'; break; case EbtBool: mangledName += 'b'; break;
case EbtSampler1D: mangledName += "s1"; break; case EbtSampler:
case EbtSampler2D: mangledName += "s2"; break; switch (sampler.type) {
case EbtSampler3D: mangledName += "s3"; break; case EbtInt: mangledName += "i"; break;
case EbtSamplerCube: mangledName += "sC"; break; case EbtUint: mangledName += "u"; break;
case EbtSampler1DShadow: mangledName += "sS1"; break; }
case EbtSampler2DShadow: mangledName += "sS2"; break; if (sampler.image)
case EbtSamplerRect: mangledName += "sR2"; break; // ARB_texture_rectangle mangledName += "I";
case EbtSamplerRectShadow: mangledName += "sSR2"; break; // ARB_texture_rectangle 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: case EbtStruct:
mangledName += "struct-"; mangledName += "struct-";
if (typeName) if (typeName)

View File

@ -2110,345 +2110,376 @@ type_specifier_nonarray
} }
| SAMPLER1D { | SAMPLER1D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler1D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd1D);
} }
| SAMPLER2D { | SAMPLER2D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D);
} }
| SAMPLER3D { | SAMPLER3D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler3D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd3D);
} }
| SAMPLERCUBE { | SAMPLERCUBE {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSamplerCube; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdCube);
} }
| SAMPLER1DSHADOW { | SAMPLER1DSHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler1DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd1D, false, true);
} }
| SAMPLER2DSHADOW { | SAMPLER2DSHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D, false, true);
} }
| SAMPLERCUBESHADOW { | SAMPLERCUBESHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdCube, false, true);
} }
| SAMPLER1DARRAY { | SAMPLER1DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd1D, true);
} }
| SAMPLER2DARRAY { | SAMPLER2DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D, true);
} }
| SAMPLER1DARRAYSHADOW { | SAMPLER1DARRAYSHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd1D, true, true);
} }
| SAMPLER2DARRAYSHADOW { | SAMPLER2DARRAYSHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D, true, true);
} }
| SAMPLERCUBEARRAY { | SAMPLERCUBEARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdCube, true);
} }
| SAMPLERCUBEARRAYSHADOW { | SAMPLERCUBEARRAYSHADOW {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdCube, true, true);
} }
| ISAMPLER1D { | ISAMPLER1D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd1D);
} }
| ISAMPLER2D { | ISAMPLER2D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd2D);
} }
| ISAMPLER3D { | ISAMPLER3D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd3D);
} }
| ISAMPLERCUBE { | ISAMPLERCUBE {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, EsdCube);
} }
| ISAMPLER1DARRAY { | ISAMPLER1DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd1D, true);
} }
| ISAMPLER2DARRAY { | ISAMPLER2DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd2D, true);
} }
| ISAMPLERCUBEARRAY { | ISAMPLERCUBEARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd3D, true);
} }
| USAMPLER1D { | USAMPLER1D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd1D);
} }
| USAMPLER2D { | USAMPLER2D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd2D);
} }
| USAMPLER3D { | USAMPLER3D {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd3D);
} }
| USAMPLERCUBE { | USAMPLERCUBE {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, EsdCube);
} }
| USAMPLER1DARRAY { | USAMPLER1DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd1D, true);
} }
| USAMPLER2DARRAY { | USAMPLER2DARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd2D, true);
} }
| USAMPLERCUBEARRAY { | USAMPLERCUBEARRAY {
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2DShadow; $$.type = EbtSampler;
$$.sampler.set(EbtUint, EsdCube, true);
} }
| SAMPLER2DRECT { | SAMPLER2DRECT {
parseContext.profileRequires($1.line, ENoProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); parseContext.profileRequires($1.line, ENoProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture");
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSamplerRect; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdRect);
} }
| SAMPLER2DRECTSHADOW { | SAMPLER2DRECTSHADOW {
parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture");
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSamplerRectShadow; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdRect, false, true);
} }
| ISAMPLER2DRECT { | ISAMPLER2DRECT {
parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture");
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSamplerRect; $$.type = EbtSampler;
$$.sampler.set(EbtInt, EsdRect);
} }
| USAMPLER2DRECT { | USAMPLER2DRECT {
parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture"); parseContext.profileRequires($1.line, ECoreProfile, 140, "GL_ARB_texture_rectangle", "rectangle texture");
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSamplerRect; $$.type = EbtSampler;
$$.sampler.set(EbtUint, EsdRect);
} }
| SAMPLERBUFFER { | SAMPLERBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, EsdBuffer);
} }
| ISAMPLERBUFFER { | ISAMPLERBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtInt, EsdBuffer);
} }
| USAMPLERBUFFER { | USAMPLERBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtUint, EsdBuffer);
} }
| SAMPLER2DMS { | SAMPLER2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D, false, false, true);
} }
| ISAMPLER2DMS { | ISAMPLER2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd2D, false, false, true);
} }
| USAMPLER2DMS { | USAMPLER2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd2D, false, false, true);
} }
| SAMPLER2DMSARRAY { | SAMPLER2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtFloat, Esd2D, true, false, true);
} }
| ISAMPLER2DMSARRAY { | ISAMPLER2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtInt, Esd2D, true, false, true);
} }
| USAMPLER2DMSARRAY { | USAMPLER2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.set(EbtUint, Esd2D, true, false, true);
} }
| IMAGE1D { | IMAGE1D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd1D);
} }
| IIMAGE1D { | IIMAGE1D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd1D);
} }
| UIMAGE1D { | UIMAGE1D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd1D);
} }
| IMAGE2D { | IMAGE2D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd2D);
} }
| IIMAGE2D { | IIMAGE2D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd2D);
} }
| UIMAGE2D { | UIMAGE2D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd2D);
} }
| IMAGE3D { | IMAGE3D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd3D);
} }
| IIMAGE3D { | IIMAGE3D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd3D);
} }
| UIMAGE3D { | UIMAGE3D {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd3D);
} }
| IMAGE2DRECT { | IMAGE2DRECT {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, EsdRect);
} }
| IIMAGE2DRECT { | IIMAGE2DRECT {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, EsdRect);
} }
| UIMAGE2DRECT { | UIMAGE2DRECT {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, EsdRect);
} }
| IMAGECUBE { | IMAGECUBE {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, EsdCube);
} }
| IIMAGECUBE { | IIMAGECUBE {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, EsdCube);
} }
| UIMAGECUBE { | UIMAGECUBE {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, EsdCube);
} }
| IMAGEBUFFER { | IMAGEBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, EsdBuffer);
} }
| IIMAGEBUFFER { | IIMAGEBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, EsdBuffer);
} }
| UIMAGEBUFFER { | UIMAGEBUFFER {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, EsdBuffer);
} }
| IMAGE1DARRAY { | IMAGE1DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd1D, true);
} }
| IIMAGE1DARRAY { | IIMAGE1DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd1D, true);
} }
| UIMAGE1DARRAY { | UIMAGE1DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd1D, true);
} }
| IMAGE2DARRAY { | IMAGE2DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd2D, true);
} }
| IIMAGE2DARRAY { | IIMAGE2DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd2D, true);
} }
| UIMAGE2DARRAY { | UIMAGE2DARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd2D, true);
} }
| IMAGECUBEARRAY { | IMAGECUBEARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, EsdCube, true);
} }
| IIMAGECUBEARRAY { | IIMAGECUBEARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, EsdCube, true);
} }
| UIMAGECUBEARRAY { | UIMAGECUBEARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, EsdCube, true);
} }
| IMAGE2DMS { | IMAGE2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd2D, false, false, true);
} }
| IIMAGE2DMS { | IIMAGE2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd2D, false, false, true);
} }
| UIMAGE2DMS { | UIMAGE2DMS {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd2D, false, false, true);
} }
| IMAGE2DMSARRAY { | IMAGE2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtFloat, Esd2D, true, false, true);
} }
| IIMAGE2DMSARRAY { | IIMAGE2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtInt, Esd2D, true, false, true);
} }
| UIMAGE2DMSARRAY { | UIMAGE2DMSARRAY {
// TODO: implement this type
$$.init($1.line, parseContext.symbolTable.atGlobalLevel()); $$.init($1.line, parseContext.symbolTable.atGlobalLevel());
$$.type = EbtSampler2D; $$.type = EbtSampler;
$$.sampler.setImage(EbtUint, Esd2D, true, false, true);
} }
| struct_specifier { | struct_specifier {
$$ = $1; $$ = $1;

View File

@ -77,9 +77,37 @@ TString TType::getCompleteString() const
else if (vectorSize > 1) else if (vectorSize > 1)
p += snprintf(p, end - p, "%d-component vector of ", vectorSize); 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;
} }
// //