1*8975f5c5SAndroid Build Coastguard Worker // 2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2002 The ANGLE Project Authors. All rights reserved. 3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file. 5*8975f5c5SAndroid Build Coastguard Worker // 6*8975f5c5SAndroid Build Coastguard Worker #ifndef COMPILER_TRANSLATOR_PARSECONTEXT_H_ 7*8975f5c5SAndroid Build Coastguard Worker #define COMPILER_TRANSLATOR_PARSECONTEXT_H_ 8*8975f5c5SAndroid Build Coastguard Worker 9*8975f5c5SAndroid Build Coastguard Worker #include "compiler/preprocessor/Preprocessor.h" 10*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/Compiler.h" 11*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/Declarator.h" 12*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/Diagnostics.h" 13*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/DirectiveHandler.h" 14*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/FunctionLookup.h" 15*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/QualifierTypes.h" 16*8975f5c5SAndroid Build Coastguard Worker #include "compiler/translator/SymbolTable.h" 17*8975f5c5SAndroid Build Coastguard Worker 18*8975f5c5SAndroid Build Coastguard Worker namespace sh 19*8975f5c5SAndroid Build Coastguard Worker { 20*8975f5c5SAndroid Build Coastguard Worker 21*8975f5c5SAndroid Build Coastguard Worker struct TMatrixFields 22*8975f5c5SAndroid Build Coastguard Worker { 23*8975f5c5SAndroid Build Coastguard Worker bool wholeRow; 24*8975f5c5SAndroid Build Coastguard Worker bool wholeCol; 25*8975f5c5SAndroid Build Coastguard Worker int row; 26*8975f5c5SAndroid Build Coastguard Worker int col; 27*8975f5c5SAndroid Build Coastguard Worker }; 28*8975f5c5SAndroid Build Coastguard Worker 29*8975f5c5SAndroid Build Coastguard Worker // 30*8975f5c5SAndroid Build Coastguard Worker // The following are extra variables needed during parsing, grouped together so 31*8975f5c5SAndroid Build Coastguard Worker // they can be passed to the parser without needing a global. 32*8975f5c5SAndroid Build Coastguard Worker // 33*8975f5c5SAndroid Build Coastguard Worker class TParseContext : angle::NonCopyable 34*8975f5c5SAndroid Build Coastguard Worker { 35*8975f5c5SAndroid Build Coastguard Worker public: 36*8975f5c5SAndroid Build Coastguard Worker TParseContext(TSymbolTable &symt, 37*8975f5c5SAndroid Build Coastguard Worker TExtensionBehavior &ext, 38*8975f5c5SAndroid Build Coastguard Worker sh::GLenum type, 39*8975f5c5SAndroid Build Coastguard Worker ShShaderSpec spec, 40*8975f5c5SAndroid Build Coastguard Worker const ShCompileOptions &options, 41*8975f5c5SAndroid Build Coastguard Worker TDiagnostics *diagnostics, 42*8975f5c5SAndroid Build Coastguard Worker const ShBuiltInResources &resources, 43*8975f5c5SAndroid Build Coastguard Worker ShShaderOutput outputType); 44*8975f5c5SAndroid Build Coastguard Worker ~TParseContext(); 45*8975f5c5SAndroid Build Coastguard Worker 46*8975f5c5SAndroid Build Coastguard Worker bool anyMultiviewExtensionAvailable(); getPreprocessor()47*8975f5c5SAndroid Build Coastguard Worker const angle::pp::Preprocessor &getPreprocessor() const { return mPreprocessor; } getPreprocessor()48*8975f5c5SAndroid Build Coastguard Worker angle::pp::Preprocessor &getPreprocessor() { return mPreprocessor; } getScanner()49*8975f5c5SAndroid Build Coastguard Worker void *getScanner() const { return mScanner; } setScanner(void * scanner)50*8975f5c5SAndroid Build Coastguard Worker void setScanner(void *scanner) { mScanner = scanner; } getShaderVersion()51*8975f5c5SAndroid Build Coastguard Worker int getShaderVersion() const { return mShaderVersion; } getShaderType()52*8975f5c5SAndroid Build Coastguard Worker sh::GLenum getShaderType() const { return mShaderType; } getShaderSpec()53*8975f5c5SAndroid Build Coastguard Worker ShShaderSpec getShaderSpec() const { return mShaderSpec; } numErrors()54*8975f5c5SAndroid Build Coastguard Worker int numErrors() const { return mDiagnostics->numErrors(); } 55*8975f5c5SAndroid Build Coastguard Worker void error(const TSourceLoc &loc, const char *reason, const char *token); 56*8975f5c5SAndroid Build Coastguard Worker void error(const TSourceLoc &loc, const char *reason, const ImmutableString &token); 57*8975f5c5SAndroid Build Coastguard Worker void warning(const TSourceLoc &loc, const char *reason, const char *token); 58*8975f5c5SAndroid Build Coastguard Worker 59*8975f5c5SAndroid Build Coastguard Worker // If isError is false, a warning will be reported instead. 60*8975f5c5SAndroid Build Coastguard Worker void outOfRangeError(bool isError, 61*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc, 62*8975f5c5SAndroid Build Coastguard Worker const char *reason, 63*8975f5c5SAndroid Build Coastguard Worker const char *token); 64*8975f5c5SAndroid Build Coastguard Worker getTreeRoot()65*8975f5c5SAndroid Build Coastguard Worker TIntermBlock *getTreeRoot() const { return mTreeRoot; } 66*8975f5c5SAndroid Build Coastguard Worker void setTreeRoot(TIntermBlock *treeRoot); 67*8975f5c5SAndroid Build Coastguard Worker getFragmentPrecisionHigh()68*8975f5c5SAndroid Build Coastguard Worker bool getFragmentPrecisionHigh() const 69*8975f5c5SAndroid Build Coastguard Worker { 70*8975f5c5SAndroid Build Coastguard Worker return mFragmentPrecisionHighOnESSL1 || mShaderVersion >= 300; 71*8975f5c5SAndroid Build Coastguard Worker } setFragmentPrecisionHighOnESSL1(bool fragmentPrecisionHigh)72*8975f5c5SAndroid Build Coastguard Worker void setFragmentPrecisionHighOnESSL1(bool fragmentPrecisionHigh) 73*8975f5c5SAndroid Build Coastguard Worker { 74*8975f5c5SAndroid Build Coastguard Worker mFragmentPrecisionHighOnESSL1 = fragmentPrecisionHigh; 75*8975f5c5SAndroid Build Coastguard Worker } 76*8975f5c5SAndroid Build Coastguard Worker usesDerivatives()77*8975f5c5SAndroid Build Coastguard Worker bool usesDerivatives() const { return mUsesDerivatives; } isEarlyFragmentTestsSpecified()78*8975f5c5SAndroid Build Coastguard Worker bool isEarlyFragmentTestsSpecified() const { return mEarlyFragmentTestsSpecified; } hasDiscard()79*8975f5c5SAndroid Build Coastguard Worker bool hasDiscard() const { return mHasDiscard; } isSampleQualifierSpecified()80*8975f5c5SAndroid Build Coastguard Worker bool isSampleQualifierSpecified() const { return mSampleQualifierSpecified; } 81*8975f5c5SAndroid Build Coastguard Worker setLoopNestingLevel(int loopNestintLevel)82*8975f5c5SAndroid Build Coastguard Worker void setLoopNestingLevel(int loopNestintLevel) { mLoopNestingLevel = loopNestintLevel; } 83*8975f5c5SAndroid Build Coastguard Worker incrLoopNestingLevel(const TSourceLoc & line)84*8975f5c5SAndroid Build Coastguard Worker void incrLoopNestingLevel(const TSourceLoc &line) 85*8975f5c5SAndroid Build Coastguard Worker { 86*8975f5c5SAndroid Build Coastguard Worker ++mLoopNestingLevel; 87*8975f5c5SAndroid Build Coastguard Worker checkNestingLevel(line); 88*8975f5c5SAndroid Build Coastguard Worker } decrLoopNestingLevel()89*8975f5c5SAndroid Build Coastguard Worker void decrLoopNestingLevel() { --mLoopNestingLevel; } 90*8975f5c5SAndroid Build Coastguard Worker incrSwitchNestingLevel(const TSourceLoc & line)91*8975f5c5SAndroid Build Coastguard Worker void incrSwitchNestingLevel(const TSourceLoc &line) 92*8975f5c5SAndroid Build Coastguard Worker { 93*8975f5c5SAndroid Build Coastguard Worker ++mSwitchNestingLevel; 94*8975f5c5SAndroid Build Coastguard Worker checkNestingLevel(line); 95*8975f5c5SAndroid Build Coastguard Worker } decrSwitchNestingLevel()96*8975f5c5SAndroid Build Coastguard Worker void decrSwitchNestingLevel() { --mSwitchNestingLevel; } 97*8975f5c5SAndroid Build Coastguard Worker isComputeShaderLocalSizeDeclared()98*8975f5c5SAndroid Build Coastguard Worker bool isComputeShaderLocalSizeDeclared() const { return mComputeShaderLocalSizeDeclared; } 99*8975f5c5SAndroid Build Coastguard Worker sh::WorkGroupSize getComputeShaderLocalSize() const; 100*8975f5c5SAndroid Build Coastguard Worker getNumViews()101*8975f5c5SAndroid Build Coastguard Worker int getNumViews() const { return mNumViews; } 102*8975f5c5SAndroid Build Coastguard Worker pixelLocalStorageFormats()103*8975f5c5SAndroid Build Coastguard Worker const std::map<int, ShPixelLocalStorageFormat> &pixelLocalStorageFormats() const 104*8975f5c5SAndroid Build Coastguard Worker { 105*8975f5c5SAndroid Build Coastguard Worker return mPLSFormats; 106*8975f5c5SAndroid Build Coastguard Worker } 107*8975f5c5SAndroid Build Coastguard Worker enterFunctionDeclaration()108*8975f5c5SAndroid Build Coastguard Worker void enterFunctionDeclaration() { mDeclaringFunction = true; } 109*8975f5c5SAndroid Build Coastguard Worker exitFunctionDeclaration()110*8975f5c5SAndroid Build Coastguard Worker void exitFunctionDeclaration() { mDeclaringFunction = false; } 111*8975f5c5SAndroid Build Coastguard Worker declaringFunction()112*8975f5c5SAndroid Build Coastguard Worker bool declaringFunction() const { return mDeclaringFunction; } 113*8975f5c5SAndroid Build Coastguard Worker 114*8975f5c5SAndroid Build Coastguard Worker TIntermConstantUnion *addScalarLiteral(const TConstantUnion *constantUnion, 115*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &line); 116*8975f5c5SAndroid Build Coastguard Worker 117*8975f5c5SAndroid Build Coastguard Worker // This method is guaranteed to succeed, even if no variable with 'name' exists. 118*8975f5c5SAndroid Build Coastguard Worker const TVariable *getNamedVariable(const TSourceLoc &location, 119*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &name, 120*8975f5c5SAndroid Build Coastguard Worker const TSymbol *symbol); 121*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *parseVariableIdentifier(const TSourceLoc &location, 122*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &name, 123*8975f5c5SAndroid Build Coastguard Worker const TSymbol *symbol); 124*8975f5c5SAndroid Build Coastguard Worker 125*8975f5c5SAndroid Build Coastguard Worker // Look at a '.' field selector string and change it into offsets for a vector. 126*8975f5c5SAndroid Build Coastguard Worker bool parseVectorFields(const TSourceLoc &line, 127*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &compString, 128*8975f5c5SAndroid Build Coastguard Worker int vecSize, 129*8975f5c5SAndroid Build Coastguard Worker TVector<int> *fieldOffsets); 130*8975f5c5SAndroid Build Coastguard Worker 131*8975f5c5SAndroid Build Coastguard Worker void assignError(const TSourceLoc &line, const char *op, const TType &left, const TType &right); 132*8975f5c5SAndroid Build Coastguard Worker void unaryOpError(const TSourceLoc &line, const char *op, const TType &operand); 133*8975f5c5SAndroid Build Coastguard Worker void binaryOpError(const TSourceLoc &line, 134*8975f5c5SAndroid Build Coastguard Worker const char *op, 135*8975f5c5SAndroid Build Coastguard Worker const TType &left, 136*8975f5c5SAndroid Build Coastguard Worker const TType &right); 137*8975f5c5SAndroid Build Coastguard Worker 138*8975f5c5SAndroid Build Coastguard Worker // Check functions - the ones that return bool return false if an error was generated. 139*8975f5c5SAndroid Build Coastguard Worker 140*8975f5c5SAndroid Build Coastguard Worker void checkIsValidExpressionStatement(const TSourceLoc &line, TIntermTyped *expr); 141*8975f5c5SAndroid Build Coastguard Worker bool checkIsNotReserved(const TSourceLoc &line, const ImmutableString &identifier); 142*8975f5c5SAndroid Build Coastguard Worker void checkPrecisionSpecified(const TSourceLoc &line, TPrecision precision, TBasicType type); 143*8975f5c5SAndroid Build Coastguard Worker bool checkCanBeLValue(const TSourceLoc &line, const char *op, TIntermTyped *node); 144*8975f5c5SAndroid Build Coastguard Worker void checkIsConst(TIntermTyped *node); 145*8975f5c5SAndroid Build Coastguard Worker void checkIsScalarInteger(TIntermTyped *node, const char *token); 146*8975f5c5SAndroid Build Coastguard Worker bool checkIsAtGlobalLevel(const TSourceLoc &line, const char *token); 147*8975f5c5SAndroid Build Coastguard Worker bool checkConstructorArguments(const TSourceLoc &line, 148*8975f5c5SAndroid Build Coastguard Worker const TIntermSequence &arguments, 149*8975f5c5SAndroid Build Coastguard Worker const TType &type); 150*8975f5c5SAndroid Build Coastguard Worker 151*8975f5c5SAndroid Build Coastguard Worker // Returns a sanitized array size to use (the size is at least 1). 152*8975f5c5SAndroid Build Coastguard Worker unsigned int checkIsValidArraySize(const TSourceLoc &line, TIntermTyped *expr); 153*8975f5c5SAndroid Build Coastguard Worker bool checkIsValidArrayDimension(const TSourceLoc &line, TVector<unsigned int> *arraySizes); 154*8975f5c5SAndroid Build Coastguard Worker bool checkIsValidQualifierForArray(const TSourceLoc &line, const TPublicType &elementQualifier); 155*8975f5c5SAndroid Build Coastguard Worker bool checkArrayElementIsNotArray(const TSourceLoc &line, const TPublicType &elementType); 156*8975f5c5SAndroid Build Coastguard Worker bool checkArrayOfArraysInOut(const TSourceLoc &line, 157*8975f5c5SAndroid Build Coastguard Worker const TPublicType &elementType, 158*8975f5c5SAndroid Build Coastguard Worker const TType &arrayType); 159*8975f5c5SAndroid Build Coastguard Worker bool checkIsNonVoid(const TSourceLoc &line, 160*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 161*8975f5c5SAndroid Build Coastguard Worker const TBasicType &type); 162*8975f5c5SAndroid Build Coastguard Worker bool checkIsScalarBool(const TSourceLoc &line, const TIntermTyped *type); 163*8975f5c5SAndroid Build Coastguard Worker void checkIsScalarBool(const TSourceLoc &line, const TPublicType &pType); 164*8975f5c5SAndroid Build Coastguard Worker bool checkIsNotOpaqueType(const TSourceLoc &line, 165*8975f5c5SAndroid Build Coastguard Worker const TTypeSpecifierNonArray &pType, 166*8975f5c5SAndroid Build Coastguard Worker const char *reason); 167*8975f5c5SAndroid Build Coastguard Worker void checkDeclaratorLocationIsNotSpecified(const TSourceLoc &line, const TPublicType &pType); 168*8975f5c5SAndroid Build Coastguard Worker void checkLocationIsNotSpecified(const TSourceLoc &location, 169*8975f5c5SAndroid Build Coastguard Worker const TLayoutQualifier &layoutQualifier); 170*8975f5c5SAndroid Build Coastguard Worker void checkStd430IsForShaderStorageBlock(const TSourceLoc &location, 171*8975f5c5SAndroid Build Coastguard Worker const TLayoutBlockStorage &blockStorage, 172*8975f5c5SAndroid Build Coastguard Worker const TQualifier &qualifier); 173*8975f5c5SAndroid Build Coastguard Worker 174*8975f5c5SAndroid Build Coastguard Worker // Check if at least one of the specified extensions can be used, and generate error/warning as 175*8975f5c5SAndroid Build Coastguard Worker // appropriate according to the spec. 176*8975f5c5SAndroid Build Coastguard Worker // This function is only needed for a few different small constant sizes of extension array, and 177*8975f5c5SAndroid Build Coastguard Worker // we want to avoid unnecessary dynamic allocations. That's why checkCanUseOneOfExtensions is a 178*8975f5c5SAndroid Build Coastguard Worker // template function rather than one taking a vector. 179*8975f5c5SAndroid Build Coastguard Worker template <size_t size> 180*8975f5c5SAndroid Build Coastguard Worker bool checkCanUseOneOfExtensions(const TSourceLoc &line, 181*8975f5c5SAndroid Build Coastguard Worker const std::array<TExtension, size> &extensions); 182*8975f5c5SAndroid Build Coastguard Worker bool checkCanUseExtension(const TSourceLoc &line, TExtension extension); 183*8975f5c5SAndroid Build Coastguard Worker 184*8975f5c5SAndroid Build Coastguard Worker // Done for all declarations, whether empty or not. 185*8975f5c5SAndroid Build Coastguard Worker void declarationQualifierErrorCheck(const sh::TQualifier qualifier, 186*8975f5c5SAndroid Build Coastguard Worker const sh::TLayoutQualifier &layoutQualifier, 187*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 188*8975f5c5SAndroid Build Coastguard Worker // Done for the first non-empty declarator in a declaration. 189*8975f5c5SAndroid Build Coastguard Worker void nonEmptyDeclarationErrorCheck(const TPublicType &publicType, 190*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation); 191*8975f5c5SAndroid Build Coastguard Worker // Done only for empty declarations. 192*8975f5c5SAndroid Build Coastguard Worker void emptyDeclarationErrorCheck(const TType &type, const TSourceLoc &location); 193*8975f5c5SAndroid Build Coastguard Worker 194*8975f5c5SAndroid Build Coastguard Worker void checkCanUseLayoutQualifier(const TSourceLoc &location); 195*8975f5c5SAndroid Build Coastguard Worker bool checkLayoutQualifierSupported(const TSourceLoc &location, 196*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &layoutQualifierName, 197*8975f5c5SAndroid Build Coastguard Worker int versionRequired); 198*8975f5c5SAndroid Build Coastguard Worker bool checkWorkGroupSizeIsNotSpecified(const TSourceLoc &location, 199*8975f5c5SAndroid Build Coastguard Worker const TLayoutQualifier &layoutQualifier); 200*8975f5c5SAndroid Build Coastguard Worker void functionCallRValueLValueErrorCheck(const TFunction *fnCandidate, TIntermAggregate *fnCall); 201*8975f5c5SAndroid Build Coastguard Worker void checkInvariantVariableQualifier(bool invariant, 202*8975f5c5SAndroid Build Coastguard Worker const TQualifier qualifier, 203*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &invariantLocation); 204*8975f5c5SAndroid Build Coastguard Worker void checkInputOutputTypeIsValidES3(const TQualifier qualifier, 205*8975f5c5SAndroid Build Coastguard Worker const TPublicType &type, 206*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &qualifierLocation); 207*8975f5c5SAndroid Build Coastguard Worker void checkLocalVariableConstStorageQualifier(const TQualifierWrapperBase &qualifier); 208*8975f5c5SAndroid Build Coastguard Worker void checkTCSOutVarIndexIsValid(TIntermBinary *binaryExpression, const TSourceLoc &location); 209*8975f5c5SAndroid Build Coastguard Worker 210*8975f5c5SAndroid Build Coastguard Worker void checkAdvancedBlendEquationsNotSpecified( 211*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location, 212*8975f5c5SAndroid Build Coastguard Worker const AdvancedBlendEquations &advancedBlendEquations, 213*8975f5c5SAndroid Build Coastguard Worker const TQualifier &qualifier); 214*8975f5c5SAndroid Build Coastguard Worker pragma()215*8975f5c5SAndroid Build Coastguard Worker const TPragma &pragma() const { return mDirectiveHandler.pragma(); } extensionBehavior()216*8975f5c5SAndroid Build Coastguard Worker const TExtensionBehavior &extensionBehavior() const 217*8975f5c5SAndroid Build Coastguard Worker { 218*8975f5c5SAndroid Build Coastguard Worker return mDirectiveHandler.extensionBehavior(); 219*8975f5c5SAndroid Build Coastguard Worker } 220*8975f5c5SAndroid Build Coastguard Worker 221*8975f5c5SAndroid Build Coastguard Worker bool isExtensionEnabled(TExtension extension) const; 222*8975f5c5SAndroid Build Coastguard Worker void handleExtensionDirective(const TSourceLoc &loc, const char *extName, const char *behavior); 223*8975f5c5SAndroid Build Coastguard Worker void handlePragmaDirective(const TSourceLoc &loc, 224*8975f5c5SAndroid Build Coastguard Worker const char *name, 225*8975f5c5SAndroid Build Coastguard Worker const char *value, 226*8975f5c5SAndroid Build Coastguard Worker bool stdgl); 227*8975f5c5SAndroid Build Coastguard Worker 228*8975f5c5SAndroid Build Coastguard Worker // For built-ins that can be redeclared, adjusts the type qualifier so transformations can 229*8975f5c5SAndroid Build Coastguard Worker // identify them correctly. 230*8975f5c5SAndroid Build Coastguard Worker void adjustRedeclaredBuiltInType(const TSourceLoc &line, 231*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 232*8975f5c5SAndroid Build Coastguard Worker TType *type); 233*8975f5c5SAndroid Build Coastguard Worker 234*8975f5c5SAndroid Build Coastguard Worker // Returns true on success. *initNode may still be nullptr on success in case the initialization 235*8975f5c5SAndroid Build Coastguard Worker // is not needed in the AST. 236*8975f5c5SAndroid Build Coastguard Worker bool executeInitializer(const TSourceLoc &line, 237*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 238*8975f5c5SAndroid Build Coastguard Worker TType *type, 239*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer, 240*8975f5c5SAndroid Build Coastguard Worker TIntermBinary **initNode); 241*8975f5c5SAndroid Build Coastguard Worker TIntermNode *addConditionInitializer(const TPublicType &pType, 242*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 243*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer, 244*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 245*8975f5c5SAndroid Build Coastguard Worker TIntermNode *addLoop(TLoopType type, 246*8975f5c5SAndroid Build Coastguard Worker TIntermNode *init, 247*8975f5c5SAndroid Build Coastguard Worker TIntermNode *cond, 248*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *expr, 249*8975f5c5SAndroid Build Coastguard Worker TIntermNode *body, 250*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 251*8975f5c5SAndroid Build Coastguard Worker 252*8975f5c5SAndroid Build Coastguard Worker // For "if" test nodes. There are three children: a condition, a true path, and a false path. 253*8975f5c5SAndroid Build Coastguard Worker // The two paths are in TIntermNodePair code. 254*8975f5c5SAndroid Build Coastguard Worker TIntermNode *addIfElse(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &loc); 255*8975f5c5SAndroid Build Coastguard Worker 256*8975f5c5SAndroid Build Coastguard Worker void addFullySpecifiedType(TPublicType *typeSpecifier); 257*8975f5c5SAndroid Build Coastguard Worker TPublicType addFullySpecifiedType(const TTypeQualifierBuilder &typeQualifierBuilder, 258*8975f5c5SAndroid Build Coastguard Worker const TPublicType &typeSpecifier); 259*8975f5c5SAndroid Build Coastguard Worker 260*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *parseSingleDeclaration(TPublicType &publicType, 261*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierOrTypeLocation, 262*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier); 263*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *parseSingleArrayDeclaration(TPublicType &elementType, 264*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 265*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 266*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &indexLocation, 267*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> &arraySizes); 268*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *parseSingleInitDeclaration(const TPublicType &publicType, 269*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 270*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 271*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &initLocation, 272*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer); 273*8975f5c5SAndroid Build Coastguard Worker 274*8975f5c5SAndroid Build Coastguard Worker // Parse a declaration like "type a[n] = initializer" 275*8975f5c5SAndroid Build Coastguard Worker // Note that this does not apply to declarations like "type[n] a = initializer" 276*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *parseSingleArrayInitDeclaration(TPublicType &elementType, 277*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 278*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 279*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &indexLocation, 280*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> &arraySizes, 281*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &initLocation, 282*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer); 283*8975f5c5SAndroid Build Coastguard Worker 284*8975f5c5SAndroid Build Coastguard Worker TIntermGlobalQualifierDeclaration *parseGlobalQualifierDeclaration( 285*8975f5c5SAndroid Build Coastguard Worker const TTypeQualifierBuilder &typeQualifierBuilder, 286*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLoc, 287*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 288*8975f5c5SAndroid Build Coastguard Worker const TSymbol *symbol); 289*8975f5c5SAndroid Build Coastguard Worker 290*8975f5c5SAndroid Build Coastguard Worker void parseDeclarator(TPublicType &publicType, 291*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 292*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 293*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *declarationOut); 294*8975f5c5SAndroid Build Coastguard Worker void parseArrayDeclarator(TPublicType &elementType, 295*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 296*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 297*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &arrayLocation, 298*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> &arraySizes, 299*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *declarationOut); 300*8975f5c5SAndroid Build Coastguard Worker void parseInitDeclarator(const TPublicType &publicType, 301*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 302*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 303*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &initLocation, 304*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer, 305*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *declarationOut); 306*8975f5c5SAndroid Build Coastguard Worker 307*8975f5c5SAndroid Build Coastguard Worker // Parse a declarator like "a[n] = initializer" 308*8975f5c5SAndroid Build Coastguard Worker void parseArrayInitDeclarator(const TPublicType &elementType, 309*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &identifierLocation, 310*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 311*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &indexLocation, 312*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> &arraySizes, 313*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &initLocation, 314*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *initializer, 315*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *declarationOut); 316*8975f5c5SAndroid Build Coastguard Worker 317*8975f5c5SAndroid Build Coastguard Worker TIntermNode *addEmptyStatement(const TSourceLoc &location); 318*8975f5c5SAndroid Build Coastguard Worker 319*8975f5c5SAndroid Build Coastguard Worker void parseDefaultPrecisionQualifier(const TPrecision precision, 320*8975f5c5SAndroid Build Coastguard Worker const TPublicType &type, 321*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 322*8975f5c5SAndroid Build Coastguard Worker void parseGlobalLayoutQualifier(const TTypeQualifierBuilder &typeQualifierBuilder); 323*8975f5c5SAndroid Build Coastguard Worker 324*8975f5c5SAndroid Build Coastguard Worker TIntermFunctionPrototype *addFunctionPrototypeDeclaration(const TFunction &parsedFunction, 325*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 326*8975f5c5SAndroid Build Coastguard Worker TIntermFunctionDefinition *addFunctionDefinition(TIntermFunctionPrototype *functionPrototype, 327*8975f5c5SAndroid Build Coastguard Worker TIntermBlock *functionBody, 328*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 329*8975f5c5SAndroid Build Coastguard Worker void parseFunctionDefinitionHeader(const TSourceLoc &location, 330*8975f5c5SAndroid Build Coastguard Worker const TFunction *function, 331*8975f5c5SAndroid Build Coastguard Worker TIntermFunctionPrototype **prototypeOut); 332*8975f5c5SAndroid Build Coastguard Worker TFunction *parseFunctionDeclarator(const TSourceLoc &location, TFunction *function); 333*8975f5c5SAndroid Build Coastguard Worker TFunction *parseFunctionHeader(const TPublicType &type, 334*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &name, 335*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 336*8975f5c5SAndroid Build Coastguard Worker 337*8975f5c5SAndroid Build Coastguard Worker TFunctionLookup *addNonConstructorFunc(const ImmutableString &name, const TSymbol *symbol); 338*8975f5c5SAndroid Build Coastguard Worker TFunctionLookup *addConstructorFunc(const TPublicType &publicType); 339*8975f5c5SAndroid Build Coastguard Worker 340*8975f5c5SAndroid Build Coastguard Worker TParameter parseParameterDeclarator(const TPublicType &type, 341*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &name, 342*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &nameLoc); 343*8975f5c5SAndroid Build Coastguard Worker TParameter parseParameterArrayDeclarator(const TPublicType &elementType, 344*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &name, 345*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &nameLoc, 346*8975f5c5SAndroid Build Coastguard Worker TVector<unsigned int> *arraySizes, 347*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &arrayLoc); 348*8975f5c5SAndroid Build Coastguard Worker void parseParameterQualifier(const TSourceLoc &line, 349*8975f5c5SAndroid Build Coastguard Worker const TTypeQualifierBuilder &typeQualifierBuilder, 350*8975f5c5SAndroid Build Coastguard Worker TPublicType &type); 351*8975f5c5SAndroid Build Coastguard Worker 352*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addIndexExpression(TIntermTyped *baseExpression, 353*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location, 354*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *indexExpression); 355*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addFieldSelectionExpression(TIntermTyped *baseExpression, 356*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &dotLocation, 357*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &fieldString, 358*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &fieldLocation); 359*8975f5c5SAndroid Build Coastguard Worker 360*8975f5c5SAndroid Build Coastguard Worker // Parse declarator for a single field 361*8975f5c5SAndroid Build Coastguard Worker TDeclarator *parseStructDeclarator(const ImmutableString &identifier, const TSourceLoc &loc); 362*8975f5c5SAndroid Build Coastguard Worker TDeclarator *parseStructArrayDeclarator(const ImmutableString &identifier, 363*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc, 364*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> *arraySizes); 365*8975f5c5SAndroid Build Coastguard Worker 366*8975f5c5SAndroid Build Coastguard Worker void checkDoesNotHaveDuplicateFieldNames(const TFieldList *fields, const TSourceLoc &location); 367*8975f5c5SAndroid Build Coastguard Worker void checkDoesNotHaveTooManyFields(const ImmutableString &name, 368*8975f5c5SAndroid Build Coastguard Worker const TFieldList *fields, 369*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 370*8975f5c5SAndroid Build Coastguard Worker TFieldList *addStructFieldList(TFieldList *fields, const TSourceLoc &location); 371*8975f5c5SAndroid Build Coastguard Worker TFieldList *combineStructFieldLists(TFieldList *processedFields, 372*8975f5c5SAndroid Build Coastguard Worker const TFieldList *newlyAddedFields, 373*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 374*8975f5c5SAndroid Build Coastguard Worker TFieldList *addStructDeclaratorListWithQualifiers( 375*8975f5c5SAndroid Build Coastguard Worker const TTypeQualifierBuilder &typeQualifierBuilder, 376*8975f5c5SAndroid Build Coastguard Worker TPublicType *typeSpecifier, 377*8975f5c5SAndroid Build Coastguard Worker const TDeclaratorList *declaratorList); 378*8975f5c5SAndroid Build Coastguard Worker TFieldList *addStructDeclaratorList(const TPublicType &typeSpecifier, 379*8975f5c5SAndroid Build Coastguard Worker const TDeclaratorList *declaratorList); 380*8975f5c5SAndroid Build Coastguard Worker TTypeSpecifierNonArray addStructure(const TSourceLoc &structLine, 381*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &nameLine, 382*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &structName, 383*8975f5c5SAndroid Build Coastguard Worker TFieldList *fieldList); 384*8975f5c5SAndroid Build Coastguard Worker 385*8975f5c5SAndroid Build Coastguard Worker TIntermDeclaration *addInterfaceBlock(const TTypeQualifierBuilder &typeQualifierBuilder, 386*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &nameLine, 387*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &blockName, 388*8975f5c5SAndroid Build Coastguard Worker TFieldList *fieldList, 389*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &instanceName, 390*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &instanceLine, 391*8975f5c5SAndroid Build Coastguard Worker const TVector<unsigned int> *arraySizes, 392*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &arraySizesLine); 393*8975f5c5SAndroid Build Coastguard Worker 394*8975f5c5SAndroid Build Coastguard Worker void parseLocalSize(const ImmutableString &qualifierType, 395*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &qualifierTypeLine, 396*8975f5c5SAndroid Build Coastguard Worker int intValue, 397*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 398*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 399*8975f5c5SAndroid Build Coastguard Worker size_t index, 400*8975f5c5SAndroid Build Coastguard Worker sh::WorkGroupSize *localSize); 401*8975f5c5SAndroid Build Coastguard Worker void parseNumViews(int intValue, 402*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 403*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 404*8975f5c5SAndroid Build Coastguard Worker int *numViews); 405*8975f5c5SAndroid Build Coastguard Worker void parseInvocations(int intValue, 406*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 407*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 408*8975f5c5SAndroid Build Coastguard Worker int *numInvocations); 409*8975f5c5SAndroid Build Coastguard Worker void parseMaxVertices(int intValue, 410*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 411*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 412*8975f5c5SAndroid Build Coastguard Worker int *numMaxVertices); 413*8975f5c5SAndroid Build Coastguard Worker void parseVertices(int intValue, 414*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 415*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 416*8975f5c5SAndroid Build Coastguard Worker int *numVertices); 417*8975f5c5SAndroid Build Coastguard Worker void parseIndexLayoutQualifier(int intValue, 418*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine, 419*8975f5c5SAndroid Build Coastguard Worker const std::string &intValueString, 420*8975f5c5SAndroid Build Coastguard Worker int *index); 421*8975f5c5SAndroid Build Coastguard Worker TLayoutQualifier parseLayoutQualifier(const ImmutableString &qualifierType, 422*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &qualifierTypeLine); 423*8975f5c5SAndroid Build Coastguard Worker TLayoutQualifier parseLayoutQualifier(const ImmutableString &qualifierType, 424*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &qualifierTypeLine, 425*8975f5c5SAndroid Build Coastguard Worker int intValue, 426*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &intValueLine); 427*8975f5c5SAndroid Build Coastguard Worker TTypeQualifierBuilder *createTypeQualifierBuilder(const TSourceLoc &loc); 428*8975f5c5SAndroid Build Coastguard Worker TStorageQualifierWrapper *parseGlobalStorageQualifier(TQualifier qualifier, 429*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 430*8975f5c5SAndroid Build Coastguard Worker TStorageQualifierWrapper *parseVaryingQualifier(const TSourceLoc &loc); 431*8975f5c5SAndroid Build Coastguard Worker TStorageQualifierWrapper *parseInQualifier(const TSourceLoc &loc); 432*8975f5c5SAndroid Build Coastguard Worker TStorageQualifierWrapper *parseOutQualifier(const TSourceLoc &loc); 433*8975f5c5SAndroid Build Coastguard Worker TStorageQualifierWrapper *parseInOutQualifier(const TSourceLoc &loc); 434*8975f5c5SAndroid Build Coastguard Worker TLayoutQualifier joinLayoutQualifiers(TLayoutQualifier leftQualifier, 435*8975f5c5SAndroid Build Coastguard Worker TLayoutQualifier rightQualifier, 436*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &rightQualifierLocation); 437*8975f5c5SAndroid Build Coastguard Worker 438*8975f5c5SAndroid Build Coastguard Worker // Performs an error check for embedded struct declarations. 439*8975f5c5SAndroid Build Coastguard Worker void enterStructDeclaration(const TSourceLoc &line, const ImmutableString &identifier); 440*8975f5c5SAndroid Build Coastguard Worker void exitStructDeclaration(); 441*8975f5c5SAndroid Build Coastguard Worker 442*8975f5c5SAndroid Build Coastguard Worker void checkIsBelowStructNestingLimit(const TSourceLoc &line, const TField &field); 443*8975f5c5SAndroid Build Coastguard Worker 444*8975f5c5SAndroid Build Coastguard Worker TIntermSwitch *addSwitch(TIntermTyped *init, 445*8975f5c5SAndroid Build Coastguard Worker TIntermBlock *statementList, 446*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 447*8975f5c5SAndroid Build Coastguard Worker TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &loc); 448*8975f5c5SAndroid Build Coastguard Worker TIntermCase *addDefault(const TSourceLoc &loc); 449*8975f5c5SAndroid Build Coastguard Worker 450*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addUnaryMath(TOperator op, TIntermTyped *child, const TSourceLoc &loc); 451*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addUnaryMathLValue(TOperator op, TIntermTyped *child, const TSourceLoc &loc); 452*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addBinaryMath(TOperator op, 453*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *left, 454*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *right, 455*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 456*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addBinaryMathBooleanResult(TOperator op, 457*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *left, 458*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *right, 459*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 460*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addAssign(TOperator op, 461*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *left, 462*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *right, 463*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 464*8975f5c5SAndroid Build Coastguard Worker 465*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addComma(TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc); 466*8975f5c5SAndroid Build Coastguard Worker 467*8975f5c5SAndroid Build Coastguard Worker TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc); 468*8975f5c5SAndroid Build Coastguard Worker TIntermBranch *addBranch(TOperator op, TIntermTyped *expression, const TSourceLoc &loc); 469*8975f5c5SAndroid Build Coastguard Worker 470*8975f5c5SAndroid Build Coastguard Worker void appendStatement(TIntermBlock *block, TIntermNode *statement); 471*8975f5c5SAndroid Build Coastguard Worker 472*8975f5c5SAndroid Build Coastguard Worker void checkTextureGather(TIntermAggregate *functionCall); 473*8975f5c5SAndroid Build Coastguard Worker void checkTextureOffset(TIntermAggregate *functionCall); 474*8975f5c5SAndroid Build Coastguard Worker void checkImageMemoryAccessForBuiltinFunctions(TIntermAggregate *functionCall); 475*8975f5c5SAndroid Build Coastguard Worker void checkImageMemoryAccessForUserDefinedFunctions(const TFunction *functionDefinition, 476*8975f5c5SAndroid Build Coastguard Worker const TIntermAggregate *functionCall); 477*8975f5c5SAndroid Build Coastguard Worker void checkAtomicMemoryBuiltinFunctions(TIntermAggregate *functionCall); 478*8975f5c5SAndroid Build Coastguard Worker void checkInterpolationFS(TIntermAggregate *functionCall); 479*8975f5c5SAndroid Build Coastguard Worker 480*8975f5c5SAndroid Build Coastguard Worker // fnCall is only storing the built-in op, and function name or constructor type. arguments 481*8975f5c5SAndroid Build Coastguard Worker // has the arguments. 482*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addFunctionCallOrMethod(TFunctionLookup *fnCall, const TSourceLoc &loc); 483*8975f5c5SAndroid Build Coastguard Worker 484*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addTernarySelection(TIntermTyped *cond, 485*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *trueExpression, 486*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *falseExpression, 487*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &line); 488*8975f5c5SAndroid Build Coastguard Worker getGeometryShaderMaxVertices()489*8975f5c5SAndroid Build Coastguard Worker int getGeometryShaderMaxVertices() const { return mGeometryShaderMaxVertices; } getGeometryShaderInvocations()490*8975f5c5SAndroid Build Coastguard Worker int getGeometryShaderInvocations() const 491*8975f5c5SAndroid Build Coastguard Worker { 492*8975f5c5SAndroid Build Coastguard Worker return (mGeometryShaderInvocations > 0) ? mGeometryShaderInvocations : 1; 493*8975f5c5SAndroid Build Coastguard Worker } getGeometryShaderInputPrimitiveType()494*8975f5c5SAndroid Build Coastguard Worker TLayoutPrimitiveType getGeometryShaderInputPrimitiveType() const 495*8975f5c5SAndroid Build Coastguard Worker { 496*8975f5c5SAndroid Build Coastguard Worker return mGeometryShaderInputPrimitiveType; 497*8975f5c5SAndroid Build Coastguard Worker } getGeometryShaderOutputPrimitiveType()498*8975f5c5SAndroid Build Coastguard Worker TLayoutPrimitiveType getGeometryShaderOutputPrimitiveType() const 499*8975f5c5SAndroid Build Coastguard Worker { 500*8975f5c5SAndroid Build Coastguard Worker return mGeometryShaderOutputPrimitiveType; 501*8975f5c5SAndroid Build Coastguard Worker } getTessControlShaderOutputVertices()502*8975f5c5SAndroid Build Coastguard Worker int getTessControlShaderOutputVertices() const { return mTessControlShaderOutputVertices; } getTessEvaluationShaderInputPrimitiveType()503*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType getTessEvaluationShaderInputPrimitiveType() const 504*8975f5c5SAndroid Build Coastguard Worker { 505*8975f5c5SAndroid Build Coastguard Worker return mTessEvaluationShaderInputPrimitiveType; 506*8975f5c5SAndroid Build Coastguard Worker } getTessEvaluationShaderInputVertexSpacingType()507*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType getTessEvaluationShaderInputVertexSpacingType() const 508*8975f5c5SAndroid Build Coastguard Worker { 509*8975f5c5SAndroid Build Coastguard Worker return mTessEvaluationShaderInputVertexSpacingType; 510*8975f5c5SAndroid Build Coastguard Worker } getTessEvaluationShaderInputOrderingType()511*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType getTessEvaluationShaderInputOrderingType() const 512*8975f5c5SAndroid Build Coastguard Worker { 513*8975f5c5SAndroid Build Coastguard Worker return mTessEvaluationShaderInputOrderingType; 514*8975f5c5SAndroid Build Coastguard Worker } getTessEvaluationShaderInputPointType()515*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType getTessEvaluationShaderInputPointType() const 516*8975f5c5SAndroid Build Coastguard Worker { 517*8975f5c5SAndroid Build Coastguard Worker return mTessEvaluationShaderInputPointType; 518*8975f5c5SAndroid Build Coastguard Worker } 519*8975f5c5SAndroid Build Coastguard Worker getDeferredArrayTypesToSize()520*8975f5c5SAndroid Build Coastguard Worker const TVector<TType *> &getDeferredArrayTypesToSize() const 521*8975f5c5SAndroid Build Coastguard Worker { 522*8975f5c5SAndroid Build Coastguard Worker return mDeferredArrayTypesToSize; 523*8975f5c5SAndroid Build Coastguard Worker } 524*8975f5c5SAndroid Build Coastguard Worker markShaderHasPrecise()525*8975f5c5SAndroid Build Coastguard Worker void markShaderHasPrecise() { mHasAnyPreciseType = true; } hasAnyPreciseType()526*8975f5c5SAndroid Build Coastguard Worker bool hasAnyPreciseType() const { return mHasAnyPreciseType; } getAdvancedBlendEquations()527*8975f5c5SAndroid Build Coastguard Worker AdvancedBlendEquations getAdvancedBlendEquations() const { return mAdvancedBlendEquations; } 528*8975f5c5SAndroid Build Coastguard Worker getOutputType()529*8975f5c5SAndroid Build Coastguard Worker ShShaderOutput getOutputType() const { return mOutputType; } 530*8975f5c5SAndroid Build Coastguard Worker getMaxExpressionComplexity()531*8975f5c5SAndroid Build Coastguard Worker size_t getMaxExpressionComplexity() const { return mMaxExpressionComplexity; } getMaxStatementDepth()532*8975f5c5SAndroid Build Coastguard Worker size_t getMaxStatementDepth() const { return mMaxStatementDepth; } 533*8975f5c5SAndroid Build Coastguard Worker 534*8975f5c5SAndroid Build Coastguard Worker // TODO(jmadill): make this private 535*8975f5c5SAndroid Build Coastguard Worker TSymbolTable &symbolTable; // symbol table that goes with the language currently being parsed 536*8975f5c5SAndroid Build Coastguard Worker 537*8975f5c5SAndroid Build Coastguard Worker private: 538*8975f5c5SAndroid Build Coastguard Worker class AtomicCounterBindingState; 539*8975f5c5SAndroid Build Coastguard Worker constexpr static size_t kAtomicCounterSize = 4; 540*8975f5c5SAndroid Build Coastguard Worker // UNIFORM_ARRAY_STRIDE for atomic counter arrays is an implementation-dependent value which 541*8975f5c5SAndroid Build Coastguard Worker // can be queried after a program is linked according to ES 3.10 section 7.7.1. This is 542*8975f5c5SAndroid Build Coastguard Worker // controversial with the offset inheritance as described in ESSL 3.10 section 4.4.6. Currently 543*8975f5c5SAndroid Build Coastguard Worker // we treat it as always 4 in favour of the original interpretation in 544*8975f5c5SAndroid Build Coastguard Worker // "ARB_shader_atomic_counters". 545*8975f5c5SAndroid Build Coastguard Worker // TODO([email protected]): Double check this once the spec vagueness is resolved. 546*8975f5c5SAndroid Build Coastguard Worker // Note that there may be tests in AtomicCounter_test that will need to be updated as well. 547*8975f5c5SAndroid Build Coastguard Worker constexpr static size_t kAtomicCounterArrayStride = 4; 548*8975f5c5SAndroid Build Coastguard Worker 549*8975f5c5SAndroid Build Coastguard Worker void markStaticReadIfSymbol(TIntermNode *node); 550*8975f5c5SAndroid Build Coastguard Worker 551*8975f5c5SAndroid Build Coastguard Worker // Returns a clamped index. If it prints out an error message, the token is "[]". 552*8975f5c5SAndroid Build Coastguard Worker int checkIndexLessThan(bool outOfRangeIndexIsError, 553*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location, 554*8975f5c5SAndroid Build Coastguard Worker int index, 555*8975f5c5SAndroid Build Coastguard Worker unsigned int arraySize, 556*8975f5c5SAndroid Build Coastguard Worker const char *reason); 557*8975f5c5SAndroid Build Coastguard Worker 558*8975f5c5SAndroid Build Coastguard Worker bool declareVariable(const TSourceLoc &line, 559*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 560*8975f5c5SAndroid Build Coastguard Worker const TType *type, 561*8975f5c5SAndroid Build Coastguard Worker TVariable **variable); 562*8975f5c5SAndroid Build Coastguard Worker 563*8975f5c5SAndroid Build Coastguard Worker void checkNestingLevel(const TSourceLoc &line); 564*8975f5c5SAndroid Build Coastguard Worker 565*8975f5c5SAndroid Build Coastguard Worker void checkCanBeDeclaredWithoutInitializer(const TSourceLoc &line, 566*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 567*8975f5c5SAndroid Build Coastguard Worker TType *type); 568*8975f5c5SAndroid Build Coastguard Worker void checkDeclarationIsValidArraySize(const TSourceLoc &line, 569*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &identifier, 570*8975f5c5SAndroid Build Coastguard Worker TType *type); 571*8975f5c5SAndroid Build Coastguard Worker bool checkIsValidTypeAndQualifierForArray(const TSourceLoc &indexLocation, 572*8975f5c5SAndroid Build Coastguard Worker const TPublicType &elementType); 573*8975f5c5SAndroid Build Coastguard Worker // Done for all atomic counter declarations, whether empty or not. 574*8975f5c5SAndroid Build Coastguard Worker void atomicCounterQualifierErrorCheck(const TPublicType &publicType, 575*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 576*8975f5c5SAndroid Build Coastguard Worker 577*8975f5c5SAndroid Build Coastguard Worker // Assumes that multiplication op has already been set based on the types. 578*8975f5c5SAndroid Build Coastguard Worker bool isMultiplicationTypeCombinationValid(TOperator op, const TType &left, const TType &right); 579*8975f5c5SAndroid Build Coastguard Worker 580*8975f5c5SAndroid Build Coastguard Worker void checkInternalFormatIsNotSpecified(const TSourceLoc &location, 581*8975f5c5SAndroid Build Coastguard Worker TLayoutImageInternalFormat internalFormat); 582*8975f5c5SAndroid Build Coastguard Worker void checkMemoryQualifierIsNotSpecified(const TMemoryQualifier &memoryQualifier, 583*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 584*8975f5c5SAndroid Build Coastguard Worker 585*8975f5c5SAndroid Build Coastguard Worker void checkAtomicCounterOffsetIsValid(bool forceAppend, const TSourceLoc &loc, TType *type); 586*8975f5c5SAndroid Build Coastguard Worker void checkAtomicCounterOffsetDoesNotOverlap(bool forceAppend, 587*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc, 588*8975f5c5SAndroid Build Coastguard Worker TType *type); 589*8975f5c5SAndroid Build Coastguard Worker void checkAtomicCounterOffsetAlignment(const TSourceLoc &location, const TType &type); 590*8975f5c5SAndroid Build Coastguard Worker void checkAtomicCounterOffsetLimit(const TSourceLoc &location, const TType &type); 591*8975f5c5SAndroid Build Coastguard Worker 592*8975f5c5SAndroid Build Coastguard Worker void checkIndexIsNotSpecified(const TSourceLoc &location, int index); 593*8975f5c5SAndroid Build Coastguard Worker void checkBindingIsValid(const TSourceLoc &identifierLocation, const TType &type); 594*8975f5c5SAndroid Build Coastguard Worker void checkBindingIsNotSpecified(const TSourceLoc &location, int binding); 595*8975f5c5SAndroid Build Coastguard Worker void checkOffsetIsNotSpecified(const TSourceLoc &location, int offset); 596*8975f5c5SAndroid Build Coastguard Worker void checkImageBindingIsValid(const TSourceLoc &location, 597*8975f5c5SAndroid Build Coastguard Worker int binding, 598*8975f5c5SAndroid Build Coastguard Worker int arrayTotalElementCount); 599*8975f5c5SAndroid Build Coastguard Worker void checkSamplerBindingIsValid(const TSourceLoc &location, 600*8975f5c5SAndroid Build Coastguard Worker int binding, 601*8975f5c5SAndroid Build Coastguard Worker int arrayTotalElementCount); 602*8975f5c5SAndroid Build Coastguard Worker void checkBlockBindingIsValid(const TSourceLoc &location, 603*8975f5c5SAndroid Build Coastguard Worker const TQualifier &qualifier, 604*8975f5c5SAndroid Build Coastguard Worker int binding, 605*8975f5c5SAndroid Build Coastguard Worker int arraySize); 606*8975f5c5SAndroid Build Coastguard Worker void checkAtomicCounterBindingIsValid(const TSourceLoc &location, int binding); 607*8975f5c5SAndroid Build Coastguard Worker void checkPixelLocalStorageBindingIsValid(const TSourceLoc &, const TType &); 608*8975f5c5SAndroid Build Coastguard Worker 609*8975f5c5SAndroid Build Coastguard Worker void checkUniformLocationInRange(const TSourceLoc &location, 610*8975f5c5SAndroid Build Coastguard Worker int objectLocationCount, 611*8975f5c5SAndroid Build Coastguard Worker const TLayoutQualifier &layoutQualifier); 612*8975f5c5SAndroid Build Coastguard Worker void checkAttributeLocationInRange(const TSourceLoc &location, 613*8975f5c5SAndroid Build Coastguard Worker int objectLocationCount, 614*8975f5c5SAndroid Build Coastguard Worker const TLayoutQualifier &layoutQualifier); 615*8975f5c5SAndroid Build Coastguard Worker 616*8975f5c5SAndroid Build Coastguard Worker void checkDepthIsNotSpecified(const TSourceLoc &location, TLayoutDepth depth); 617*8975f5c5SAndroid Build Coastguard Worker 618*8975f5c5SAndroid Build Coastguard Worker void checkYuvIsNotSpecified(const TSourceLoc &location, bool yuv); 619*8975f5c5SAndroid Build Coastguard Worker 620*8975f5c5SAndroid Build Coastguard Worker void checkEarlyFragmentTestsIsNotSpecified(const TSourceLoc &location, bool earlyFragmentTests); 621*8975f5c5SAndroid Build Coastguard Worker 622*8975f5c5SAndroid Build Coastguard Worker void checkNoncoherentIsSpecified(const TSourceLoc &location, bool noncoherent); 623*8975f5c5SAndroid Build Coastguard Worker 624*8975f5c5SAndroid Build Coastguard Worker void checkNoncoherentIsNotSpecified(const TSourceLoc &location, bool noncoherent); 625*8975f5c5SAndroid Build Coastguard Worker 626*8975f5c5SAndroid Build Coastguard Worker bool checkUnsizedArrayConstructorArgumentDimensionality(const TIntermSequence &arguments, 627*8975f5c5SAndroid Build Coastguard Worker TType type, 628*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &line); 629*8975f5c5SAndroid Build Coastguard Worker 630*8975f5c5SAndroid Build Coastguard Worker // Check texture offset is within range. 631*8975f5c5SAndroid Build Coastguard Worker void checkSingleTextureOffset(const TSourceLoc &line, 632*8975f5c5SAndroid Build Coastguard Worker const TConstantUnion *values, 633*8975f5c5SAndroid Build Coastguard Worker size_t size, 634*8975f5c5SAndroid Build Coastguard Worker int minOffsetValue, 635*8975f5c5SAndroid Build Coastguard Worker int maxOffsetValue); 636*8975f5c5SAndroid Build Coastguard Worker 637*8975f5c5SAndroid Build Coastguard Worker // Will set the size of the outermost array according to geometry shader input layout. 638*8975f5c5SAndroid Build Coastguard Worker void checkGeometryShaderInputAndSetArraySize(const TSourceLoc &location, 639*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &token, 640*8975f5c5SAndroid Build Coastguard Worker TType *type); 641*8975f5c5SAndroid Build Coastguard Worker 642*8975f5c5SAndroid Build Coastguard Worker // Similar, for tessellation shaders. 643*8975f5c5SAndroid Build Coastguard Worker void checkTessellationShaderUnsizedArraysAndSetSize(const TSourceLoc &location, 644*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &token, 645*8975f5c5SAndroid Build Coastguard Worker TType *type); 646*8975f5c5SAndroid Build Coastguard Worker 647*8975f5c5SAndroid Build Coastguard Worker // Will size any unsized array type so unsized arrays won't need to be taken into account 648*8975f5c5SAndroid Build Coastguard Worker // further along the line in parsing. 649*8975f5c5SAndroid Build Coastguard Worker void checkIsNotUnsizedArray(const TSourceLoc &line, 650*8975f5c5SAndroid Build Coastguard Worker const char *errorMessage, 651*8975f5c5SAndroid Build Coastguard Worker const ImmutableString &token, 652*8975f5c5SAndroid Build Coastguard Worker TType *arrayType); 653*8975f5c5SAndroid Build Coastguard Worker 654*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addBinaryMathInternal(TOperator op, 655*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *left, 656*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *right, 657*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 658*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *createUnaryMath(TOperator op, 659*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *child, 660*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc, 661*8975f5c5SAndroid Build Coastguard Worker const TFunction *func); 662*8975f5c5SAndroid Build Coastguard Worker 663*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addMethod(TFunctionLookup *fnCall, const TSourceLoc &loc); 664*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addConstructor(TFunctionLookup *fnCall, const TSourceLoc &line); 665*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addNonConstructorFunctionCallImpl(TFunctionLookup *fnCall, const TSourceLoc &loc); 666*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *addNonConstructorFunctionCall(TFunctionLookup *fnCall, const TSourceLoc &loc); 667*8975f5c5SAndroid Build Coastguard Worker 668*8975f5c5SAndroid Build Coastguard Worker // Return either the original expression or the folded version of the expression in case the 669*8975f5c5SAndroid Build Coastguard Worker // folded node will validate the same way during subsequent parsing. 670*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *expressionOrFoldedResult(TIntermTyped *expression); 671*8975f5c5SAndroid Build Coastguard Worker 672*8975f5c5SAndroid Build Coastguard Worker // Return true if the checks pass 673*8975f5c5SAndroid Build Coastguard Worker bool binaryOpCommonCheck(TOperator op, 674*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *left, 675*8975f5c5SAndroid Build Coastguard Worker TIntermTyped *right, 676*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &loc); 677*8975f5c5SAndroid Build Coastguard Worker 678*8975f5c5SAndroid Build Coastguard Worker TIntermFunctionPrototype *createPrototypeNodeFromFunction(const TFunction &function, 679*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location, 680*8975f5c5SAndroid Build Coastguard Worker bool insertParametersToSymbolTable); 681*8975f5c5SAndroid Build Coastguard Worker 682*8975f5c5SAndroid Build Coastguard Worker void setAtomicCounterBindingDefaultOffset(const TPublicType &declaration, 683*8975f5c5SAndroid Build Coastguard Worker const TSourceLoc &location); 684*8975f5c5SAndroid Build Coastguard Worker 685*8975f5c5SAndroid Build Coastguard Worker bool checkPrimitiveTypeMatchesTypeQualifier(const TTypeQualifier &typeQualifier); 686*8975f5c5SAndroid Build Coastguard Worker bool parseGeometryShaderInputLayoutQualifier(const TTypeQualifier &typeQualifier); 687*8975f5c5SAndroid Build Coastguard Worker bool parseGeometryShaderOutputLayoutQualifier(const TTypeQualifier &typeQualifier); 688*8975f5c5SAndroid Build Coastguard Worker void setGeometryShaderInputArraySize(unsigned int inputArraySize, const TSourceLoc &line); 689*8975f5c5SAndroid Build Coastguard Worker 690*8975f5c5SAndroid Build Coastguard Worker bool parseTessControlShaderOutputLayoutQualifier(const TTypeQualifier &typeQualifier); 691*8975f5c5SAndroid Build Coastguard Worker bool parseTessEvaluationShaderInputLayoutQualifier(const TTypeQualifier &typeQualifier); 692*8975f5c5SAndroid Build Coastguard Worker 693*8975f5c5SAndroid Build Coastguard Worker // Certain operations become illegal only iff the shader declares pixel local storage uniforms. 694*8975f5c5SAndroid Build Coastguard Worker enum class PLSIllegalOperations 695*8975f5c5SAndroid Build Coastguard Worker { 696*8975f5c5SAndroid Build Coastguard Worker // When polyfilled with shader images, pixel local storage requires early_fragment_tests, 697*8975f5c5SAndroid Build Coastguard Worker // which causes discard to interact differently with the depth and stencil tests. 698*8975f5c5SAndroid Build Coastguard Worker // 699*8975f5c5SAndroid Build Coastguard Worker // To ensure identical behavior across all backends (some of which may not have access to 700*8975f5c5SAndroid Build Coastguard Worker // early_fragment_tests), we disallow discard if pixel local storage uniforms have been 701*8975f5c5SAndroid Build Coastguard Worker // declared. 702*8975f5c5SAndroid Build Coastguard Worker Discard, 703*8975f5c5SAndroid Build Coastguard Worker 704*8975f5c5SAndroid Build Coastguard Worker // ARB_fragment_shader_interlock functions cannot be called within flow control, which 705*8975f5c5SAndroid Build Coastguard Worker // includes any code that might execute after a return statement. To keep things simple, and 706*8975f5c5SAndroid Build Coastguard Worker // since these "interlock" calls are automatically injected by the compiler inside of 707*8975f5c5SAndroid Build Coastguard Worker // main(), we disallow return from main() if pixel local storage uniforms have been 708*8975f5c5SAndroid Build Coastguard Worker // declared. 709*8975f5c5SAndroid Build Coastguard Worker ReturnFromMain, 710*8975f5c5SAndroid Build Coastguard Worker 711*8975f5c5SAndroid Build Coastguard Worker // When polyfilled with shader images, pixel local storage requires early_fragment_tests, 712*8975f5c5SAndroid Build Coastguard Worker // which causes assignments to gl_FragDepth(EXT) and gl_SampleMask to be ignored. 713*8975f5c5SAndroid Build Coastguard Worker // 714*8975f5c5SAndroid Build Coastguard Worker // To ensure identical behavior across all backends, we disallow assignment to these values 715*8975f5c5SAndroid Build Coastguard Worker // if pixel local storage uniforms have been declared. 716*8975f5c5SAndroid Build Coastguard Worker AssignFragDepth, 717*8975f5c5SAndroid Build Coastguard Worker AssignSampleMask, 718*8975f5c5SAndroid Build Coastguard Worker 719*8975f5c5SAndroid Build Coastguard Worker // EXT_blend_func_extended may restrict the number of draw buffers with a nonzero output 720*8975f5c5SAndroid Build Coastguard Worker // index, which can invalidate a PLS implementation. 721*8975f5c5SAndroid Build Coastguard Worker FragDataIndexNonzero, 722*8975f5c5SAndroid Build Coastguard Worker 723*8975f5c5SAndroid Build Coastguard Worker // KHR_blend_equation_advanced is incompatible with multiple draw buffers, which is a 724*8975f5c5SAndroid Build Coastguard Worker // required feature for many PLS implementations. 725*8975f5c5SAndroid Build Coastguard Worker EnableAdvancedBlendEquation, 726*8975f5c5SAndroid Build Coastguard Worker }; 727*8975f5c5SAndroid Build Coastguard Worker 728*8975f5c5SAndroid Build Coastguard Worker // Generates an error if any pixel local storage uniforms have been declared (more specifically, 729*8975f5c5SAndroid Build Coastguard Worker // if mPLSFormats is not empty). 730*8975f5c5SAndroid Build Coastguard Worker // 731*8975f5c5SAndroid Build Coastguard Worker // If no pixel local storage uniforms have been declared, and if the PLS extension is enabled, 732*8975f5c5SAndroid Build Coastguard Worker // saves the potential error to mPLSPotentialErrors in case we encounter a PLS uniform later. 733*8975f5c5SAndroid Build Coastguard Worker void errorIfPLSDeclared(const TSourceLoc &, PLSIllegalOperations); 734*8975f5c5SAndroid Build Coastguard Worker 735*8975f5c5SAndroid Build Coastguard Worker // Set to true when the last/current declarator list was started with an empty declaration. The 736*8975f5c5SAndroid Build Coastguard Worker // non-empty declaration error check will need to be performed if the empty declaration is 737*8975f5c5SAndroid Build Coastguard Worker // followed by a declarator. 738*8975f5c5SAndroid Build Coastguard Worker bool mDeferredNonEmptyDeclarationErrorCheck; 739*8975f5c5SAndroid Build Coastguard Worker 740*8975f5c5SAndroid Build Coastguard Worker sh::GLenum mShaderType; // vertex/fragment/geometry/etc shader 741*8975f5c5SAndroid Build Coastguard Worker ShShaderSpec mShaderSpec; // The language specification compiler conforms to - GLES/WebGL/etc. 742*8975f5c5SAndroid Build Coastguard Worker ShCompileOptions mCompileOptions; // Options passed to TCompiler 743*8975f5c5SAndroid Build Coastguard Worker int mShaderVersion; 744*8975f5c5SAndroid Build Coastguard Worker TIntermBlock *mTreeRoot; // root of parse tree being created 745*8975f5c5SAndroid Build Coastguard Worker int mLoopNestingLevel; // 0 if outside all loops 746*8975f5c5SAndroid Build Coastguard Worker int mStructNestingLevel; // incremented while parsing a struct declaration 747*8975f5c5SAndroid Build Coastguard Worker int mSwitchNestingLevel; // 0 if outside all switch statements 748*8975f5c5SAndroid Build Coastguard Worker const TType 749*8975f5c5SAndroid Build Coastguard Worker *mCurrentFunctionType; // the return type of the function that's currently being parsed 750*8975f5c5SAndroid Build Coastguard Worker bool mFunctionReturnsValue; // true if a non-void function has a return 751*8975f5c5SAndroid Build Coastguard Worker bool mFragmentPrecisionHighOnESSL1; // true if highp precision is supported when compiling 752*8975f5c5SAndroid Build Coastguard Worker // ESSL1. 753*8975f5c5SAndroid Build Coastguard Worker bool mEarlyFragmentTestsSpecified; // true if layout(early_fragment_tests) in; is specified. 754*8975f5c5SAndroid Build Coastguard Worker bool mHasDiscard; // true if |discard| is encountered in the shader. 755*8975f5c5SAndroid Build Coastguard Worker bool mSampleQualifierSpecified; // true if the |sample| qualifier is used 756*8975f5c5SAndroid Build Coastguard Worker bool mPositionRedeclaredForSeparateShaderObject; // true if EXT_separate_shader_objects is 757*8975f5c5SAndroid Build Coastguard Worker // enabled and gl_Position is redefined. 758*8975f5c5SAndroid Build Coastguard Worker bool mPointSizeRedeclaredForSeparateShaderObject; // true if EXT_separate_shader_objects is 759*8975f5c5SAndroid Build Coastguard Worker // enabled and gl_PointSize is redefined. 760*8975f5c5SAndroid Build Coastguard Worker bool mPositionOrPointSizeUsedForSeparateShaderObject; // true if gl_Position or gl_PointSize 761*8975f5c5SAndroid Build Coastguard Worker // has been referenced. 762*8975f5c5SAndroid Build Coastguard Worker bool mUsesDerivatives; // true if screen-space derivatives are used implicitly or explicitly 763*8975f5c5SAndroid Build Coastguard Worker TLayoutMatrixPacking mDefaultUniformMatrixPacking; 764*8975f5c5SAndroid Build Coastguard Worker TLayoutBlockStorage mDefaultUniformBlockStorage; 765*8975f5c5SAndroid Build Coastguard Worker TLayoutMatrixPacking mDefaultBufferMatrixPacking; 766*8975f5c5SAndroid Build Coastguard Worker TLayoutBlockStorage mDefaultBufferBlockStorage; 767*8975f5c5SAndroid Build Coastguard Worker TString mHashErrMsg; 768*8975f5c5SAndroid Build Coastguard Worker TDiagnostics *mDiagnostics; 769*8975f5c5SAndroid Build Coastguard Worker TDirectiveHandler mDirectiveHandler; 770*8975f5c5SAndroid Build Coastguard Worker angle::pp::Preprocessor mPreprocessor; 771*8975f5c5SAndroid Build Coastguard Worker void *mScanner; 772*8975f5c5SAndroid Build Coastguard Worker const size_t mMaxExpressionComplexity; 773*8975f5c5SAndroid Build Coastguard Worker const size_t mMaxStatementDepth; 774*8975f5c5SAndroid Build Coastguard Worker int mMinProgramTexelOffset; 775*8975f5c5SAndroid Build Coastguard Worker int mMaxProgramTexelOffset; 776*8975f5c5SAndroid Build Coastguard Worker 777*8975f5c5SAndroid Build Coastguard Worker int mMinProgramTextureGatherOffset; 778*8975f5c5SAndroid Build Coastguard Worker int mMaxProgramTextureGatherOffset; 779*8975f5c5SAndroid Build Coastguard Worker 780*8975f5c5SAndroid Build Coastguard Worker // keep track of local group size declared in layout. It should be declared only once. 781*8975f5c5SAndroid Build Coastguard Worker bool mComputeShaderLocalSizeDeclared; 782*8975f5c5SAndroid Build Coastguard Worker sh::WorkGroupSize mComputeShaderLocalSize; 783*8975f5c5SAndroid Build Coastguard Worker // keep track of number of views declared in layout. 784*8975f5c5SAndroid Build Coastguard Worker int mNumViews; 785*8975f5c5SAndroid Build Coastguard Worker int mMaxNumViews; 786*8975f5c5SAndroid Build Coastguard Worker int mMaxImageUnits; 787*8975f5c5SAndroid Build Coastguard Worker int mMaxCombinedTextureImageUnits; 788*8975f5c5SAndroid Build Coastguard Worker int mMaxUniformLocations; 789*8975f5c5SAndroid Build Coastguard Worker int mMaxUniformBufferBindings; 790*8975f5c5SAndroid Build Coastguard Worker int mMaxVertexAttribs; 791*8975f5c5SAndroid Build Coastguard Worker int mMaxAtomicCounterBindings; 792*8975f5c5SAndroid Build Coastguard Worker int mMaxAtomicCounterBufferSize; 793*8975f5c5SAndroid Build Coastguard Worker int mMaxShaderStorageBufferBindings; 794*8975f5c5SAndroid Build Coastguard Worker int mMaxPixelLocalStoragePlanes; 795*8975f5c5SAndroid Build Coastguard Worker 796*8975f5c5SAndroid Build Coastguard Worker // keeps track whether we are declaring / defining a function 797*8975f5c5SAndroid Build Coastguard Worker bool mDeclaringFunction; 798*8975f5c5SAndroid Build Coastguard Worker 799*8975f5c5SAndroid Build Coastguard Worker // keeps track whether we are declaring / defining the function main(). 800*8975f5c5SAndroid Build Coastguard Worker bool mDeclaringMain; 801*8975f5c5SAndroid Build Coastguard Worker 802*8975f5c5SAndroid Build Coastguard Worker // Track the state of each atomic counter binding. 803*8975f5c5SAndroid Build Coastguard Worker std::map<int, AtomicCounterBindingState> mAtomicCounterBindingStates; 804*8975f5c5SAndroid Build Coastguard Worker 805*8975f5c5SAndroid Build Coastguard Worker // Track the format of each pixel local storage binding. 806*8975f5c5SAndroid Build Coastguard Worker std::map<int, ShPixelLocalStorageFormat> mPLSFormats; 807*8975f5c5SAndroid Build Coastguard Worker 808*8975f5c5SAndroid Build Coastguard Worker // Potential errors to generate immediately upon encountering a pixel local storage uniform. 809*8975f5c5SAndroid Build Coastguard Worker std::vector<std::tuple<const TSourceLoc, PLSIllegalOperations>> mPLSPotentialErrors; 810*8975f5c5SAndroid Build Coastguard Worker 811*8975f5c5SAndroid Build Coastguard Worker // Track the geometry shader global parameters declared in layout. 812*8975f5c5SAndroid Build Coastguard Worker TLayoutPrimitiveType mGeometryShaderInputPrimitiveType; 813*8975f5c5SAndroid Build Coastguard Worker TLayoutPrimitiveType mGeometryShaderOutputPrimitiveType; 814*8975f5c5SAndroid Build Coastguard Worker int mGeometryShaderInvocations; 815*8975f5c5SAndroid Build Coastguard Worker int mGeometryShaderMaxVertices; 816*8975f5c5SAndroid Build Coastguard Worker int mMaxGeometryShaderInvocations; 817*8975f5c5SAndroid Build Coastguard Worker int mMaxGeometryShaderMaxVertices; 818*8975f5c5SAndroid Build Coastguard Worker unsigned int mGeometryInputArraySize; 819*8975f5c5SAndroid Build Coastguard Worker 820*8975f5c5SAndroid Build Coastguard Worker int mMaxPatchVertices; 821*8975f5c5SAndroid Build Coastguard Worker int mTessControlShaderOutputVertices; 822*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType mTessEvaluationShaderInputPrimitiveType; 823*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType mTessEvaluationShaderInputVertexSpacingType; 824*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType mTessEvaluationShaderInputOrderingType; 825*8975f5c5SAndroid Build Coastguard Worker TLayoutTessEvaluationType mTessEvaluationShaderInputPointType; 826*8975f5c5SAndroid Build Coastguard Worker // List of array declarations without an explicit size that have come before layout(vertices=N). 827*8975f5c5SAndroid Build Coastguard Worker // Once the vertex count is specified, these arrays are sized. 828*8975f5c5SAndroid Build Coastguard Worker TVector<TType *> mDeferredArrayTypesToSize; 829*8975f5c5SAndroid Build Coastguard Worker // Whether the |precise| keyword has been seen in the shader. 830*8975f5c5SAndroid Build Coastguard Worker bool mHasAnyPreciseType; 831*8975f5c5SAndroid Build Coastguard Worker 832*8975f5c5SAndroid Build Coastguard Worker AdvancedBlendEquations mAdvancedBlendEquations; 833*8975f5c5SAndroid Build Coastguard Worker 834*8975f5c5SAndroid Build Coastguard Worker // Track when we add new scope for func body in ESSL 1.00 spec 835*8975f5c5SAndroid Build Coastguard Worker bool mFunctionBodyNewScope; 836*8975f5c5SAndroid Build Coastguard Worker 837*8975f5c5SAndroid Build Coastguard Worker ShShaderOutput mOutputType; 838*8975f5c5SAndroid Build Coastguard Worker }; 839*8975f5c5SAndroid Build Coastguard Worker 840*8975f5c5SAndroid Build Coastguard Worker int PaParseStrings(size_t count, 841*8975f5c5SAndroid Build Coastguard Worker const char *const string[], 842*8975f5c5SAndroid Build Coastguard Worker const int length[], 843*8975f5c5SAndroid Build Coastguard Worker TParseContext *context); 844*8975f5c5SAndroid Build Coastguard Worker 845*8975f5c5SAndroid Build Coastguard Worker } // namespace sh 846*8975f5c5SAndroid Build Coastguard Worker 847*8975f5c5SAndroid Build Coastguard Worker #endif // COMPILER_TRANSLATOR_PARSECONTEXT_H_ 848