1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/OutputGLSLBase.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 1.4 +// 1.5 +// Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#ifndef CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ 1.11 +#define CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_ 1.12 + 1.13 +#include <set> 1.14 + 1.15 +#include "compiler/ForLoopUnroll.h" 1.16 +#include "compiler/intermediate.h" 1.17 +#include "compiler/ParseHelper.h" 1.18 + 1.19 +class TOutputGLSLBase : public TIntermTraverser 1.20 +{ 1.21 +public: 1.22 + TOutputGLSLBase(TInfoSinkBase& objSink, 1.23 + ShArrayIndexClampingStrategy clampingStrategy, 1.24 + ShHashFunction64 hashFunction, 1.25 + NameMap& nameMap, 1.26 + TSymbolTable& symbolTable); 1.27 + 1.28 +protected: 1.29 + TInfoSinkBase& objSink() { return mObjSink; } 1.30 + void writeTriplet(Visit visit, const char* preStr, const char* inStr, const char* postStr); 1.31 + void writeVariableType(const TType& type); 1.32 + virtual bool writeVariablePrecision(TPrecision precision) = 0; 1.33 + void writeFunctionParameters(const TIntermSequence& args); 1.34 + const ConstantUnion* writeConstantUnion(const TType& type, const ConstantUnion* pConstUnion); 1.35 + TString getTypeName(const TType& type); 1.36 + 1.37 + virtual void visitSymbol(TIntermSymbol* node); 1.38 + virtual void visitConstantUnion(TIntermConstantUnion* node); 1.39 + virtual bool visitBinary(Visit visit, TIntermBinary* node); 1.40 + virtual bool visitUnary(Visit visit, TIntermUnary* node); 1.41 + virtual bool visitSelection(Visit visit, TIntermSelection* node); 1.42 + virtual bool visitAggregate(Visit visit, TIntermAggregate* node); 1.43 + virtual bool visitLoop(Visit visit, TIntermLoop* node); 1.44 + virtual bool visitBranch(Visit visit, TIntermBranch* node); 1.45 + 1.46 + void visitCodeBlock(TIntermNode* node); 1.47 + 1.48 + 1.49 + // Return the original name if hash function pointer is NULL; 1.50 + // otherwise return the hashed name. 1.51 + TString hashName(const TString& name); 1.52 + // Same as hashName(), but without hashing built-in variables. 1.53 + TString hashVariableName(const TString& name); 1.54 + // Same as hashName(), but without hashing built-in functions. 1.55 + TString hashFunctionName(const TString& mangled_name); 1.56 + 1.57 +private: 1.58 + bool structDeclared(const TStructure* structure) const; 1.59 + void declareStruct(const TStructure* structure); 1.60 + 1.61 + TInfoSinkBase& mObjSink; 1.62 + bool mDeclaringVariables; 1.63 + 1.64 + // Structs are declared as the tree is traversed. This set contains all 1.65 + // the structs already declared. It is maintained so that a struct is 1.66 + // declared only once. 1.67 + typedef std::set<TString> DeclaredStructs; 1.68 + DeclaredStructs mDeclaredStructs; 1.69 + 1.70 + ForLoopUnroll mLoopUnroll; 1.71 + 1.72 + ShArrayIndexClampingStrategy mClampingStrategy; 1.73 + 1.74 + // name hashing. 1.75 + ShHashFunction64 mHashFunction; 1.76 + 1.77 + NameMap& mNameMap; 1.78 + 1.79 + TSymbolTable& mSymbolTable; 1.80 +}; 1.81 + 1.82 +#endif // CROSSCOMPILERGLSL_OUTPUTGLSLBASE_H_