LEFT | RIGHT |
1 // | 1 // |
2 // Copyright (c) 2002-2011 The ANGLE Project Authors. All rights reserved. | 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 | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 // | 5 // |
6 | 6 |
7 #ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_ | 7 #ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_ |
8 #define COMPILER_MAP_LONG_VARIABLE_NAMES_H_ | 8 #define COMPILER_MAP_LONG_VARIABLE_NAMES_H_ |
9 | 9 |
10 #include "GLSLANG/ShaderLang.h" | 10 #include "GLSLANG/ShaderLang.h" |
11 | 11 |
12 #include "compiler/intermediate.h" | 12 #include "compiler/intermediate.h" |
13 #include "compiler/SymbolTable.h" | |
14 #include "compiler/VariableInfo.h" | 13 #include "compiler/VariableInfo.h" |
15 | 14 |
16 // This size does not include '\0' in the end. | 15 // This size does not include '\0' in the end. |
17 #define MAX_IDENTIFIER_NAME_SIZE 32 | 16 #define MAX_IDENTIFIER_NAME_SIZE 32 |
18 | 17 |
19 // Traverses intermediate tree to map attributes and uniforms names that are | 18 // Traverses intermediate tree to map attributes and uniforms names that are |
20 // longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE. | 19 // longer than MAX_IDENTIFIER_NAME_SIZE to MAX_IDENTIFIER_NAME_SIZE. |
21 class MapLongVariableNames : public TIntermTraverser { | 20 class MapLongVariableNames : public TIntermTraverser { |
22 public: | 21 public: |
23 MapLongVariableNames(TSymbolTable& symbolTable, | 22 MapLongVariableNames() { } |
24 TVariableInfoList& attribs, | |
25 TVariableInfoList& uniforms); | |
26 | 23 |
27 virtual void visitSymbol(TIntermSymbol*); | 24 virtual void visitSymbol(TIntermSymbol*); |
28 virtual void visitConstantUnion(TIntermConstantUnion*); | 25 virtual void visitConstantUnion(TIntermConstantUnion*); |
29 virtual bool visitBinary(Visit, TIntermBinary*); | 26 virtual bool visitBinary(Visit, TIntermBinary*); |
30 virtual bool visitUnary(Visit, TIntermUnary*); | 27 virtual bool visitUnary(Visit, TIntermUnary*); |
31 virtual bool visitSelection(Visit, TIntermSelection*); | 28 virtual bool visitSelection(Visit, TIntermSelection*); |
32 virtual bool visitAggregate(Visit, TIntermAggregate*); | 29 virtual bool visitAggregate(Visit, TIntermAggregate*); |
33 virtual bool visitLoop(Visit, TIntermLoop*); | 30 virtual bool visitLoop(Visit, TIntermLoop*); |
34 virtual bool visitBranch(Visit, TIntermBranch*); | 31 virtual bool visitBranch(Visit, TIntermBranch*); |
35 | |
36 private: | |
37 // Mapped names are in the format of webgl_(uniqueId)_(name), where name is | |
38 // the first k characters of the original name so the mapped name's size is | |
39 // MAX_IDENTIFIER_NAME_SIZE. | |
40 TString mapSymbolName(const TIntermSymbol* symbolNode); | |
41 ···· | |
42 // Set the mapped name in Attribs/Uniforms info list. | |
43 // If the original name is not in the list, do nothing. | |
44 void setMappedAttribUniformName(TVariableInfoList& list, | |
45 const TString& originalName, | |
46 const TString& mappedName); | |
47 | |
48 TSymbolTable& mSymbolTable; | |
49 TVariableInfoList& mAttribs; | |
50 TVariableInfoList& mUniforms; | |
51 }; | 32 }; |
52 | 33 |
53 #endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_ | 34 #endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_ |
LEFT | RIGHT |