Move ShaderVariables to common shared source.

Also move the block layout encoding utilities to the common folder.
The combined changes allow us to include the shader and block code
into both libGLESv2 and the translator separately. This in turn
fixes the Chromium component build, where we were calling internal
translator functions directly from libGLESv2.

BUG=angle:568

Change-Id: Ibcfa2c936a7c737ad515c10bd24061ff39ee5747
Reviewed-on: https://chromium-review.googlesource.com/192891
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/common/blocklayout.cpp b/src/common/blocklayout.cpp
new file mode 100644
index 0000000..45f516f
--- /dev/null
+++ b/src/common/blocklayout.cpp
@@ -0,0 +1,305 @@
+//
+// Copyright (c) 2013-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.
+//
+// blocklayout.cpp:
+//   Implementation for block layout classes and methods.
+//
+
+#include "common/blocklayout.h"
+#include "common/shadervars.h"
+#include "common/mathutil.h"
+#include "common/utilities.h"
+
+namespace gl
+{
+
+BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
+    : mCurrentOffset(0),
+      mBlockInfoOut(blockInfoOut)
+{
+}
+
+void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields)
+{
+    for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
+    {
+        const InterfaceBlockField &variable = fields[fieldIndex];
+
+        if (variable.fields.size() > 0)
+        {
+            const unsigned int elementCount = std::max(1u, variable.arraySize);
+
+            for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
+            {
+                enterAggregateType();
+                encodeInterfaceBlockFields(variable.fields);
+                exitAggregateType();
+            }
+        }
+        else
+        {
+            encodeInterfaceBlockField(variable);
+        }
+    }
+}
+
+void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field)
+{
+    int arrayStride;
+    int matrixStride;
+
+    ASSERT(field.fields.empty());
+    getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride);
+
+    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
+
+    if (mBlockInfoOut)
+    {
+        mBlockInfoOut->push_back(memberInfo);
+    }
+
+    advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
+}
+
+void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
+{
+    int arrayStride;
+    int matrixStride;
+
+    getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &arrayStride, &matrixStride);
+
+    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
+
+    if (mBlockInfoOut)
+    {
+        mBlockInfoOut->push_back(memberInfo);
+    }
+
+    advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
+}
+
+void BlockLayoutEncoder::nextRegister()
+{
+    mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister);
+}
+
+Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
+    : BlockLayoutEncoder(blockInfoOut)
+{
+}
+
+void Std140BlockEncoder::enterAggregateType()
+{
+    nextRegister();
+}
+
+void Std140BlockEncoder::exitAggregateType()
+{
+    nextRegister();
+}
+
+void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
+{
+    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
+    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
+
+    size_t baseAlignment = 0;
+    int matrixStride = 0;
+    int arrayStride = 0;
+
+    if (gl::IsMatrixType(type))
+    {
+        baseAlignment = ComponentsPerRegister;
+        matrixStride = ComponentsPerRegister;
+
+        if (arraySize > 0)
+        {
+            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+            arrayStride = ComponentsPerRegister * numRegisters;
+        }
+    }
+    else if (arraySize > 0)
+    {
+        baseAlignment = ComponentsPerRegister;
+        arrayStride = ComponentsPerRegister;
+    }
+    else
+    {
+        const int numComponents = gl::UniformComponentCount(type);
+        baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
+    }
+
+    mCurrentOffset = rx::roundUp(mCurrentOffset, baseAlignment);
+
+    *matrixStrideOut = matrixStride;
+    *arrayStrideOut = arrayStride;
+}
+
+void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
+{
+    if (arraySize > 0)
+    {
+        mCurrentOffset += arrayStride * arraySize;
+    }
+    else if (gl::IsMatrixType(type))
+    {
+        ASSERT(matrixStride == ComponentsPerRegister);
+        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+        mCurrentOffset += ComponentsPerRegister * numRegisters;
+    }
+    else
+    {
+        mCurrentOffset += gl::UniformComponentCount(type);
+    }
+}
+
+HLSLBlockEncoder::HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
+    : BlockLayoutEncoder(blockInfoOut)
+{
+}
+
+void HLSLBlockEncoder::enterAggregateType()
+{
+    nextRegister();
+}
+
+void HLSLBlockEncoder::exitAggregateType()
+{
+}
+
+void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
+{
+    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
+    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
+
+    int matrixStride = 0;
+    int arrayStride = 0;
+
+    if (gl::IsMatrixType(type))
+    {
+        nextRegister();
+        matrixStride = ComponentsPerRegister;
+
+        if (arraySize > 0)
+        {
+            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+            arrayStride = ComponentsPerRegister * numRegisters;
+        }
+    }
+    else if (arraySize > 0)
+    {
+        nextRegister();
+        arrayStride = ComponentsPerRegister;
+    }
+    else
+    {
+        int numComponents = gl::UniformComponentCount(type);
+        if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
+        {
+            nextRegister();
+        }
+    }
+
+    *matrixStrideOut = matrixStride;
+    *arrayStrideOut = arrayStride;
+}
+
+void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
+{
+    if (arraySize > 0)
+    {
+        mCurrentOffset += arrayStride * (arraySize - 1);
+    }
+
+    if (gl::IsMatrixType(type))
+    {
+        ASSERT(matrixStride == ComponentsPerRegister);
+        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
+        const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
+        mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
+        mCurrentOffset += numComponents;
+    }
+    else
+    {
+        mCurrentOffset += gl::UniformComponentCount(type);
+    }
+}
+
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable, HLSLBlockEncoder *encoder, const std::vector<gl::BlockMemberInfo> &blockInfo)
+{
+    // because this method computes offsets (element indexes) instead of any total sizes,
+    // we can ignore the array size of the variable
+
+    if (variable->isStruct())
+    {
+        encoder->enterAggregateType();
+
+        for (size_t fieldIndex = 0; fieldIndex < variable->fields.size(); fieldIndex++)
+        {
+            HLSLVariableGetRegisterInfo(baseRegisterIndex, &variable->fields[fieldIndex], encoder, blockInfo);
+        }
+
+        encoder->exitAggregateType();
+    }
+    else
+    {
+        encoder->encodeType(variable->type, variable->arraySize, false);
+
+        const size_t registerBytes = (encoder->BytesPerComponent * encoder->ComponentsPerRegister);
+        variable->registerIndex = baseRegisterIndex + (blockInfo.back().offset / registerBytes);
+        variable->elementIndex = (blockInfo.back().offset % registerBytes) / sizeof(float);
+    }
+}
+
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, gl::Uniform *variable)
+{
+    std::vector<BlockMemberInfo> blockInfo;
+    HLSLBlockEncoder encoder(&blockInfo);
+    HLSLVariableGetRegisterInfo(baseRegisterIndex, variable, &encoder, blockInfo);
+}
+
+template <class ShaderVarType>
+void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder)
+{
+    if (variable.isStruct())
+    {
+        for (size_t arrayElement = 0; arrayElement < variable.elementCount(); arrayElement++)
+        {
+            encoder->enterAggregateType();
+
+            for (size_t fieldIndex = 0; fieldIndex < variable.fields.size(); fieldIndex++)
+            {
+                HLSLVariableRegisterCount(variable.fields[fieldIndex], encoder);
+            }
+
+            encoder->exitAggregateType();
+        }
+    }
+    else
+    {
+        // We operate only on varyings and uniforms, which do not have matrix layout qualifiers
+        encoder->encodeType(variable.type, variable.arraySize, false);
+    }
+}
+
+unsigned int HLSLVariableRegisterCount(const Varying &variable)
+{
+    HLSLBlockEncoder encoder(NULL);
+    HLSLVariableRegisterCount(variable, &encoder);
+
+    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
+    return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
+}
+
+unsigned int HLSLVariableRegisterCount(const Uniform &variable)
+{
+    HLSLBlockEncoder encoder(NULL);
+    HLSLVariableRegisterCount(variable, &encoder);
+
+    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
+    return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
+}
+
+}
diff --git a/src/common/blocklayout.h b/src/common/blocklayout.h
new file mode 100644
index 0000000..68f855b
--- /dev/null
+++ b/src/common/blocklayout.h
@@ -0,0 +1,96 @@
+//
+// Copyright (c) 2013-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.
+//
+// blocklayout.h:
+//   Methods and classes related to uniform layout and packing in GLSL and HLSL.
+//
+
+#ifndef COMMON_BLOCKLAYOUT_H_
+#define COMMON_BLOCKLAYOUT_H_
+
+#include <vector>
+#define GL_APICALL
+#include <GLES3/gl3.h>
+#include <GLES2/gl2.h>
+
+namespace gl
+{
+
+struct ShaderVariable;
+struct InterfaceBlockField;
+struct BlockMemberInfo;
+struct Uniform;
+struct Varying;
+
+class BlockLayoutEncoder
+{
+  public:
+    BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
+
+    void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
+    void encodeInterfaceBlockField(const InterfaceBlockField &field);
+    void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
+    size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
+
+    static const size_t BytesPerComponent = 4u;
+    static const unsigned int ComponentsPerRegister = 4u;
+
+  protected:
+    size_t mCurrentOffset;
+
+    void nextRegister();
+
+    virtual void enterAggregateType() = 0;
+    virtual void exitAggregateType() = 0;
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
+
+  private:
+    std::vector<BlockMemberInfo> *mBlockInfoOut;
+};
+
+// Block layout according to the std140 block layout
+// See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification
+
+class Std140BlockEncoder : public BlockLayoutEncoder
+{
+  public:
+    Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
+
+  protected:
+    virtual void enterAggregateType();
+    virtual void exitAggregateType();
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
+};
+
+// Block layout packed according to the default D3D11 register packing rules
+// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
+
+class HLSLBlockEncoder : public BlockLayoutEncoder
+{
+  public:
+    HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
+
+    virtual void enterAggregateType();
+    virtual void exitAggregateType();
+
+  protected:
+    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
+    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
+};
+
+// This method assigns values to the variable's "registerIndex" and "elementIndex" fields.
+// "elementIndex" is only used for structures.
+void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable);
+
+// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
+// class to count the number of used registers in a struct (which are individually packed according to the same rules).
+unsigned int HLSLVariableRegisterCount(const Varying &variable);
+unsigned int HLSLVariableRegisterCount(const Uniform &variable);
+
+}
+
+#endif // COMMON_BLOCKLAYOUT_H_
diff --git a/src/compiler/translator/ShaderVariable.cpp b/src/common/shadervars.cpp
similarity index 90%
rename from src/compiler/translator/ShaderVariable.cpp
rename to src/common/shadervars.cpp
index a8a5e93..c9843dc 100644
--- a/src/compiler/translator/ShaderVariable.cpp
+++ b/src/common/shadervars.cpp
@@ -1,12 +1,15 @@
 //
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2013-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.
 //
+// shadervars.cpp:
+//   Implementation for GL shader variable member functions.
+//
 
-#include "compiler/translator/ShaderVariable.h"
+#include "common/shadervars.h"
 
