Fix row-major layout tracking in interface blocks.

Some block field types, such as nested structs, were bugged. This
only affects our "CollectVariables" path, not our current HLSL
UBO path.

BUG=angle:466

Change-Id: I2b8daf58aa7ec1ad06a80d38f57e76087eacccdc
Reviewed-on: https://chromium-review.googlesource.com/213503
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <capn@chromium.org>
diff --git a/src/compiler/translator/ShaderVars.cpp b/src/compiler/translator/ShaderVars.cpp
index 90f3bd0..822c558 100644
--- a/src/compiler/translator/ShaderVars.cpp
+++ b/src/compiler/translator/ShaderVars.cpp
@@ -89,7 +89,7 @@
 }
 
 InterfaceBlockField::InterfaceBlockField()
-    : isRowMajorMatrix(false)
+    : isRowMajorLayout(false)
 {}
 
 InterfaceBlockField::~InterfaceBlockField()
@@ -97,13 +97,13 @@
 
 InterfaceBlockField::InterfaceBlockField(const InterfaceBlockField &other)
     : ShaderVariable(other),
-      isRowMajorMatrix(other.isRowMajorMatrix)
+      isRowMajorLayout(other.isRowMajorLayout)
 {}
 
 InterfaceBlockField &InterfaceBlockField::operator=(const InterfaceBlockField &other)
 {
     ShaderVariable::operator=(other);
-    isRowMajorMatrix = other.isRowMajorMatrix;
+    isRowMajorLayout = other.isRowMajorLayout;
     return *this;
 }
 
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index 9d0c4c8..b023c29 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -272,6 +272,7 @@
     interfaceBlock.isRowMajorLayout = (blockType->matrixPacking() == EmpRowMajor);
     interfaceBlock.layout = sh::GetBlockLayoutType(blockType->blockStorage());
 
+    // Gather field information
     sh::GetInterfaceBlockFields(*blockType, &interfaceBlock.fields);
 
     infoList->push_back(interfaceBlock);
@@ -356,13 +357,14 @@
 {
     if (binaryNode->getOp() == EOpIndexDirectInterfaceBlock)
     {
-        TIntermSymbol *symbol = binaryNode->getLeft()->getAsSymbolNode();
-        ASSERT(symbol);
+        // NOTE: we do not determine static use for individual blocks of an array
+        TIntermTyped *blockNode = binaryNode->getLeft()->getAsTyped();
+        ASSERT(blockNode);
 
         TIntermConstantUnion *constantUnion = binaryNode->getRight()->getAsConstantUnion();
         ASSERT(constantUnion);
 
-        const TInterfaceBlock *interfaceBlock = symbol->getType().getInterfaceBlock();
+        const TInterfaceBlock *interfaceBlock = blockNode->getType().getInterfaceBlock();
         sh::InterfaceBlock *namedBlock = FindVariable(interfaceBlock->name(), mInterfaceBlocks);
         ASSERT(namedBlock);
         namedBlock->staticUse = true;
diff --git a/src/compiler/translator/util.cpp b/src/compiler/translator/util.cpp
index 8684a13..40c90d8 100644
--- a/src/compiler/translator/util.cpp
+++ b/src/compiler/translator/util.cpp
@@ -356,7 +356,7 @@
         GetVariableTraverser traverser;
         traverser.traverse(fieldType, fullFieldName, fieldsOut);
 
-        fieldsOut->back().isRowMajorMatrix = (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
+        fieldsOut->back().isRowMajorLayout = (fieldType.getLayoutQualifier().matrixPacking == EmpRowMajor);
     }
 }