summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-09-25 13:22:55 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-09-29 16:09:29 +0200
commit311157c3c6849e8efccd88f7594bb34c570a6780 (patch)
treea50c252b638488326529c0e69aa05e42abce7462 /src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp
parent04d3a89e20d49a3b5015b071bfdedc81973b090c (diff)
ANGLE: Upgrade to 2.1~abce76206141
Upgrade to address issues discovered since the last upgrade. Patch notes: 0000-General-fixes-for-ANGLE-2.1.patch added removal of the unused third-party tracing functions 0003-Fix-compilation-with-MinGW-gcc-64-bit.patch removed as it is no longer needed 0011-ANGLE-Fix-compilation-error-on-MinGW-caused-by-trace.patch removed as it is no longer needed 0016-ANGLE-Fix-compilation-with-MinGW-D3D11.patch now supports MinGW 64-bit [ChangeLog][Third-party libraries] ANGLE updated to 2.1~f8602ad91e4f Task-number: QTBUG-40649 Task-number: QTBUG-40658 Task-number: QTBUG-41031 Task-number: QTBUG-41081 Task-number: QTBUG-41308 Task-number: QTBUG-41563 Change-Id: I9f776c8d5cb94ddb12d608a8d5630bfc54437bea Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp')
-rw-r--r--src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp b/src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp
new file mode 100644
index 0000000000..767b18085c
--- /dev/null
+++ b/src/3rdparty/angle/src/compiler/translator/RegenerateStructNames.cpp
@@ -0,0 +1,82 @@
+//
+// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+
+#include "compiler/translator/RegenerateStructNames.h"
+#include "compiler/translator/compilerdebug.h"
+
+void RegenerateStructNames::visitSymbol(TIntermSymbol *symbol)
+{
+ ASSERT(symbol);
+ TType *type = symbol->getTypePointer();
+ ASSERT(type);
+ TStructure *userType = type->getStruct();
+ if (!userType)
+ return;
+
+ if (mSymbolTable.findBuiltIn(userType->name(), mShaderVersion))
+ {
+ // Built-in struct, do not touch it.
+ return;
+ }
+
+ int uniqueId = userType->uniqueId();
+
+ ASSERT(mScopeDepth > 0);
+ if (mScopeDepth == 1)
+ {
+ // If a struct is defined at global scope, we don't map its name.
+ // This is because at global level, the struct might be used to
+ // declare a uniform, so the same name needs to stay the same for
+ // vertex/fragment shaders. However, our mapping uses internal ID,
+ // which will be different for the same struct in vertex/fragment
+ // shaders.
+ // This is OK because names for any structs defined in other scopes
+ // will begin with "_webgl", which is reserved. So there will be
+ // no conflicts among unmapped struct names from global scope and
+ // mapped struct names from other scopes.
+ // However, we need to keep track of these global structs, so if a
+ // variable is used in a local scope, we don't try to modify the
+ // struct name through that variable.
+ mDeclaredGlobalStructs.insert(uniqueId);
+ return;
+ }
+ if (mDeclaredGlobalStructs.count(uniqueId) > 0)
+ return;
+ // Map {name} to _webgl_struct_{uniqueId}_{name}.
+ const char kPrefix[] = "_webgl_struct_";
+ if (userType->name().find(kPrefix) == 0)
+ {
+ // The name has already been regenerated.
+ return;
+ }
+ std::string id = Str(uniqueId);
+ TString tmp = kPrefix + TString(id.c_str());
+ tmp += "_" + userType->name();
+ userType->setName(tmp);
+}
+
+bool RegenerateStructNames::visitAggregate(Visit, TIntermAggregate *aggregate)
+{
+ ASSERT(aggregate);
+ switch (aggregate->getOp())
+ {
+ case EOpSequence:
+ ++mScopeDepth;
+ {
+ TIntermSequence &sequence = *(aggregate->getSequence());
+ for (size_t ii = 0; ii < sequence.size(); ++ii)
+ {
+ TIntermNode *node = sequence[ii];
+ ASSERT(node != NULL);
+ node->traverse(this);
+ }
+ }
+ --mScopeDepth;
+ return false;
+ default:
+ return true;
+ }
+}