-namespace sh
+namespace gl
 {
 
 ShaderVariable::ShaderVariable(GLenum typeIn, GLenum precisionIn, const char *nameIn, unsigned int arraySizeIn)
diff --git a/src/compiler/translator/ShaderVariable.h b/src/common/shadervars.h
similarity index 90%
rename from src/compiler/translator/ShaderVariable.h
rename to src/common/shadervars.h
index 53c3326..eba0141 100644
--- a/src/compiler/translator/ShaderVariable.h
+++ b/src/common/shadervars.h
@@ -1,11 +1,14 @@
 //
-// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
+// Copyright (c) 2013-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.
 //
+// shadervars.h:
+//  Types to represent GL variables (varyings, uniforms, etc)
+//
 
-#ifndef COMPILER_SHADERVARIABLE_H_
-#define COMPILER_SHADERVARIABLE_H_
+#ifndef COMMON_SHADERVARIABLE_H_
+#define COMMON_SHADERVARIABLE_H_
 
 #include <string>
 #include <vector>
@@ -15,7 +18,7 @@
 #include <GLES3/gl3.h>
 #include <GLES2/gl2.h>
 
-namespace sh
+namespace gl
 {
 
 enum InterpolationType
@@ -119,8 +122,6 @@
     unsigned int registerIndex;
 };
 
-typedef std::vector<InterfaceBlock> ActiveInterfaceBlocks;
-
 }
 
-#endif   // COMPILER_SHADERVARIABLE_H_
+#endif // COMMON_SHADERVARIABLE_H_
diff --git a/src/compiler/translator/BlockLayoutEncoder.cpp b/src/compiler/translator/BlockLayoutEncoder.cpp
deleted file mode 100644
index ef94d9b..0000000
--- a/src/compiler/translator/BlockLayoutEncoder.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-//
-// Copyright (c) 2013 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/BlockLayoutEncoder.h"
-#include "compiler/translator/ShaderVariable.h"
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-namespace sh
-{
-
-BlockLayoutEncoder::BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
-    : mCurrentOffset(0),
-      mBlockInfoOut(blockInfoOut)
-{
-}
-
-void BlockLayoutEncoder::encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields)
-{
-    for (unsigned int fieldIndex = 0; fieldIndex < fields.size(); fieldIndex++)
-    {
-        const InterfaceBlockField &variable = fields[fieldIndex];
-
-        if (variable.fields.size() > 0)
-        {
-            const unsigned int elementCount = std::max(1u, variable.arraySize);
-
-            for (unsigned int elementIndex = 0; elementIndex < elementCount; elementIndex++)
-            {
-                enterAggregateType();
-                encodeInterfaceBlockFields(variable.fields);
-                exitAggregateType();
-            }
-        }
-        else
-        {
-            encodeInterfaceBlockField(variable);
-        }
-    }
-}
-
-void BlockLayoutEncoder::encodeInterfaceBlockField(const InterfaceBlockField &field)
-{
-    int arrayStride;
-    int matrixStride;
-
-    ASSERT(field.fields.empty());
-    getBlockLayoutInfo(field.type, field.arraySize, field.isRowMajorMatrix, &arrayStride, &matrixStride);
-
-    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, field.isRowMajorMatrix);
-
-    if (mBlockInfoOut)
-    {
-        mBlockInfoOut->push_back(memberInfo);
-    }
-
-    advanceOffset(field.type, field.arraySize, field.isRowMajorMatrix, arrayStride, matrixStride);
-}
-
-void BlockLayoutEncoder::encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix)
-{
-    int arrayStride;
-    int matrixStride;
-
-    getBlockLayoutInfo(type, arraySize, isRowMajorMatrix, &arrayStride, &matrixStride);
-
-    const BlockMemberInfo memberInfo(mCurrentOffset * BytesPerComponent, arrayStride * BytesPerComponent, matrixStride * BytesPerComponent, isRowMajorMatrix);
-
-    if (mBlockInfoOut)
-    {
-        mBlockInfoOut->push_back(memberInfo);
-    }
-
-    advanceOffset(type, arraySize, isRowMajorMatrix, arrayStride, matrixStride);
-}
-
-void BlockLayoutEncoder::nextRegister()
-{
-    mCurrentOffset = rx::roundUp<size_t>(mCurrentOffset, ComponentsPerRegister);
-}
-
-Std140BlockEncoder::Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
-    : BlockLayoutEncoder(blockInfoOut)
-{
-}
-
-void Std140BlockEncoder::enterAggregateType()
-{
-    nextRegister();
-}
-
-void Std140BlockEncoder::exitAggregateType()
-{
-    nextRegister();
-}
-
-void Std140BlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
-{
-    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
-    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
-
-    size_t baseAlignment = 0;
-    int matrixStride = 0;
-    int arrayStride = 0;
-
-    if (gl::IsMatrixType(type))
-    {
-        baseAlignment = ComponentsPerRegister;
-        matrixStride = ComponentsPerRegister;
-
-        if (arraySize > 0)
-        {
-            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
-            arrayStride = ComponentsPerRegister * numRegisters;
-        }
-    }
-    else if (arraySize > 0)
-    {
-        baseAlignment = ComponentsPerRegister;
-        arrayStride = ComponentsPerRegister;
-    }
-    else
-    {
-        const int numComponents = gl::UniformComponentCount(type);
-        baseAlignment = (numComponents == 3 ? 4u : static_cast<size_t>(numComponents));
-    }
-
-    mCurrentOffset = rx::roundUp(mCurrentOffset, baseAlignment);
-
-    *matrixStrideOut = matrixStride;
-    *arrayStrideOut = arrayStride;
-}
-
-void Std140BlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
-{
-    if (arraySize > 0)
-    {
-        mCurrentOffset += arrayStride * arraySize;
-    }
-    else if (gl::IsMatrixType(type))
-    {
-        ASSERT(matrixStride == ComponentsPerRegister);
-        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
-        mCurrentOffset += ComponentsPerRegister * numRegisters;
-    }
-    else
-    {
-        mCurrentOffset += gl::UniformComponentCount(type);
-    }
-}
-
-}
diff --git a/src/compiler/translator/BlockLayoutEncoder.h b/src/compiler/translator/BlockLayoutEncoder.h
deleted file mode 100644
index b6fb7bf..0000000
--- a/src/compiler/translator/BlockLayoutEncoder.h
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-#ifndef TRANSLATOR_COMMON_BLOCKLAYOUTENCODER_H_
-#define TRANSLATOR_COMMON_BLOCKLAYOUTENCODER_H_
-
-#include <vector>
-#define GL_APICALL
-#include <GLES3/gl3.h>
-#include <GLES2/gl2.h>
-
-namespace sh
-{
-
-struct ShaderVariable;
-struct InterfaceBlockField;
-struct BlockMemberInfo;
-
-class BlockLayoutEncoder
-{
-  public:
-    BlockLayoutEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
-
-    void encodeInterfaceBlockFields(const std::vector<InterfaceBlockField> &fields);
-    void encodeInterfaceBlockField(const InterfaceBlockField &field);
-    void encodeType(GLenum type, unsigned int arraySize, bool isRowMajorMatrix);
-    size_t getBlockSize() const { return mCurrentOffset * BytesPerComponent; }
-
-    static const size_t BytesPerComponent = 4u;
-    static const unsigned int ComponentsPerRegister = 4u;
-
-  protected:
-    size_t mCurrentOffset;
-
-    void nextRegister();
-
-    virtual void enterAggregateType() = 0;
-    virtual void exitAggregateType() = 0;
-    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut) = 0;
-    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride) = 0;
-
-  private:
-    std::vector<BlockMemberInfo> *mBlockInfoOut;
-};
-
-// Block layout according to the std140 block layout
-// See "Standard Uniform Block Layout" in Section 2.11.6 of the OpenGL ES 3.0 specification
-
-class Std140BlockEncoder : public BlockLayoutEncoder
-{
-  public:
-    Std140BlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
-
-  protected:
-    virtual void enterAggregateType();
-    virtual void exitAggregateType();
-    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
-    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
-};
-
-}
-
-#endif // TRANSLATOR_COMMON_BLOCKLAYOUTENCODER_H_
diff --git a/src/compiler/translator/HLSLLayoutEncoder.cpp b/src/compiler/translator/HLSLLayoutEncoder.cpp
deleted file mode 100644
index 7868fb9..0000000
--- a/src/compiler/translator/HLSLLayoutEncoder.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-//
-// Copyright (c) 2013 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/HLSLLayoutEncoder.h"
-#include "compiler/translator/ShaderVariable.h"
-#include "common/mathutil.h"
-#include "common/utilities.h"
-
-namespace sh
-{
-
-HLSLBlockEncoder::HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut)
-    : BlockLayoutEncoder(blockInfoOut)
-{
-}
-
-void HLSLBlockEncoder::enterAggregateType()
-{
-    nextRegister();
-}
-
-void HLSLBlockEncoder::exitAggregateType()
-{
-}
-
-void HLSLBlockEncoder::getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut)
-{
-    // We assume we are only dealing with 4 byte components (no doubles or half-words currently)
-    ASSERT(gl::UniformComponentSize(gl::UniformComponentType(type)) == BytesPerComponent);
-
-    int matrixStride = 0;
-    int arrayStride = 0;
-
-    if (gl::IsMatrixType(type))
-    {
-        nextRegister();
-        matrixStride = ComponentsPerRegister;
-
-        if (arraySize > 0)
-        {
-            const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
-            arrayStride = ComponentsPerRegister * numRegisters;
-        }
-    }
-    else if (arraySize > 0)
-    {
-        nextRegister();
-        arrayStride = ComponentsPerRegister;
-    }
-    else
-    {
-        int numComponents = gl::UniformComponentCount(type);
-        if ((numComponents + (mCurrentOffset % ComponentsPerRegister)) > ComponentsPerRegister)
-        {
-            nextRegister();
-        }
-    }
-
-    *matrixStrideOut = matrixStride;
-    *arrayStrideOut = arrayStride;
-}
-
-void HLSLBlockEncoder::advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride)
-{
-    if (arraySize > 0)
-    {
-        mCurrentOffset += arrayStride * (arraySize - 1);
-    }
-
-    if (gl::IsMatrixType(type))
-    {
-        ASSERT(matrixStride == ComponentsPerRegister);
-        const int numRegisters = gl::MatrixRegisterCount(type, isRowMajorMatrix);
-        const int numComponents = gl::MatrixComponentCount(type, isRowMajorMatrix);
-        mCurrentOffset += ComponentsPerRegister * (numRegisters - 1);
-        mCurrentOffset += numComponents;
-    }
-    else
-    {
-        mCurrentOffset += gl::UniformComponentCount(type);
-    }
-}
-
-void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable, HLSLBlockEncoder *encoder, const std::vector<BlockMemberInfo> &blockInfo)
-{
-    // because this method computes offsets (element indexes) instead of any total sizes,
-    // we can ignore the array size of the variable
-
-    if (variable->isStruct())
-    {
-        encoder->enterAggregateType();
-
-        for (size_t fieldIndex = 0; fieldIndex < variable->fields.size(); fieldIndex++)
-        {
-            HLSLVariableGetRegisterInfo(baseRegisterIndex, &variable->fields[fieldIndex], encoder, blockInfo);
-        }
-
-        encoder->exitAggregateType();
-    }
-    else
-    {
-        encoder->encodeType(variable->type, variable->arraySize, false);
-
-        const size_t registerBytes = (encoder->BytesPerComponent * encoder->ComponentsPerRegister);
-        variable->registerIndex = baseRegisterIndex + (blockInfo.back().offset / registerBytes);
-        variable->elementIndex = (blockInfo.back().offset % registerBytes) / sizeof(float);
-    }
-}
-
-void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable)
-{
-    std::vector<BlockMemberInfo> blockInfo;
-    HLSLBlockEncoder encoder(&blockInfo);
-    HLSLVariableGetRegisterInfo(baseRegisterIndex, variable, &encoder, blockInfo);
-}
-
-template <class ShaderVarType>
-void HLSLVariableRegisterCount(const ShaderVarType &variable, HLSLBlockEncoder *encoder)
-{
-    if (variable.isStruct())
-    {
-        for (size_t arrayElement = 0; arrayElement < variable.elementCount(); arrayElement++)
-        {
-            encoder->enterAggregateType();
-
-            for (size_t fieldIndex = 0; fieldIndex < variable.fields.size(); fieldIndex++)
-            {
-                HLSLVariableRegisterCount(variable.fields[fieldIndex], encoder);
-            }
-
-            encoder->exitAggregateType();
-        }
-    }
-    else
-    {
-        // We operate only on varyings and uniforms, which do not have matrix layout qualifiers
-        encoder->encodeType(variable.type, variable.arraySize, false);
-    }
-}
-
-unsigned int HLSLVariableRegisterCount(const Varying &variable)
-{
-    HLSLBlockEncoder encoder(NULL);
-    HLSLVariableRegisterCount(variable, &encoder);
-
-    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
-    return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
-}
-
-unsigned int HLSLVariableRegisterCount(const Uniform &variable)
-{
-    HLSLBlockEncoder encoder(NULL);
-    HLSLVariableRegisterCount(variable, &encoder);
-
-    const size_t registerBytes = (encoder.BytesPerComponent * encoder.ComponentsPerRegister);
-    return static_cast<unsigned int>(rx::roundUp<size_t>(encoder.getBlockSize(), registerBytes) / registerBytes);
-}
-
-}
diff --git a/src/compiler/translator/HLSLLayoutEncoder.h b/src/compiler/translator/HLSLLayoutEncoder.h
deleted file mode 100644
index 95bbb27..0000000
--- a/src/compiler/translator/HLSLLayoutEncoder.h
+++ /dev/null
@@ -1,45 +0,0 @@
-//
-// Copyright (c) 2013 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.
-//
-
-#ifndef TRANSLATOR_HLSL_HLSLLAYOUTENCODER_H_
-#define TRANSLATOR_HLSL_HLSLLAYOUTENCODER_H_
-
-#include "compiler/translator/BlockLayoutEncoder.h"
-
-namespace sh
-{
-
-struct Varying;
-struct Uniform;
-
-// Block layout packed according to the default D3D11 register packing rules
-// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb509632(v=vs.85).aspx
-
-class HLSLBlockEncoder : public BlockLayoutEncoder
-{
-  public:
-    HLSLBlockEncoder(std::vector<BlockMemberInfo> *blockInfoOut);
-
-    virtual void enterAggregateType();
-    virtual void exitAggregateType();
-
-  protected:
-    virtual void getBlockLayoutInfo(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int *arrayStrideOut, int *matrixStrideOut);
-    virtual void advanceOffset(GLenum type, unsigned int arraySize, bool isRowMajorMatrix, int arrayStride, int matrixStride);
-};
-
-// This method assigns values to the variable's "registerIndex" and "elementIndex" fields.
-// "elementIndex" is only used for structures.
-void HLSLVariableGetRegisterInfo(unsigned int baseRegisterIndex, Uniform *variable);
-
-// This method returns the number of used registers for a ShaderVariable. It is dependent on the HLSLBlockEncoder
-// class to count the number of used registers in a struct (which are individually packed according to the same rules).
-unsigned int HLSLVariableRegisterCount(const Varying &variable);
-unsigned int HLSLVariableRegisterCount(const Uniform &variable);
-
-}
-
-#endif // TRANSLATOR_HLSL_HLSLLAYOUTENCODER_H_
diff --git a/src/compiler/translator/OutputHLSL.cpp b/src/compiler/translator/OutputHLSL.cpp
index 75df471..37812ff 100644
--- a/src/compiler/translator/OutputHLSL.cpp
+++ b/src/compiler/translator/OutputHLSL.cpp
@@ -8,12 +8,12 @@
 
 #include "common/angleutils.h"
 #include "common/utilities.h"
