zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | #ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |
| 8 | #define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |
| 9 | |
| 10 | #include <set> |
| 11 | |
| 12 | #include "compiler/ForLoopUnroll.h" |
| 13 | #include "compiler/intermediate.h" |
| 14 | #include "compiler/ParseHelper.h" |
| 15 | |
| 16 | class TOutputGLSLBase : public TIntermTraverser |
| 17 | { |
| 18 | public: |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 19 | TOutputGLSLBase(TInfoSinkBase& objSink, |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame^] | 20 | ShArrayIndexClampingStrategy clampingStrategy, |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 21 | ShHashFunction64 hashFunction, |
| 22 | NameMap& nameMap, |
| 23 | TSymbolTable& symbolTable); |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 24 | |
| 25 | protected: |
| 26 | TInfoSinkBase& objSink() { return mObjSink; } |
| 27 | void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr); |
| 28 | void writeVariableType(const TType& type); |
| 29 | virtual bool writeVariablePrecision(TPrecision precision) = 0; |
| 30 | void writeFunctionParameters(const TIntermSequence& args); |
| 31 | const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 32 | TString getTypeName(const TType& type); |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 33 | |
| 34 | virtual void visitSymbol(TIntermSymbol* node); |
| 35 | virtual void visitConstantUnion(TIntermConstantUnion* node); |
| 36 | virtual bool visitBinary(Visit visit, TIntermBinary* node); |
| 37 | virtual bool visitUnary(Visit visit, TIntermUnary* node); |
| 38 | virtual bool visitSelection(Visit visit, TIntermSelection* node); |
| 39 | virtual bool visitAggregate(Visit visit, TIntermAggregate* node); |
| 40 | virtual bool visitLoop(Visit visit, TIntermLoop* node); |
| 41 | virtual bool visitBranch(Visit visit, TIntermBranch* node); |
| 42 | |
| 43 | void visitCodeBlock(TIntermNode* node); |
| 44 | |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 45 | |
| 46 | // Return the original name if hash function pointer is NULL; |
| 47 | // otherwise return the hashed name. |
| 48 | TString hashName(const TString& name); |
| 49 | // Same as hashName(), but without hashing built-in variables. |
| 50 | TString hashVariableName(const TString& name); |
| 51 | // Same as hashName(), but without hashing built-in functions. |
| 52 | TString hashFunctionName(const TString& mangled_name); |
| 53 | |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 54 | private: |
| 55 | TInfoSinkBase& mObjSink; |
| 56 | bool mDeclaringVariables; |
| 57 | |
| 58 | // Structs are declared as the tree is traversed. This set contains all |
| 59 | // the structs already declared. It is maintained so that a struct is |
| 60 | // declared only once. |
| 61 | typedef std::set<TString> DeclaredStructs; |
| 62 | DeclaredStructs mDeclaredStructs; |
| 63 | |
| 64 | ForLoopUnroll mLoopUnroll; |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 65 | |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame^] | 66 | ShArrayIndexClampingStrategy mClampingStrategy; |
| 67 | |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 68 | // name hashing. |
| 69 | ShHashFunction64 mHashFunction; |
shannon.woods@transgaming.com | 1d432bb | 2013-01-25 21:57:28 +0000 | [diff] [blame^] | 70 | |
daniel@transgaming.com | 0aa3b5a | 2012-11-28 19:43:24 +0000 | [diff] [blame] | 71 | NameMap& mNameMap; |
| 72 | |
| 73 | TSymbolTable& mSymbolTable; |
zmo@google.com | 5601ea0 | 2011-06-10 18:23:25 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | #endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ |