diff options
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/Types.h')
-rw-r--r-- | src/3rdparty/angle/src/compiler/translator/Types.h | 151 |
1 files changed, 115 insertions, 36 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/Types.h b/src/3rdparty/angle/src/compiler/translator/Types.h index 044f22c3c1..c2968dceba 100644 --- a/src/3rdparty/angle/src/compiler/translator/Types.h +++ b/src/3rdparty/angle/src/compiler/translator/Types.h @@ -8,10 +8,10 @@ #define COMPILER_TRANSLATOR_TYPES_H_ #include "common/angleutils.h" +#include "common/debug.h" #include "compiler/translator/BaseTypes.h" #include "compiler/translator/Common.h" -#include "compiler/translator/compilerdebug.h" struct TPublicType; class TType; @@ -73,12 +73,6 @@ class TFieldListCollection : angle::NonCopyable return *mFields; } - const TString &mangledName() const - { - if (mMangledName.empty()) - mMangledName = buildMangledName(); - return mMangledName; - } size_t objectSize() const { if (mObjectSize == 0) @@ -93,9 +87,8 @@ class TFieldListCollection : angle::NonCopyable mObjectSize(0) { } - TString buildMangledName() const; + TString buildMangledName(const TString &mangledNamePrefix) const; size_t calculateObjectSize() const; - virtual TString mangledNamePrefix() const = 0; const TString *mName; TFieldList *mFields; @@ -124,6 +117,7 @@ class TStructure : public TFieldListCollection return mDeepestNesting; } bool containsArrays() const; + bool containsType(TBasicType t) const; bool containsSamplers() const; bool equals(const TStructure &other) const; @@ -149,6 +143,13 @@ class TStructure : public TFieldListCollection return mAtGlobalScope; } + const TString &mangledName() const + { + if (mMangledName.empty()) + mMangledName = buildMangledName("struct-"); + return mMangledName; + } + private: // TODO(zmo): Find a way to get rid of the const_cast in function // setName(). At the moment keep this function private so only @@ -160,10 +161,6 @@ class TStructure : public TFieldListCollection *mutableName = name; } - virtual TString mangledNamePrefix() const - { - return "struct-"; - } int calculateDeepestNesting() const; mutable int mDeepestNesting; @@ -209,13 +206,14 @@ class TInterfaceBlock : public TFieldListCollection { return mMatrixPacking; } - - private: - virtual TString mangledNamePrefix() const + const TString &mangledName() const { - return "iblock-"; + if (mMangledName.empty()) + mMangledName = buildMangledName("iblock-"); + return mMangledName; } + private: const TString *mInstanceName; // for interface block instance names int mArraySize; // 0 if not an array TLayoutBlockStorage mBlockStorage; @@ -230,10 +228,14 @@ class TType public: POOL_ALLOCATOR_NEW_DELETE(); TType() + : type(EbtVoid), precision(EbpUndefined), qualifier(EvqGlobal), invariant(false), + layoutQualifier(TLayoutQualifier::create()), + primarySize(0), secondarySize(0), array(false), arraySize(0), + interfaceBlock(nullptr), structure(nullptr) { } TType(TBasicType t, unsigned char ps = 1, unsigned char ss = 1) - : type(t), precision(EbpUndefined), qualifier(EvqGlobal), + : type(t), precision(EbpUndefined), qualifier(EvqGlobal), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(false), arraySize(0), interfaceBlock(0), structure(0) @@ -241,7 +243,7 @@ class TType } TType(TBasicType t, TPrecision p, TQualifier q = EvqTemporary, unsigned char ps = 1, unsigned char ss = 1, bool a = false) - : type(t), precision(p), qualifier(q), + : type(t), precision(p), qualifier(q), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(ps), secondarySize(ss), array(a), arraySize(0), interfaceBlock(0), structure(0) @@ -249,7 +251,7 @@ class TType } explicit TType(const TPublicType &p); TType(TStructure *userDef, TPrecision p = EbpUndefined) - : type(EbtStruct), precision(p), qualifier(EvqTemporary), + : type(EbtStruct), precision(p), qualifier(EvqTemporary), invariant(false), layoutQualifier(TLayoutQualifier::create()), primarySize(1), secondarySize(1), array(false), arraySize(0), interfaceBlock(0), structure(userDef) @@ -258,19 +260,26 @@ class TType TType(TInterfaceBlock *interfaceBlockIn, TQualifier qualifierIn, TLayoutQualifier layoutQualifierIn, int arraySizeIn) : type(EbtInterfaceBlock), precision(EbpUndefined), qualifier(qualifierIn), - layoutQualifier(layoutQualifierIn), + invariant(false), layoutQualifier(layoutQualifierIn), primarySize(1), secondarySize(1), array(arraySizeIn > 0), arraySize(arraySizeIn), interfaceBlock(interfaceBlockIn), structure(0) { } + TType(const TType &) = default; + TType &operator=(const TType &) = default; + TBasicType getBasicType() const { return type; } void setBasicType(TBasicType t) { - type = t; + if (type != t) + { + type = t; + invalidateMangledName(); + } } TPrecision getPrecision() const @@ -291,6 +300,11 @@ class TType qualifier = q; } + bool isInvariant() const + { + return invariant; + } + TLayoutQualifier getLayoutQualifier() const { return layoutQualifier; @@ -320,11 +334,19 @@ class TType } void setPrimarySize(unsigned char ps) { - primarySize = ps; + if (primarySize != ps) + { + primarySize = ps; + invalidateMangledName(); + } } void setSecondarySize(unsigned char ss) { - secondarySize = ss; + if (secondarySize != ss) + { + secondarySize = ss; + invalidateMangledName(); + } } // Full size of single instance of type @@ -340,7 +362,11 @@ class TType } bool isArray() const { - return array ? true : false; + return array; + } + bool isUnsizedArray() const + { + return array && arraySize == 0; } int getArraySize() const { @@ -348,13 +374,21 @@ class TType } void setArraySize(int s) { - array = true; - arraySize = s; + if (!array || arraySize != s) + { + array = true; + arraySize = s; + invalidateMangledName(); + } } void clearArrayness() { - array = false; - arraySize = 0; + if (array) + { + array = false; + arraySize = 0; + invalidateMangledName(); + } } TInterfaceBlock *getInterfaceBlock() const @@ -363,7 +397,11 @@ class TType } void setInterfaceBlock(TInterfaceBlock *interfaceBlockIn) { - interfaceBlock = interfaceBlockIn; + if (interfaceBlock != interfaceBlockIn) + { + interfaceBlock = interfaceBlockIn; + invalidateMangledName(); + } } bool isInterfaceBlock() const { @@ -389,10 +427,14 @@ class TType } void setStruct(TStructure *s) { - structure = s; + if (structure != s) + { + structure = s; + invalidateMangledName(); + } } - const TString &getMangledName() + const TString &getMangledName() const { if (mangled.empty()) { @@ -477,19 +519,31 @@ class TType return structure ? structure->containsArrays() : false; } + bool isStructureContainingType(TBasicType t) const + { + return structure ? structure->containsType(t) : false; + } + bool isStructureContainingSamplers() const { return structure ? structure->containsSamplers() : false; } - protected: + // Initializes all lazily-initialized members. + void realize() + { + getMangledName(); + } + + private: + void invalidateMangledName() { mangled = ""; } TString buildMangledName() const; size_t getStructSize() const; - void computeDeepestStructNesting(); TBasicType type; TPrecision precision; TQualifier qualifier; + bool invariant; TLayoutQualifier layoutQualifier; unsigned char primarySize; // size of vector or cols matrix unsigned char secondarySize; // rows of a matrix @@ -519,6 +573,7 @@ struct TPublicType TBasicType type; TLayoutQualifier layoutQualifier; TQualifier qualifier; + bool invariant; TPrecision precision; unsigned char primarySize; // size of vector or cols of matrix unsigned char secondarySize; // rows of matrix @@ -527,11 +582,15 @@ struct TPublicType TType *userDef; TSourceLoc line; + // true if the type was defined by a struct specifier rather than a reference to a type name. + bool isStructSpecifier; + void setBasic(TBasicType bt, TQualifier q, const TSourceLoc &ln) { type = bt; layoutQualifier = TLayoutQualifier::create(); qualifier = q; + invariant = false; precision = EbpUndefined; primarySize = 1; secondarySize = 1; @@ -539,6 +598,7 @@ struct TPublicType arraySize = 0; userDef = 0; line = ln; + isStructSpecifier = false; } void setAggregate(unsigned char size) @@ -553,11 +613,20 @@ struct TPublicType secondarySize = r; } - void setArray(bool a, int s = 0) + bool isUnsizedArray() const { - array = a; + return array && arraySize == 0; + } + void setArraySize(int s) + { + array = true; arraySize = s; } + void clearArrayness() + { + array = false; + arraySize = 0; + } bool isStructureContainingArrays() const { @@ -569,6 +638,16 @@ struct TPublicType return userDef->isStructureContainingArrays(); } + bool isStructureContainingType(TBasicType t) const + { + if (!userDef) + { + return false; + } + + return userDef->isStructureContainingType(t); + } + bool isMatrix() const { return primarySize > 1 && secondarySize > 1; |