+#include "common/blocklayout.h"
 #include "compiler/translator/compilerdebug.h"
 #include "compiler/translator/InfoSink.h"
 #include "compiler/translator/DetectDiscontinuity.h"
 #include "compiler/translator/SearchSymbol.h"
 #include "compiler/translator/UnfoldShortCircuit.h"
-#include "compiler/translator/HLSLLayoutEncoder.h"
 #include "compiler/translator/FlagStd140Structs.h"
 #include "compiler/translator/NodeSearch.h"
 #include "compiler/translator/RewriteElseBlocks.h"
@@ -220,27 +220,27 @@
     return mBody;
 }
 
-const std::vector<Uniform> &OutputHLSL::getUniforms()
+const std::vector<gl::Uniform> &OutputHLSL::getUniforms()
 {
     return mActiveUniforms;
 }
 
-const ActiveInterfaceBlocks &OutputHLSL::getInterfaceBlocks() const
+const std::vector<gl::InterfaceBlock> &OutputHLSL::getInterfaceBlocks() const
 {
     return mActiveInterfaceBlocks;
 }
 
-const std::vector<Attribute> &OutputHLSL::getOutputVariables() const
+const std::vector<gl::Attribute> &OutputHLSL::getOutputVariables() const
 {
     return mActiveOutputVariables;
 }
 
-const std::vector<Attribute> &OutputHLSL::getAttributes() const
+const std::vector<gl::Attribute> &OutputHLSL::getAttributes() const
 {
     return mActiveAttributes;
 }
 
-const std::vector<Varying> &OutputHLSL::getVaryings() const
+const std::vector<gl::Varying> &OutputHLSL::getVaryings() const
 {
     return mActiveVaryings;
 }
@@ -473,25 +473,25 @@
 }
 
 // Use the same layout for packed and shared
-void setBlockLayout(InterfaceBlock *interfaceBlock, BlockLayoutType newLayout)
+void setBlockLayout(gl::InterfaceBlock *interfaceBlock, gl::BlockLayoutType newLayout)
 {
     interfaceBlock->layout = newLayout;
     interfaceBlock->blockInfo.clear();
 
     switch (newLayout)
     {
-      case BLOCKLAYOUT_SHARED:
-      case BLOCKLAYOUT_PACKED:
+      case gl::BLOCKLAYOUT_SHARED:
+      case gl::BLOCKLAYOUT_PACKED:
         {
-            HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo);
+            gl::HLSLBlockEncoder hlslEncoder(&interfaceBlock->blockInfo);
             hlslEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
             interfaceBlock->dataSize = hlslEncoder.getBlockSize();
         }
         break;
 
-      case BLOCKLAYOUT_STANDARD:
+      case gl::BLOCKLAYOUT_STANDARD:
         {
-            Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
+            gl::Std140BlockEncoder stdEncoder(&interfaceBlock->blockInfo);
             stdEncoder.encodeInterfaceBlockFields(interfaceBlock->fields);
             interfaceBlock->dataSize = stdEncoder.getBlockSize();
         }
@@ -503,14 +503,14 @@
     }
 }
 
-BlockLayoutType convertBlockLayoutType(TLayoutBlockStorage blockStorage)
+gl::BlockLayoutType convertBlockLayoutType(TLayoutBlockStorage blockStorage)
 {
     switch (blockStorage)
     {
-      case EbsPacked: return BLOCKLAYOUT_PACKED;
-      case EbsShared: return BLOCKLAYOUT_SHARED;
-      case EbsStd140: return BLOCKLAYOUT_STANDARD;
-      default: UNREACHABLE(); return BLOCKLAYOUT_SHARED;
+      case EbsPacked: return gl::BLOCKLAYOUT_PACKED;
+      case EbsShared: return gl::BLOCKLAYOUT_SHARED;
+      case EbsStd140: return gl::BLOCKLAYOUT_STANDARD;
+      default: UNREACHABLE(); return gl::BLOCKLAYOUT_SHARED;
     }
 }
 
@@ -599,7 +599,7 @@
         const TFieldList &fieldList = interfaceBlock.fields();
 
         unsigned int arraySize = static_cast<unsigned int>(interfaceBlock.arraySize());
-        sh::InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister);
+        gl::InterfaceBlock activeBlock(interfaceBlock.name().c_str(), arraySize, mInterfaceBlockRegister);
         for (unsigned int typeIndex = 0; typeIndex < fieldList.size(); typeIndex++)
         {
             const TField &field = *fieldList[typeIndex];
@@ -609,7 +609,7 @@
 
         mInterfaceBlockRegister += std::max(1u, arraySize);
 
-        BlockLayoutType blockLayoutType = convertBlockLayoutType(interfaceBlock.blockStorage());
+        gl::BlockLayoutType blockLayoutType = convertBlockLayoutType(interfaceBlock.blockStorage());
         setBlockLayout(&activeBlock, blockLayoutType);
 
         if (interfaceBlock.matrixPacking() == EmpRowMajor)
@@ -668,7 +668,7 @@
 
         attributes += "static " + typeString(type) + " " + decorate(name) + arrayString(type) + " = " + initializer(type) + ";\n";
 
-        Attribute attributeVar(glVariableType(type), glVariablePrecision(type), name.c_str(),
+        gl::Attribute attributeVar(glVariableType(type), glVariablePrecision(type), name.c_str(),
                                (unsigned int)type.getArraySize(), type.getLayoutQualifier().location);
         mActiveAttributes.push_back(attributeVar);
     }
@@ -713,7 +713,7 @@
                 out << "static " + typeString(variableType) + " out_" + variableName + arrayString(variableType) +
                        " = " + initializer(variableType) + ";\n";
 
-                Attribute outputVar(glVariableType(variableType), glVariablePrecision(variableType), variableName.c_str(),
+                gl::Attribute outputVar(glVariableType(variableType), glVariablePrecision(variableType), variableName.c_str(),
                                     (unsigned int)variableType.getArraySize(), layoutQualifier.location);
                 mActiveOutputVariables.push_back(outputVar);
             }
@@ -3880,20 +3880,20 @@
     return string;
 }
 
-void OutputHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector<InterfaceBlockField>& output)
+void OutputHLSL::declareInterfaceBlockField(const TType &type, const TString &name, std::vector<gl::InterfaceBlockField>& output)
 {
     const TStructure *structure = type.getStruct();
 
     if (!structure)
     {
         const bool isRowMajorMatrix = (type.isMatrix() && type.getLayoutQualifier().matrixPacking == EmpRowMajor);
-        InterfaceBlockField field(glVariableType(type), glVariablePrecision(type), name.c_str(),
-                        (unsigned int)type.getArraySize(), isRowMajorMatrix);
+        gl::InterfaceBlockField field(glVariableType(type), glVariablePrecision(type), name.c_str(),
+                                      (unsigned int)type.getArraySize(), isRowMajorMatrix);
         output.push_back(field);
    }
     else
     {
-        InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false);
+        gl::InterfaceBlockField structField(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), false);
 
         const TFieldList &fields = structure->fields();
 
@@ -3912,22 +3912,22 @@
     }
 }
 
-Uniform OutputHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<Uniform>& output)
+gl::Uniform OutputHLSL::declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<gl::Uniform>& output)
 {
     const TStructure *structure = type.getStruct();
 
     if (!structure)
     {
-        Uniform uniform(glVariableType(type), glVariablePrecision(type), name.c_str(),
-                        (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0);
+        gl::Uniform uniform(glVariableType(type), glVariablePrecision(type), name.c_str(),
+                            (unsigned int)type.getArraySize(), (unsigned int)registerIndex, 0);
         output.push_back(uniform);
 
         return uniform;
    }
     else
     {
-        Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
-                              (unsigned int)registerIndex, GL_INVALID_INDEX);
+        gl::Uniform structUniform(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(),
+                                  (unsigned int)registerIndex, GL_INVALID_INDEX);
 
         const TFieldList &fields = structure->fields();
 
@@ -3948,13 +3948,13 @@
     }
 }
 
