Implement shader identifier name mapping.
The name mapping happens when an identifier is longer than 32 characters. The name mapping is behind a flag, so it won't happen by default. Also, functions to query the mapped names are added.
The purpose of this CL is for the drivers that can't handle long names. For example, linux NVIDIA driver can't handle 256 character name, whereas WebGL spec requires that.
This CL also fixes the issue that some of the TIntermSymbols' ids are 0s.
ANGLEBUG=144
TEST=test manually with shaders with long identifier names.
Review URL: http://codereview.appspot.com/4428058
git-svn-id: https://angleproject.googlecode.com/svn/trunk@619 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/Compiler.cpp b/src/compiler/Compiler.cpp
index 3c41bc9..287962d 100644
--- a/src/compiler/Compiler.cpp
+++ b/src/compiler/Compiler.cpp
@@ -8,6 +8,7 @@
#include "compiler/ParseHelper.h"
#include "compiler/ShHandle.h"
#include "compiler/ValidateLimitations.h"
+#include "compiler/MapLongVariableNames.h"
namespace {
bool InitializeSymbolTable(
@@ -147,14 +148,20 @@
if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
success = validateLimitations(root);
+ // Call mapLongVariableNames() before collectAttribsUniforms() so in
+ // collectAttribsUniforms() we already have the mapped symbol names and
+ // we could composite mapped and original variable names.
+ if (compileOptions & SH_MAP_LONG_VARIABLE_NAMES)
+ mapLongVariableNames(root);
+
+ if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS))
+ collectAttribsUniforms(root);
+
if (success && (compileOptions & SH_INTERMEDIATE_TREE))
intermediate.outputTree(root);
if (success && (compileOptions & SH_OBJECT_CODE))
translate(root);
-
- if (success && (compileOptions & SH_ATTRIBUTES_UNIFORMS))
- collectAttribsUniforms(root);
}
// Cleanup memory.
@@ -197,3 +204,14 @@
CollectAttribsUniforms collect(attribs, uniforms);
root->traverse(&collect);
}
+
+void TCompiler::mapLongVariableNames(TIntermNode* root)
+{
+ MapLongVariableNames map;
+ root->traverse(&map);
+}
+
+int TCompiler::getMappedNameMaxLength() const
+{
+ return MAX_IDENTIFIER_NAME_SIZE + 1;
+}