Declare and initialize ViewID_OVR and InstanceID
The patch modifies the vertex shader's AST to declare and initialize
the global variables ViewID_OVR and InstanceID. Every occurrence of
gl_ViewID_OVR gets replaced by ViewID_OVR and initialized in main
with a value dependent on gl_InstanceID and the number of views.
To guarantee correct results for instanced rendering, each occurrence
of gl_InstanceID is replaced with InstanceID and initialized similarly.
BUG=angleproject:2062
TEST=angle_unittests
Change-Id: I48be688605b5af869bc370758e70ccc209ea4419
Reviewed-on: https://chromium-review.googlesource.com/548596
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/translator/DeferGlobalInitializers.cpp b/src/compiler/translator/DeferGlobalInitializers.cpp
index 8fd39dc..72aa69e 100644
--- a/src/compiler/translator/DeferGlobalInitializers.cpp
+++ b/src/compiler/translator/DeferGlobalInitializers.cpp
@@ -85,6 +85,11 @@
{
TIntermSymbol *symbolNode = declarator->getAsSymbolNode();
ASSERT(symbolNode);
+
+ // Ignore ANGLE internal variables.
+ if (symbolNode->getName().isInternal())
+ continue;
+
if (symbolNode->getQualifier() == EvqGlobal && symbolNode->getSymbol() != "")
{
TIntermSequence *initCode = CreateInitCode(symbolNode);