-InterpolationType getInterpolationType(TQualifier qualifier)
+gl::InterpolationType getInterpolationType(TQualifier qualifier)
 {
     switch (qualifier)
     {
       case EvqFlatIn:
       case EvqFlatOut:
-        return INTERPOLATION_FLAT;
+        return gl::INTERPOLATION_FLAT;
 
       case EvqSmoothIn:
       case EvqSmoothOut:
@@ -3962,30 +3962,30 @@
       case EvqFragmentIn:
       case EvqVaryingIn:
       case EvqVaryingOut:
-        return INTERPOLATION_SMOOTH;
+        return gl::INTERPOLATION_SMOOTH;
 
       case EvqCentroidIn:
       case EvqCentroidOut:
-        return INTERPOLATION_CENTROID;
+        return gl::INTERPOLATION_CENTROID;
 
       default: UNREACHABLE();
-        return INTERPOLATION_SMOOTH;
+        return gl::INTERPOLATION_SMOOTH;
     }
 }
 
-void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<Varying>& fieldsOut)
+void OutputHLSL::declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<gl::Varying>& fieldsOut)
 {
     const TStructure *structure = type.getStruct();
 
-    InterpolationType interpolation = getInterpolationType(baseTypeQualifier);
+    gl::InterpolationType interpolation = getInterpolationType(baseTypeQualifier);
     if (!structure)
     {
-        Varying varying(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation);
+        gl::Varying varying(glVariableType(type), glVariablePrecision(type), name.c_str(), (unsigned int)type.getArraySize(), interpolation);
         fieldsOut.push_back(varying);
     }
     else
     {
-        Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation);
+        gl::Varying structVarying(GL_STRUCT_ANGLEX, GL_NONE, name.c_str(), (unsigned int)type.getArraySize(), interpolation);
         const TFieldList &fields = structure->fields();
 
         structVarying.structName = structure->name().c_str();
@@ -4004,15 +4004,15 @@
 {
     int registerIndex = (IsSampler(type.getBasicType()) ? mSamplerRegister : mUniformRegister);
 
-    const Uniform &uniform = declareUniformToList(type, name, registerIndex, mActiveUniforms);
+    const gl::Uniform &uniform = declareUniformToList(type, name, registerIndex, mActiveUniforms);
 
     if (IsSampler(type.getBasicType()))
     {
-        mSamplerRegister += HLSLVariableRegisterCount(uniform);
+        mSamplerRegister += gl::HLSLVariableRegisterCount(uniform);
     }
     else
     {
-        mUniformRegister += HLSLVariableRegisterCount(uniform);
+        mUniformRegister += gl::HLSLVariableRegisterCount(uniform);
     }
 
     return registerIndex;
diff --git a/src/compiler/translator/OutputHLSL.h b/src/compiler/translator/OutputHLSL.h
index 5d66fc5..ad42f2d 100644
--- a/src/compiler/translator/OutputHLSL.h
+++ b/src/compiler/translator/OutputHLSL.h
@@ -17,7 +17,7 @@
 
 #include "compiler/translator/intermediate.h"
 #include "compiler/translator/ParseContext.h"
-#include "compiler/translator/ShaderVariable.h"
+#include "common/shadervars.h"
 
 namespace sh
 {
@@ -32,11 +32,11 @@
     void output();
 
     TInfoSinkBase &getBodyStream();
-    const std::vector<Uniform> &getUniforms();
-    const ActiveInterfaceBlocks &getInterfaceBlocks() const;
-    const std::vector<Attribute> &getOutputVariables() const;
-    const std::vector<Attribute> &getAttributes() const;
-    const std::vector<Varying> &getVaryings() const;
+    const std::vector<gl::Uniform> &getUniforms();
+    const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const;
+    const std::vector<gl::Attribute> &getOutputVariables() const;
+    const std::vector<gl::Attribute> &getAttributes() const;
+    const std::vector<gl::Varying> &getVaryings() const;
 
     TString typeString(const TType &type);
     TString textureString(const TType &type);
@@ -184,10 +184,10 @@
     TString registerString(TIntermSymbol *operand);
     int samplerRegister(TIntermSymbol *sampler);
     int uniformRegister(TIntermSymbol *uniform);
-    void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<InterfaceBlockField>& output);
-    Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<Uniform>& output);
+    void declareInterfaceBlockField(const TType &type, const TString &name, std::vector<gl::InterfaceBlockField>& output);
+    gl::Uniform declareUniformToList(const TType &type, const TString &name, int registerIndex, std::vector<gl::Uniform>& output);
     void declareUniform(const TType &type, const TString &name, int index);
-    void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<Varying>& fieldsOut);
+    void declareVaryingToList(const TType &type, TQualifier baseTypeQualifier, const TString &name, std::vector<gl::Varying>& fieldsOut);
 
     // Returns the uniform's register index
     int declareUniformAndAssignRegister(const TType &type, const TString &name);
@@ -210,11 +210,11 @@
     static bool isVaryingOut(TQualifier qualifier);
     static bool isVarying(TQualifier qualifier);
 
-    std::vector<Uniform> mActiveUniforms;
-    ActiveInterfaceBlocks mActiveInterfaceBlocks;
-    std::vector<Attribute> mActiveOutputVariables;
-    std::vector<Attribute> mActiveAttributes;
-    std::vector<Varying> mActiveVaryings;
+    std::vector<gl::Uniform> mActiveUniforms;
+    std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
+    std::vector<gl::Attribute> mActiveOutputVariables;
+    std::vector<gl::Attribute> mActiveAttributes;
+    std::vector<gl::Varying> mActiveVaryings;
     std::map<TString, int> mStd140StructElementIndexes;
     std::map<TIntermTyped*, TString> mFlaggedStructMappedNames;
     std::map<TIntermTyped*, TString> mFlaggedStructOriginalNames;
diff --git a/src/compiler/translator/TranslatorHLSL.h b/src/compiler/translator/TranslatorHLSL.h
index 796a16c..6020a51 100644
--- a/src/compiler/translator/TranslatorHLSL.h
+++ b/src/compiler/translator/TranslatorHLSL.h
@@ -8,27 +8,27 @@
 #define COMPILER_TRANSLATORHLSL_H_
 
 #include "compiler/translator/ShHandle.h"
-#include "compiler/translator/ShaderVariable.h"
+#include "common/shadervars.h"
 
 class TranslatorHLSL : public TCompiler {
 public:
     TranslatorHLSL(ShShaderType type, ShShaderSpec spec, ShShaderOutput output);
 
     virtual TranslatorHLSL *getAsTranslatorHLSL() { return this; }
-    const std::vector<sh::Uniform> &getUniforms() { return mActiveUniforms; }
-    const sh::ActiveInterfaceBlocks &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
-    const std::vector<sh::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
-    const std::vector<sh::Attribute> &getAttributes() { return mActiveAttributes; }
-    const std::vector<sh::Varying> &getVaryings() { return mActiveVaryings; }
+    const std::vector<gl::Uniform> &getUniforms() { return mActiveUniforms; }
+    const std::vector<gl::InterfaceBlock> &getInterfaceBlocks() const { return mActiveInterfaceBlocks; }
+    const std::vector<gl::Attribute> &getOutputVariables() { return mActiveOutputVariables; }
+    const std::vector<gl::Attribute> &getAttributes() { return mActiveAttributes; }
+    const std::vector<gl::Varying> &getVaryings() { return mActiveVaryings; }
 
 protected:
     virtual void translate(TIntermNode* root);
 
-    std::vector<sh::Uniform> mActiveUniforms;
-    sh::ActiveInterfaceBlocks mActiveInterfaceBlocks;
-    std::vector<sh::Attribute> mActiveOutputVariables;
-    std::vector<sh::Attribute> mActiveAttributes;
-    std::vector<sh::Varying> mActiveVaryings;
+    std::vector<gl::Uniform> mActiveUniforms;
+    std::vector<gl::InterfaceBlock> mActiveInterfaceBlocks;
+    std::vector<gl::Attribute> mActiveOutputVariables;
+    std::vector<gl::Attribute> mActiveAttributes;
+    std::vector<gl::Varying> mActiveVaryings;
     ShShaderOutput mOutputType;
 };
 
diff --git a/src/libGLESv2/DynamicHLSL.cpp b/src/libGLESv2/DynamicHLSL.cpp
index 12a1ed9..193fca5 100644
--- a/src/libGLESv2/DynamicHLSL.cpp
+++ b/src/libGLESv2/DynamicHLSL.cpp
@@ -15,8 +15,7 @@
 #include "common/utilities.h"
 #include "libGLESv2/ProgramBinary.h"
 #include "libGLESv2/formatutils.h"
-
-#include "compiler/translator/HLSLLayoutEncoder.h"
+#include "common/blocklayout.h"
 
 static std::string Str(int i)
 {
@@ -90,12 +89,12 @@
 {
 }
 
-static bool packVarying(sh::Varying *varying, const int maxVaryingVectors, const sh::ShaderVariable *packing[][4])
+static bool packVarying(Varying *varying, const int maxVaryingVectors, const ShaderVariable *packing[][4])
 {
     GLenum transposedType = TransposeMatrixType(varying->type);
 
     // matrices within varying structs are not transposed
-    int registers = (varying->isStruct() ? sh::HLSLVariableRegisterCount(*varying) : gl::VariableRowCount(transposedType)) * varying->elementCount();
+    int registers = (varying->isStruct() ? HLSLVariableRegisterCount(*varying) : VariableRowCount(transposedType)) * varying->elementCount();
     int elements = (varying->isStruct() ? 4 : VariableColumnCount(transposedType));
     bool success = false;
 
@@ -219,7 +218,7 @@
 
 // Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
 // Returns the number of used varying registers, or -1 if unsuccesful
-int DynamicHLSL::packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader,
+int DynamicHLSL::packVaryings(InfoLog &infoLog, const ShaderVariable *packing[][4], FragmentShader *fragmentShader,
                               VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings)
 {
     const int maxVaryingVectors = mRenderer->getMaxVaryingVectors();
@@ -231,7 +230,7 @@
 
     for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
     {
-        sh::Varying *varying = &fragmentShader->mVaryings[varyingIndex];
+        Varying *varying = &fragmentShader->mVaryings[varyingIndex];
         if (packVarying(varying, maxVaryingVectors, packing))
         {
             packedVaryings.insert(varying->name);
@@ -251,7 +250,7 @@
             bool found = false;
             for (unsigned int varyingIndex = 0; varyingIndex < vertexShader->mVaryings.size(); varyingIndex++)
             {
-                sh::Varying *varying = &vertexShader->mVaryings[varyingIndex];
+                Varying *varying = &vertexShader->mVaryings[varyingIndex];
                 if (transformFeedbackVarying == varying->name)
                 {
                     if (!packVarying(varying, maxVaryingVectors, packing))
@@ -294,7 +293,7 @@
 
     for (unsigned int varyingIndex = 0; varyingIndex < shader->mVaryings.size(); varyingIndex++)
     {
-        sh::Varying *varying = &shader->mVaryings[varyingIndex];
+        Varying *varying = &shader->mVaryings[varyingIndex];
         if (varying->registerAssigned())
         {
             GLenum transposedType = TransposeMatrixType(varying->type);
@@ -306,9 +305,9 @@
                 {
                     switch (varying->interpolation)
                     {
-                      case sh::INTERPOLATION_SMOOTH:   varyingHLSL += "    ";                 break;
-                      case sh::INTERPOLATION_FLAT:     varyingHLSL += "    nointerpolation "; break;
-                      case sh::INTERPOLATION_CENTROID: varyingHLSL += "    centroid ";        break;
+                      case INTERPOLATION_SMOOTH:   varyingHLSL += "    ";                 break;
+                      case INTERPOLATION_FLAT:     varyingHLSL += "    nointerpolation "; break;
+                      case INTERPOLATION_CENTROID: varyingHLSL += "    centroid ";        break;
                       default:  UNREACHABLE();
                     }
 
@@ -325,8 +324,8 @@
                     }
                     else
                     {
-                        GLenum componentType = gl::UniformComponentType(transposedType);
-                        int columnCount = gl::VariableColumnCount(transposedType);
+                        GLenum componentType = UniformComponentType(transposedType);
+                        int columnCount = VariableColumnCount(transposedType);
                         typeString = gl_d3d::HLSLComponentTypeString(componentType, columnCount);
                     }
                     varyingHLSL += typeString + " v" + n + " : " + varyingSemantic + n + ";\n";
@@ -345,7 +344,7 @@
     return varyingHLSL;
 }
 
-std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[], const sh::Attribute shaderAttributes[]) const
+std::string DynamicHLSL::generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const
 {
     std::string structHLSL, initHLSL;
 
@@ -357,7 +356,7 @@
         ASSERT(inputIndex < MAX_VERTEX_ATTRIBS);
 
         const VertexFormat &vertexFormat = inputLayout[inputIndex];
-        const sh::Attribute &shaderAttribute = shaderAttributes[attributeIndex];
+        const Attribute &shaderAttribute = shaderAttributes[attributeIndex];
 
         if (!shaderAttribute.name.empty())
         {
@@ -409,7 +408,7 @@
            "}\n";
 }
 
-bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
+bool DynamicHLSL::generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ShaderVariable *packing[][4],
                                          std::string& pixelHLSL, std::string& vertexHLSL,
                                          FragmentShader *fragmentShader, VertexShader *vertexShader,
                                          const std::vector<std::string>& transformFeedbackVaryings,
@@ -568,7 +567,7 @@
 
     for (unsigned int vertVaryingIndex = 0; vertVaryingIndex < vertexShader->mVaryings.size(); vertVaryingIndex++)
     {
-        sh::Varying *varying = &vertexShader->mVaryings[vertVaryingIndex];
+        Varying *varying = &vertexShader->mVaryings[vertVaryingIndex];
         if (varying->registerAssigned())
         {
             for (unsigned int elementIndex = 0; elementIndex < varying->elementCount(); elementIndex++)
@@ -687,11 +686,11 @@
     {
         defineOutputVariables(fragmentShader, programOutputVars);
 
-        const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
+        const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
         for (auto locationIt = programOutputVars->begin(); locationIt != programOutputVars->end(); locationIt++)
         {
             const VariableLocation &outputLocation = locationIt->second;
-            const sh::ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
+            const ShaderVariable &outputVariable = shaderOutputVars[outputLocation.index];
             const std::string &elementString = (outputLocation.element == GL_INVALID_INDEX ? "" : Str(outputLocation.element));
 
             pixelHLSL += "    " + gl_d3d::HLSLTypeString(outputVariable.type) +
@@ -767,7 +766,7 @@
 
     for (unsigned int varyingIndex = 0; varyingIndex < fragmentShader->mVaryings.size(); varyingIndex++)
     {
-        sh::Varying *varying = &fragmentShader->mVaryings[varyingIndex];
+        Varying *varying = &fragmentShader->mVaryings[varyingIndex];
         if (varying->registerAssigned())
         {
             for (unsigned int elementIndex = 0; elementIndex < varying->elementCount(); elementIndex++)
@@ -851,11 +850,11 @@
 
 void DynamicHLSL::defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const
 {
-    const std::vector<sh::Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
+    const std::vector<Attribute> &shaderOutputVars = fragmentShader->getOutputVariables();
 
     for (unsigned int outputVariableIndex = 0; outputVariableIndex < shaderOutputVars.size(); outputVariableIndex++)
     {
-        const sh::Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
+        const Attribute &outputVariable = shaderOutputVars[outputVariableIndex];
         const int baseLocation = outputVariable.location == -1 ? 0 : outputVariable.location;
 
         if (outputVariable.arraySize > 0)
@@ -875,14 +874,14 @@
     }
 }
 
-std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+std::string DynamicHLSL::generateGeometryShaderHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
 {
     // for now we only handle point sprite emulation
     ASSERT(vertexShader->mUsesPointSize && mRenderer->getMajorShaderModel() >= 4);
     return generatePointSpriteHLSL(registers, packing, fragmentShader, vertexShader);
 }
 
-std::string DynamicHLSL::generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
+std::string DynamicHLSL::generatePointSpriteHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const
 {
     ASSERT(registers >= 0);
     ASSERT(vertexShader->mUsesPointSize);
@@ -1015,7 +1014,7 @@
     return name;
 }
 
-std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const
+std::string DynamicHLSL::generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const
 {
     std::string attribString = "input." + decorateVariable(shaderAttrib.name);
 
diff --git a/src/libGLESv2/DynamicHLSL.h b/src/libGLESv2/DynamicHLSL.h
index e50e9b4..022a595 100644
--- a/src/libGLESv2/DynamicHLSL.h
+++ b/src/libGLESv2/DynamicHLSL.h
@@ -11,12 +11,6 @@
 
 #include "common/angleutils.h"
 
-namespace sh
-{
-struct ShaderVariable;
-struct Attribute;
-}
-
 namespace rx
 {
 class Renderer;
@@ -32,23 +26,25 @@
 struct LinkedVarying;
 class VertexAttribute;
 struct VertexFormat;
+struct ShaderVariable;
+struct Attribute;
 
 class DynamicHLSL
 {
   public:
     explicit DynamicHLSL(rx::Renderer *const renderer);
 
-    int packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader,
+    int packVaryings(InfoLog &infoLog, const ShaderVariable *packing[][4], FragmentShader *fragmentShader,
                      VertexShader *vertexShader, const std::vector<std::string>& transformFeedbackVaryings);
-    std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const sh::Attribute shaderAttributes[]) const;
-    bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
+    std::string generateInputLayoutHLSL(const VertexFormat inputLayout[], const Attribute shaderAttributes[]) const;
+    bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const ShaderVariable *packing[][4],
                                 std::string& pixelHLSL, std::string& vertexHLSL,
                                 FragmentShader *fragmentShader, VertexShader *vertexShader,
                                 const std::vector<std::string>& transformFeedbackVaryings,
                                 std::vector<LinkedVarying> *linkedVaryings,
                                 std::map<int, VariableLocation> *programOutputVars) const;
 
-    std::string generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+    std::string generateGeometryShaderHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
 
     static const std::string VERTEX_ATTRIBUTE_STUB_STRING;
 
@@ -60,12 +56,12 @@
     std::string generateVaryingHLSL(VertexShader *shader, const std::string &varyingSemantic,
                                     std::vector<LinkedVarying> *linkedVaryings) const;
     void defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const;
-    std::string generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
+    std::string generatePointSpriteHLSL(int registers, const ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
 
     // Prepend an underscore
     static std::string decorateVariable(const std::string &name);
 
-    std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const sh::ShaderVariable &shaderAttrib) const;
+    std::string generateAttributeConversionHLSL(const VertexFormat &vertexFormat, const ShaderVariable &shaderAttrib) const;
 };
 
 // Utility method shared between ProgramBinary and DynamicHLSL
diff --git a/src/libGLESv2/ProgramBinary.cpp b/src/libGLESv2/ProgramBinary.cpp
index 1c51968..5ab101a 100644
--- a/src/libGLESv2/ProgramBinary.cpp
+++ b/src/libGLESv2/ProgramBinary.cpp
@@ -50,14 +50,14 @@
     return subscript;
 }
 
-void GetInputLayoutFromShader(const std::vector<sh::Attribute> &shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS])
+void GetInputLayoutFromShader(const std::vector<gl::Attribute> &shaderAttributes, VertexFormat inputLayout[MAX_VERTEX_ATTRIBS])
 {
     size_t layoutIndex = 0;
     for (size_t attributeIndex = 0; attributeIndex < shaderAttributes.size(); attributeIndex++)
     {
         ASSERT(layoutIndex < MAX_VERTEX_ATTRIBS);
 
-        const sh::Attribute &shaderAttr = shaderAttributes[attributeIndex];
+        const gl::Attribute &shaderAttr = shaderAttributes[attributeIndex];
 
         if (shaderAttr.type != GL_NONE)
         {
@@ -479,7 +479,7 @@
     const int components = UniformComponentCount(targetUniformType);
     const GLenum targetBoolType = UniformBoolVectorType(targetUniformType);
 
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
     targetUniform->dirty = true;
 
     int elementCount = targetUniform->elementCount();
@@ -623,7 +623,7 @@
         return false;
     }
 
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
     targetUniform->dirty = true;
 
     if (targetUniform->type != targetUniformType)
@@ -710,7 +710,7 @@
         return false;
     }
 
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
     targetUniform->dirty = true;
 
     int elementCount = targetUniform->elementCount();
@@ -799,7 +799,7 @@
         return false;
     }
 
-    Uniform *targetUniform = mUniforms[mUniformIndex[location].index];
+    LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
 
     // sized queries -- ensure the provided buffer is large enough
     if (bufSize)
@@ -909,7 +909,7 @@
     // Retrieve sampler uniform values
     for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
     {
-        Uniform *targetUniform = mUniforms[uniformIndex];
+        LinkedUniform *targetUniform = mUniforms[uniformIndex];
 
         if (targetUniform->dirty)
         {
@@ -1008,17 +1008,17 @@
 
 bool ProgramBinary::linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader)
 {
-    std::vector<sh::Varying> &fragmentVaryings = fragmentShader->getVaryings();
-    std::vector<sh::Varying> &vertexVaryings = vertexShader->getVaryings();
+    std::vector<gl::Varying> &fragmentVaryings = fragmentShader->getVaryings();
+    std::vector<gl::Varying> &vertexVaryings = vertexShader->getVaryings();
 
     for (size_t fragVaryingIndex = 0; fragVaryingIndex < fragmentVaryings.size(); fragVaryingIndex++)
     {
-        sh::Varying *input = &fragmentVaryings[fragVaryingIndex];
+        gl::Varying *input = &fragmentVaryings[fragVaryingIndex];
         bool matched = false;
 
         for (size_t vertVaryingIndex = 0; vertVaryingIndex < vertexVaryings.size(); vertVaryingIndex++)
         {
-            sh::Varying *output = &vertexVaryings[vertVaryingIndex];
+            gl::Varying *output = &vertexVaryings[vertVaryingIndex];
             if (output->name == input->name)
             {
                 if (!linkValidateVariables(infoLog, output->name, *input, *output))
@@ -1153,9 +1153,9 @@
         stream.read(&matrixStride);
         stream.read(&isRowMajorMatrix);
 
-        const sh::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
+        const gl::BlockMemberInfo blockInfo(offset, arrayStride, matrixStride, isRowMajorMatrix);
 
-        mUniforms[i] = new Uniform(type, precision, name, arraySize, blockIndex, blockInfo);
+        mUniforms[i] = new LinkedUniform(type, precision, name, arraySize, blockIndex, blockInfo);
         
         stream.read(&mUniforms[i]->psRegisterIndex);
         stream.read(&mUniforms[i]->vsRegisterIndex);
@@ -1355,7 +1355,7 @@
     stream.write(mUniforms.size());
     for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); ++uniformIndex)
     {
-        const Uniform &uniform = *mUniforms[uniformIndex];
+        const LinkedUniform &uniform = *mUniforms[uniformIndex];
 
         stream.write(uniform.type);
         stream.write(uniform.precision);
@@ -1527,7 +1527,7 @@
     mVertexWorkarounds = vertexShader->getD3DWorkarounds();
 
     // Map the varyings to the register file
-    const sh::ShaderVariable *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
+    const gl::ShaderVariable *packing[IMPLEMENTATION_MAX_VARYING_VECTORS][4] = {NULL};
     int registers = mDynamicHLSL->packVaryings(infoLog, packing, fragmentShader, vertexShader, transformFeedbackVaryings);
 
     if (registers < 0)
@@ -1564,9 +1564,9 @@
     // special case for gl_DepthRange, the only built-in uniform (also a struct)
     if (vertexShader->usesDepthRange() || fragmentShader->usesDepthRange())
     {
-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, sh::BlockMemberInfo::defaultBlockInfo));
-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, sh::BlockMemberInfo::defaultBlockInfo));
-        mUniforms.push_back(new Uniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, sh::BlockMemberInfo::defaultBlockInfo));
+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.near", 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.far", 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
+        mUniforms.push_back(new LinkedUniform(GL_FLOAT, GL_HIGH_FLOAT, "gl_DepthRange.diff", 0, -1, gl::BlockMemberInfo::defaultBlockInfo));
     }
 
     if (!linkUniformBlocks(infoLog, vertexShader->getInterfaceBlocks(), fragmentShader->getInterfaceBlocks()))
@@ -1625,12 +1625,12 @@
 bool ProgramBinary::linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader)
 {
     unsigned int usedLocations = 0;
-    const std::vector<sh::Attribute> &activeAttributes = vertexShader->activeAttributes();
+    const std::vector<gl::Attribute> &activeAttributes = vertexShader->activeAttributes();
 
     // Link attributes that have a binding location
     for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++)
     {
-        const sh::Attribute &attribute = activeAttributes[attributeIndex];
+        const gl::Attribute &attribute = activeAttributes[attributeIndex];
         const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
 
         mShaderAttributes[attributeIndex] = attribute;
@@ -1649,7 +1649,7 @@
             for (int row = 0; row < rows; row++)
             {
                 const int rowLocation = location + row;
-                sh::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation];
+                gl::ShaderVariable &linkedAttribute = mLinkedAttribute[rowLocation];
 
                 // In GLSL 3.00, attribute aliasing produces a link error
                 // In GLSL 1.00, attribute aliasing is allowed
@@ -1671,7 +1671,7 @@
     // Link attributes that don't have a binding location
     for (unsigned int attributeIndex = 0; attributeIndex < activeAttributes.size(); attributeIndex++)
     {
-        const sh::Attribute &attribute = activeAttributes[attributeIndex];
+        const gl::Attribute &attribute = activeAttributes[attributeIndex];
         const int location = attribute.location == -1 ? attributeBindings.getAttributeBinding(attribute.name) : attribute.location;
 
         if (location == -1)   // Not set by glBindAttribLocation or by location layout qualifier
@@ -1706,7 +1706,7 @@
     return true;
 }
 
-bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision)
+bool ProgramBinary::linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const gl::ShaderVariable &vertexVariable, const gl::ShaderVariable &fragmentVariable, bool validatePrecision)
 {
     if (vertexVariable.type != fragmentVariable.type)
     {
@@ -1758,14 +1758,14 @@
     return true;
 }
 
-bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform)
+bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::Uniform &vertexUniform, const gl::Uniform &fragmentUniform)
 {
     if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
     {
         return false;
     }
 
-    if (!linkValidateFields<sh::Uniform>(infoLog, uniformName, vertexUniform, fragmentUniform))
+    if (!linkValidateFields<gl::Uniform>(infoLog, uniformName, vertexUniform, fragmentUniform))
     {
         return false;
     }
@@ -1773,7 +1773,7 @@
     return true;
 }
 
-bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying)
+bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const gl::Varying &vertexVarying, const gl::Varying &fragmentVarying)
 {
     if (!linkValidateVariablesBase(infoLog, varyingName, vertexVarying, fragmentVarying, false))
     {
@@ -1786,7 +1786,7 @@
         return false;
     }
 
-    if (!linkValidateFields<sh::Varying>(infoLog, varyingName, vertexVarying, fragmentVarying))
+    if (!linkValidateFields<gl::Varying>(infoLog, varyingName, vertexVarying, fragmentVarying))
     {
         return false;
     }
@@ -1794,7 +1794,7 @@
     return true;
 }
 
-bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform)
+bool ProgramBinary::linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const gl::InterfaceBlockField &vertexUniform, const gl::InterfaceBlockField &fragmentUniform)
 {
     if (!linkValidateVariablesBase(infoLog, uniformName, vertexUniform, fragmentUniform, true))
     {
@@ -1807,7 +1807,7 @@
         return false;
     }
 
-    if (!linkValidateFields<sh::InterfaceBlockField>(infoLog, uniformName, vertexUniform, fragmentUniform))
+    if (!linkValidateFields<gl::InterfaceBlockField>(infoLog, uniformName, vertexUniform, fragmentUniform))
     {
         return false;
     }
@@ -1815,25 +1815,25 @@
     return true;
 }
 
-bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector<sh::Uniform> &vertexUniforms, const std::vector<sh::Uniform> &fragmentUniforms)
+bool ProgramBinary::linkUniforms(InfoLog &infoLog, const std::vector<gl::Uniform> &vertexUniforms, const std::vector<gl::Uniform> &fragmentUniforms)
 {
     // Check that uniforms defined in the vertex and fragment shaders are identical
-    typedef std::map<std::string, const sh::Uniform*> UniformMap;
+    typedef std::map<std::string, const gl::Uniform*> UniformMap;
     UniformMap linkedUniforms;
 
     for (unsigned int vertexUniformIndex = 0; vertexUniformIndex < vertexUniforms.size(); vertexUniformIndex++)
     {
-        const sh::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex];
+        const gl::Uniform &vertexUniform = vertexUniforms[vertexUniformIndex];
         linkedUniforms[vertexUniform.name] = &vertexUniform;
     }
 
     for (unsigned int fragmentUniformIndex = 0; fragmentUniformIndex < fragmentUniforms.size(); fragmentUniformIndex++)
     {
-        const sh::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex];
+        const gl::Uniform &fragmentUniform = fragmentUniforms[fragmentUniformIndex];
         UniformMap::const_iterator entry = linkedUniforms.find(fragmentUniform.name);
         if (entry != linkedUniforms.end())
         {
-            const sh::Uniform &vertexUniform = *entry->second;
+            const gl::Uniform &vertexUniform = *entry->second;
             const std::string &uniformName = "uniform '" + vertexUniform.name + "'";
             if (!linkValidateVariables(infoLog, uniformName, vertexUniform, fragmentUniform))
             {
@@ -1863,7 +1863,7 @@
     return true;
 }
 
-int totalRegisterCount(const sh::Uniform &uniform)
+int totalRegisterCount(const gl::Uniform &uniform)
 {
     int registerCount = 0;
 
@@ -1912,7 +1912,7 @@
     return TEXTURE_2D;
 }
 
-bool ProgramBinary::defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog)
+bool ProgramBinary::defineUniform(GLenum shader, const gl::Uniform &constant, InfoLog &infoLog)
 {
     if (constant.isStruct())
     {
@@ -1924,9 +1924,9 @@
             {
                 for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++)
                 {
-                    const sh::Uniform &field = constant.fields[fieldIndex];
+                    const gl::Uniform &field = constant.fields[fieldIndex];
                     const std::string &uniformName = constant.name + ArrayString(elementIndex) + "." + field.name;
-                    sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
+                    gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
                                              elementRegisterIndex, field.elementIndex);
 
                     fieldUniform.fields = field.fields;
@@ -1942,10 +1942,10 @@
         {
             for (size_t fieldIndex = 0; fieldIndex < constant.fields.size(); fieldIndex++)
             {
-                const sh::Uniform &field = constant.fields[fieldIndex];
+                const gl::Uniform &field = constant.fields[fieldIndex];
                 const std::string &uniformName = constant.name + "." + field.name;
 
-                sh::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
+                gl::Uniform fieldUniform(field.type, field.precision, uniformName.c_str(), field.arraySize,
                                          field.registerIndex, field.elementIndex);
 
                 fieldUniform.fields = field.fields;
@@ -2003,7 +2003,7 @@
         while (samplerIndex < constant.registerIndex + constant.arraySize);
     }
 
-    Uniform *uniform = NULL;
+    LinkedUniform *uniform = NULL;
     GLint location = getUniformLocation(constant.name);
 
     if (location >= 0)   // Previously defined, type and precision must match
@@ -2012,7 +2012,7 @@
     }
     else
     {
-        uniform = new Uniform(constant.type, constant.precision, constant.name, constant.arraySize, -1, sh::BlockMemberInfo::defaultBlockInfo);
+        uniform = new LinkedUniform(constant.type, constant.precision, constant.name, constant.arraySize, -1, gl::BlockMemberInfo::defaultBlockInfo);
         uniform->registerElement = constant.elementIndex;
     }
 
@@ -2065,7 +2065,7 @@
     return true;
 }
 
-bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock)
+bool ProgramBinary::areMatchingInterfaceBlocks(InfoLog &infoLog, const gl::InterfaceBlock &vertexInterfaceBlock, const gl::InterfaceBlock &fragmentInterfaceBlock)
 {
     const char* blockName = vertexInterfaceBlock.name.c_str();
 
@@ -2091,8 +2091,8 @@
     const unsigned int numBlockMembers = vertexInterfaceBlock.fields.size();
     for (unsigned int blockMemberIndex = 0; blockMemberIndex < numBlockMembers; blockMemberIndex++)
     {
-        const sh::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
-        const sh::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
+        const gl::InterfaceBlockField &vertexMember = vertexInterfaceBlock.fields[blockMemberIndex];
+        const gl::InterfaceBlockField &fragmentMember = fragmentInterfaceBlock.fields[blockMemberIndex];
 
         if (vertexMember.name != fragmentMember.name)
         {
@@ -2111,25 +2111,26 @@
     return true;
 }
 
-bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const sh::ActiveInterfaceBlocks &vertexInterfaceBlocks, const sh::ActiveInterfaceBlocks &fragmentInterfaceBlocks)
+bool ProgramBinary::linkUniformBlocks(InfoLog &infoLog, const std::vector<gl::InterfaceBlock> &vertexInterfaceBlocks,
+                                      const std::vector<gl::InterfaceBlock> &fragmentInterfaceBlocks)
 {
     // Check that interface blocks defined in the vertex and fragment shaders are identical
-    typedef std::map<std::string, const sh::InterfaceBlock*> UniformBlockMap;
+    typedef std::map<std::string, const gl::InterfaceBlock*> UniformBlockMap;
     UniformBlockMap linkedUniformBlocks;
 
     for (unsigned int blockIndex = 0; blockIndex < vertexInterfaceBlocks.size(); blockIndex++)
     {
-        const sh::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
+        const gl::InterfaceBlock &vertexInterfaceBlock = vertexInterfaceBlocks[blockIndex];
         linkedUniformBlocks[vertexInterfaceBlock.name] = &vertexInterfaceBlock;
     }
 
     for (unsigned int blockIndex = 0; blockIndex < fragmentInterfaceBlocks.size(); blockIndex++)
     {
-        const sh::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
+        const gl::InterfaceBlock &fragmentInterfaceBlock = fragmentInterfaceBlocks[blockIndex];
         UniformBlockMap::const_iterator entry = linkedUniformBlocks.find(fragmentInterfaceBlock.name);
         if (entry != linkedUniformBlocks.end())
         {
-            const sh::InterfaceBlock &vertexInterfaceBlock = *entry->second;
+            const gl::InterfaceBlock &vertexInterfaceBlock = *entry->second;
             if (!areMatchingInterfaceBlocks(infoLog, vertexInterfaceBlock, fragmentInterfaceBlock))
             {
                 return false;
@@ -2214,11 +2215,11 @@
     return true;
 }
 
-void ProgramBinary::defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes)
+void ProgramBinary::defineUniformBlockMembers(const std::vector<gl::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes)
 {
     for (unsigned int uniformIndex = 0; uniformIndex < fields.size(); uniformIndex++)
     {
-        const sh::InterfaceBlockField &field = fields[uniformIndex];
+        const gl::InterfaceBlockField &field = fields[uniformIndex];
         const std::string &fieldName = (prefix.empty() ? field.name : prefix + "." + field.name);
 
         if (!field.fields.empty())
@@ -2238,8 +2239,8 @@
         }
         else
         {
-            Uniform *newUniform = new Uniform(field.type, field.precision, fieldName, field.arraySize,
-                                              blockIndex, **blockInfoItr);
+            LinkedUniform *newUniform = new LinkedUniform(field.type, field.precision, fieldName, field.arraySize,
+                                                          blockIndex, **blockInfoItr);
 
             // add to uniform list, but not index, since uniform block uniforms have no location
             blockUniformIndexes->push_back(mUniforms.size());
@@ -2249,7 +2250,7 @@
     }
 }
 
-bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock)
+bool ProgramBinary::defineUniformBlock(InfoLog &infoLog, GLenum shader, const gl::InterfaceBlock &interfaceBlock)
 {
     // create uniform block entries if they do not exist
     if (getUniformBlockIndex(interfaceBlock.name) == GL_INVALID_INDEX)
@@ -2456,7 +2457,7 @@
 
 GLint ProgramBinary::getActiveUniformi(GLuint index, GLenum pname) const
 {
-    const gl::Uniform& uniform = *mUniforms[index];
+    const gl::LinkedUniform& uniform = *mUniforms[index];
 
     switch (pname)
     {
@@ -2719,7 +2720,7 @@
     unsigned int fragmentRegisters = 0;
     for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
     {
-        const Uniform &uniform = *mUniforms[uniformIndex];
+        const LinkedUniform &uniform = *mUniforms[uniformIndex];
 
         if (!IsSampler(uniform.type))
         {
diff --git a/src/libGLESv2/ProgramBinary.h b/src/libGLESv2/ProgramBinary.h
index 52e24f3..9b65d01 100644
--- a/src/libGLESv2/ProgramBinary.h
+++ b/src/libGLESv2/ProgramBinary.h
@@ -84,7 +84,7 @@
     ~ProgramBinary();
 
     rx::ShaderExecutable *getPixelExecutable() const;
-    rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS]);
+    rx::ShaderExecutable *getVertexExecutableForInputLayout(const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS]);
     rx::ShaderExecutable *getGeometryExecutable() const;
 
     GLuint getAttributeLocation(const char *name);
@@ -128,7 +128,7 @@
 
     void dirtyAllUniforms();
     void applyUniforms();
-    bool applyUniformBuffers(const std::vector<gl::Buffer*> boundBuffers);
+    bool applyUniformBuffers(const std::vector<Buffer*> boundBuffers);
 
     bool load(InfoLog &infoLog, const void *binary, GLsizei length);
     bool save(void* binary, GLsizei bufSize, GLsizei *length);
@@ -167,9 +167,9 @@
     int getShaderVersion() const;
 
     void initAttributesByLayout();
-    void sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
+    void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
 
-    const UniformArray &getUniforms() const { return mUniforms; }
+    const std::vector<LinkedUniform*> &getUniforms() const { return mUniforms; }
     const rx::UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
     const rx::UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
 
@@ -179,25 +179,25 @@
     bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader);
     bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
 
-    typedef sh::BlockMemberInfoArray::const_iterator BlockInfoItr;
+    typedef BlockMemberInfoArray::const_iterator BlockInfoItr;
 
     template <class ShaderVarType>
     bool linkValidateFields(InfoLog &infoLog, const std::string &varName, const ShaderVarType &vertexVar, const ShaderVarType &fragmentVar);
-    bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const sh::ShaderVariable &vertexVariable, const sh::ShaderVariable &fragmentVariable, bool validatePrecision);
+    bool linkValidateVariablesBase(InfoLog &infoLog, const std::string &variableName, const ShaderVariable &vertexVariable, const ShaderVariable &fragmentVariable, bool validatePrecision);
 
-    bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
-    bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
-    bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
-    bool linkUniforms(InfoLog &infoLog, const std::vector<sh::Uniform> &vertexUniforms, const std::vector<sh::Uniform> &fragmentUniforms);
-    bool defineUniform(GLenum shader, const sh::Uniform &constant, InfoLog &infoLog);
-    bool areMatchingInterfaceBlocks(InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock, const sh::InterfaceBlock &fragmentInterfaceBlock);
-    bool linkUniformBlocks(InfoLog &infoLog, const sh::ActiveInterfaceBlocks &vertexUniformBlocks, const sh::ActiveInterfaceBlocks &fragmentUniformBlocks);
+    bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const Uniform &vertexUniform, const Uniform &fragmentUniform);
+    bool linkValidateVariables(InfoLog &infoLog, const std::string &varyingName, const Varying &vertexVarying, const Varying &fragmentVarying);
+    bool linkValidateVariables(InfoLog &infoLog, const std::string &uniformName, const InterfaceBlockField &vertexUniform, const InterfaceBlockField &fragmentUniform);
+    bool linkUniforms(InfoLog &infoLog, const std::vector<Uniform> &vertexUniforms, const std::vector<Uniform> &fragmentUniforms);
+    bool defineUniform(GLenum shader, const Uniform &constant, InfoLog &infoLog);
+    bool areMatchingInterfaceBlocks(InfoLog &infoLog, const InterfaceBlock &vertexInterfaceBlock, const InterfaceBlock &fragmentInterfaceBlock);
+    bool linkUniformBlocks(InfoLog &infoLog, const std::vector<InterfaceBlock> &vertexUniformBlocks, const std::vector<InterfaceBlock> &fragmentUniformBlocks);
     bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
                                                const std::vector<std::string> &transformFeedbackVaryingNames,
                                                GLenum transformFeedbackBufferMode,
                                                std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings) const;
-    void defineUniformBlockMembers(const std::vector<sh::InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
-    bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const sh::InterfaceBlock &interfaceBlock);
+    void defineUniformBlockMembers(const std::vector<InterfaceBlockField> &fields, const std::string &prefix, int blockIndex, BlockInfoItr *blockInfoItr, std::vector<unsigned int> *blockUniformIndexes);
+    bool defineUniformBlock(InfoLog &infoLog, GLenum shader, const InterfaceBlock &interfaceBlock);
     bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex);
     void defineOutputVariables(FragmentShader *fragmentShader);
     void initializeUniformStorage();
@@ -217,17 +217,17 @@
     {
       public:
         VertexExecutable(rx::Renderer *const renderer,
-                         const VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS],
+                         const VertexFormat inputLayout[MAX_VERTEX_ATTRIBS],
                          rx::ShaderExecutable *shaderExecutable);
         ~VertexExecutable();
 
-        bool matchesInputLayout(const VertexFormat attributes[gl::MAX_VERTEX_ATTRIBS]) const;
+        bool matchesInputLayout(const VertexFormat attributes[MAX_VERTEX_ATTRIBS]) const;
 
         const VertexFormat *inputs() const { return mInputs; }
         rx::ShaderExecutable *shaderExecutable() const { return mShaderExecutable; }
 
       private:
-        VertexFormat mInputs[gl::MAX_VERTEX_ATTRIBS];
+        VertexFormat mInputs[MAX_VERTEX_ATTRIBS];
         rx::ShaderExecutable *mShaderExecutable;
     };
 
@@ -240,8 +240,8 @@
     rx::ShaderExecutable *mGeometryExecutable;
     rx::ShaderExecutable *mPixelExecutable;
 
-    sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
-    sh::Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
+    Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
+    Attribute mShaderAttributes[MAX_VERTEX_ATTRIBS];
     int mSemanticIndex[MAX_VERTEX_ATTRIBS];
     int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
 
@@ -264,8 +264,8 @@
     bool mUsesPointSize;
     int mShaderVersion;
 
-    UniformArray mUniforms;
-    UniformBlockArray mUniformBlocks;
+    std::vector<LinkedUniform*> mUniforms;
+    std::vector<UniformBlock*> mUniformBlocks;
     std::vector<VariableLocation> mUniformIndex;
     std::map<int, VariableLocation> mOutputVariables;
     rx::UniformStorage *mVertexUniformStorage;
diff --git a/src/libGLESv2/Shader.cpp b/src/libGLESv2/Shader.cpp
index 10bcd74..baced15 100644
--- a/src/libGLESv2/Shader.cpp
+++ b/src/libGLESv2/Shader.cpp
@@ -115,17 +115,17 @@
     getSourceImpl(mHlsl, bufSize, length, buffer);
 }
 
-const std::vector<sh::Uniform> &Shader::getUniforms() const
+const std::vector<Uniform> &Shader::getUniforms() const
 {
     return mActiveUniforms;
 }
 
-const sh::ActiveInterfaceBlocks &Shader::getInterfaceBlocks() const
+const std::vector<InterfaceBlock> &Shader::getInterfaceBlocks() const
 {
     return mActiveInterfaceBlocks;
 }
 
-std::vector<sh::Varying> &Shader::getVaryings()
+std::vector<Varying> &Shader::getVaryings()
 {
     return mVaryings;
 }
@@ -225,7 +225,7 @@
 {
     if (!mHlsl.empty())
     {
-        std::vector<sh::Varying> *activeVaryings;
+        std::vector<Varying> *activeVaryings;
         ShGetInfoPointer(compiler, SH_ACTIVE_VARYINGS_ARRAY, reinterpret_cast<void**>(&activeVaryings));
         mVaryings = *activeVaryings;
 
@@ -357,11 +357,11 @@
 
         void *activeUniforms;
         ShGetInfoPointer(compiler, SH_ACTIVE_UNIFORMS_ARRAY, &activeUniforms);
-        mActiveUniforms = *(std::vector<sh::Uniform>*)activeUniforms;
+        mActiveUniforms = *(std::vector<Uniform>*)activeUniforms;
 
         void *activeInterfaceBlocks;
         ShGetInfoPointer(compiler, SH_ACTIVE_INTERFACE_BLOCKS_ARRAY, &activeInterfaceBlocks);
-        mActiveInterfaceBlocks = *(sh::ActiveInterfaceBlocks*)activeInterfaceBlocks;
+        mActiveInterfaceBlocks = *(std::vector<InterfaceBlock>*)activeInterfaceBlocks;
     }
     else
     {
@@ -440,7 +440,7 @@
 };
 
 // true if varying x has a higher priority in packing than y
-bool Shader::compareVarying(const sh::ShaderVariable &x, const sh::ShaderVariable &y)
+bool Shader::compareVarying(const ShaderVariable &x, const ShaderVariable &y)
 {
     if (x.type == y.type)
     {
@@ -511,7 +511,7 @@
         int semanticIndex = 0;
         for (unsigned int attributeIndex = 0; attributeIndex < mActiveAttributes.size(); attributeIndex++)
         {
-            const sh::ShaderVariable &attribute = mActiveAttributes[attributeIndex];
+            const ShaderVariable &attribute = mActiveAttributes[attributeIndex];
 
             if (attribute.name == attributeName)
             {
@@ -532,7 +532,7 @@
     {
         void *activeAttributes;
         ShGetInfoPointer(mVertexCompiler, SH_ACTIVE_ATTRIBUTES_ARRAY, &activeAttributes);
-        mActiveAttributes = *(std::vector<sh::Attribute>*)activeAttributes;
+        mActiveAttributes = *(std::vector<Attribute>*)activeAttributes;
     }
 }
 
@@ -563,7 +563,7 @@
     {
         void *activeOutputVariables;
         ShGetInfoPointer(mFragmentCompiler, SH_ACTIVE_OUTPUT_VARIABLES_ARRAY, &activeOutputVariables);
-        mActiveOutputVariables = *(std::vector<sh::Attribute>*)activeOutputVariables;
+        mActiveOutputVariables = *(std::vector<Attribute>*)activeOutputVariables;
     }
 }
 
@@ -574,7 +574,7 @@
     mActiveOutputVariables.clear();
 }
 
-const std::vector<sh::Attribute> &FragmentShader::getOutputVariables() const
+const std::vector<Attribute> &FragmentShader::getOutputVariables() const
 {
     return mActiveOutputVariables;
 }
diff --git a/src/libGLESv2/Shader.h b/src/libGLESv2/Shader.h
index 0ec4ecf..e7df4e9 100644
--- a/src/libGLESv2/Shader.h
+++ b/src/libGLESv2/Shader.h
@@ -19,7 +19,7 @@
 #include <list>
 #include <vector>
 
-#include "compiler/translator/ShaderVariable.h"
+#include "common/shadervars.h"
 #include "common/angleutils.h"
 #include "libGLESv2/angletypes.h"
 
@@ -52,9 +52,9 @@
     void getSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
     int getTranslatedSourceLength() const;
     void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
-    const std::vector<sh::Uniform> &getUniforms() const;
-    const sh::ActiveInterfaceBlocks &getInterfaceBlocks() const;
-    std::vector<sh::Varying> &getVaryings();
+    const std::vector<Uniform> &getUniforms() const;
+    const std::vector<InterfaceBlock> &getInterfaceBlocks() const;
+    std::vector<Varying> &getVaryings();
 
     virtual void compile() = 0;
     virtual void uncompile();
@@ -82,11 +82,11 @@
 
     void getSourceImpl(const std::string &source, GLsizei bufSize, GLsizei *length, char *buffer) const;
 
-    static bool compareVarying(const sh::ShaderVariable &x, const sh::ShaderVariable &y);
+    static bool compareVarying(const ShaderVariable &x, const ShaderVariable &y);
 
     const rx::Renderer *const mRenderer;
 
-    std::vector<sh::Varying> mVaryings;
+    std::vector<Varying> mVaryings;
 
     bool mUsesMultipleRenderTargets;
     bool mUsesFragColor;
@@ -116,8 +116,8 @@
     std::string mSource;
     std::string mHlsl;
     std::string mInfoLog;
-    std::vector<sh::Uniform> mActiveUniforms;
-    sh::ActiveInterfaceBlocks mActiveInterfaceBlocks;
+    std::vector<Uniform> mActiveUniforms;
+    std::vector<InterfaceBlock> mActiveInterfaceBlocks;
 
     ResourceManager *mResourceManager;
 };
@@ -136,14 +136,14 @@
     virtual void uncompile();
     int getSemanticIndex(const std::string &attributeName);
 
-    const std::vector<sh::Attribute> &activeAttributes() const { return mActiveAttributes; }
+    const std::vector<Attribute> &activeAttributes() const { return mActiveAttributes; }
 
   private:
     DISALLOW_COPY_AND_ASSIGN(VertexShader);
 
     void parseAttributes();
 
-    std::vector<sh::Attribute> mActiveAttributes;
+    std::vector<Attribute> mActiveAttributes;
 };
 
 class FragmentShader : public Shader
@@ -156,12 +156,12 @@
     virtual GLenum getType();
     virtual void compile();
     virtual void uncompile();
-    const std::vector<sh::Attribute> &getOutputVariables() const;
+    const std::vector<Attribute> &getOutputVariables() const;
 
   private:
     DISALLOW_COPY_AND_ASSIGN(FragmentShader);
 
-    std::vector<sh::Attribute> mActiveOutputVariables;
+    std::vector<Attribute> mActiveOutputVariables;
 };
 }
 
diff --git a/src/libGLESv2/Uniform.cpp b/src/libGLESv2/Uniform.cpp
index 175aa08..a5ab7cb 100644
--- a/src/libGLESv2/Uniform.cpp
+++ b/src/libGLESv2/Uniform.cpp
@@ -12,7 +12,8 @@
 namespace gl
 {
 
-Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo)
+LinkedUniform::LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize,
+                             const int blockIndex, const BlockMemberInfo &blockInfo)
     : type(type),
       precision(precision),
       name(name),
@@ -37,45 +38,45 @@
     }
 }
 
-Uniform::~Uniform()
+LinkedUniform::~LinkedUniform()
 {
     delete[] data;
 }
 
-bool Uniform::isArray() const
+bool LinkedUniform::isArray() const
 {
     return arraySize > 0;
 }
 
-unsigned int Uniform::elementCount() const
+unsigned int LinkedUniform::elementCount() const
 {
     return arraySize > 0 ? arraySize : 1;
 }
 
-bool Uniform::isReferencedByVertexShader() const
+bool LinkedUniform::isReferencedByVertexShader() const
 {
     return vsRegisterIndex != GL_INVALID_INDEX;
 }
 
-bool Uniform::isReferencedByFragmentShader() const
+bool LinkedUniform::isReferencedByFragmentShader() const
 {
     return psRegisterIndex != GL_INVALID_INDEX;
 }
 
-bool Uniform::isInDefaultBlock() const
+bool LinkedUniform::isInDefaultBlock() const
 {
     return blockIndex == -1;
 }
 
-size_t Uniform::dataSize() const
+size_t LinkedUniform::dataSize() const
 {
     ASSERT(type != GL_STRUCT_ANGLEX);
     return UniformInternalSize(type) * elementCount();
 }
 
-bool Uniform::isSampler() const
+bool LinkedUniform::isSampler() const
 {
-    return gl::IsSampler(type);
+    return IsSampler(type);
 }
 
 UniformBlock::UniformBlock(const std::string &name, unsigned int elementIndex, unsigned int dataSize)
diff --git a/src/libGLESv2/Uniform.h b/src/libGLESv2/Uniform.h
index 0f70e63..9e35157 100644
--- a/src/libGLESv2/Uniform.h
+++ b/src/libGLESv2/Uniform.h
@@ -16,17 +16,17 @@
 
 #include "common/debug.h"
 #include "angletypes.h"
-#include "compiler/translator/ShaderVariable.h"
+#include "common/shadervars.h"
 
 namespace gl
 {
 
 // Helper struct representing a single shader uniform
-struct Uniform
+struct LinkedUniform
 {
-    Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const sh::BlockMemberInfo &blockInfo);
+    LinkedUniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, const int blockIndex, const BlockMemberInfo &blockInfo);
 
-    ~Uniform();
+    ~LinkedUniform();
 
     bool isArray() const;
     unsigned int elementCount() const;
@@ -41,7 +41,7 @@
     const std::string name;
     const unsigned int arraySize;
     const int blockIndex;
-    const sh::BlockMemberInfo blockInfo;
+    const BlockMemberInfo blockInfo;
 
     unsigned char *data;
     bool dirty;
@@ -55,8 +55,6 @@
     unsigned int registerElement;
 };
 
-typedef std::vector<Uniform*> UniformArray;
-
 // Helper struct representing a single shader uniform block
 struct UniformBlock
 {
@@ -77,8 +75,6 @@
     unsigned int vsRegisterIndex;
 };
 
-typedef std::vector<UniformBlock*> UniformBlockArray;
-
 }
 
 #endif   // LIBGLESV2_UNIFORM_H_
diff --git a/src/libGLESv2/renderer/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
index 3c75c2a..3b4d0f5 100644
--- a/src/libGLESv2/renderer/d3d11/Renderer11.cpp
+++ b/src/libGLESv2/renderer/d3d11/Renderer11.cpp
@@ -1574,7 +1574,7 @@
 
 void Renderer11::applyUniforms(const gl::ProgramBinary &programBinary)
 {
-    const gl::UniformArray &uniformArray = programBinary.getUniforms();
+    const std::vector<gl::LinkedUniform*> &uniformArray = programBinary.getUniforms();
 
     unsigned int totalRegisterCountVS = 0;
     unsigned int totalRegisterCountPS = 0;
@@ -1584,7 +1584,7 @@
 
     for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
     {
-        const gl::Uniform &uniform = *uniformArray[uniformIndex];
+        const gl::LinkedUniform &uniform = *uniformArray[uniformIndex];
 
         if (uniform.isReferencedByVertexShader() && !uniform.isSampler())
         {
@@ -1628,7 +1628,7 @@
 
     for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
     {
-        gl::Uniform *uniform = uniformArray[uniformIndex];
+        gl::LinkedUniform *uniform = uniformArray[uniformIndex];
 
         if (!uniform->isSampler())
         {
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
index d53546f..c5ad862 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.cpp
@@ -1768,11 +1768,11 @@
 
 void Renderer9::applyUniforms(const gl::ProgramBinary &programBinary)
 {
-    const gl::UniformArray &uniformArray = programBinary.getUniforms();
+    const std::vector<gl::LinkedUniform*> &uniformArray = programBinary.getUniforms();
 
     for (size_t uniformIndex = 0; uniformIndex < uniformArray.size(); uniformIndex++)
     {
-        gl::Uniform *targetUniform = uniformArray[uniformIndex];
+        gl::LinkedUniform *targetUniform = uniformArray[uniformIndex];
 
         if (targetUniform->dirty)
         {
@@ -1820,7 +1820,7 @@
     }
 }
 
-void Renderer9::applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v)
+void Renderer9::applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v)
 {
     if (targetUniform->isReferencedByFragmentShader())
     {
@@ -1833,7 +1833,7 @@
     }
 }
 
-void Renderer9::applyUniformniv(gl::Uniform *targetUniform, const GLint *v)
+void Renderer9::applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v)
 {
     ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
     GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
@@ -1849,7 +1849,7 @@
     applyUniformnfv(targetUniform, (GLfloat*)vector);
 }
 
-void Renderer9::applyUniformnbv(gl::Uniform *targetUniform, const GLint *v)
+void Renderer9::applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v)
 {
     ASSERT(targetUniform->registerCount <= MAX_VERTEX_CONSTANT_VECTORS_D3D9);
     GLfloat vector[MAX_VERTEX_CONSTANT_VECTORS_D3D9][4];
diff --git a/src/libGLESv2/renderer/d3d9/Renderer9.h b/src/libGLESv2/renderer/d3d9/Renderer9.h
index 2576499..571e6c0 100644
--- a/src/libGLESv2/renderer/d3d9/Renderer9.h
+++ b/src/libGLESv2/renderer/d3d9/Renderer9.h
@@ -241,9 +241,9 @@
 
     void deinitialize();
 
-    void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v);
-    void applyUniformniv(gl::Uniform *targetUniform, const GLint *v);
-    void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v);
+    void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v);
+    void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v);
+    void applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v);
 
     void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
     void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);