Add a Uniform type info table.

Currently most uniform type info is determined by switching on the
uniform type. Some values are computed from other values, which can
result in three or more switch statements plus some multiplies or
other math. This patch attempts to improve the speed by pre computing
necessary values into constant static tables.

Improves performance by about 7% in a uniform stress test.

BUG=angleproject:1390

Change-Id: I29bef259a17f6d6536171ade4950e2d712bfd39c
Reviewed-on: https://chromium-review.googlesource.com/643791
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/common/angleutils.h b/src/common/angleutils.h
index c735069..676a104 100644
--- a/src/common/angleutils.h
+++ b/src/common/angleutils.h
@@ -248,7 +248,6 @@
 #define GL_BGRA4_ANGLEX 0x6ABC
 #define GL_BGR5_A1_ANGLEX 0x6ABD
 #define GL_INT_64_ANGLEX 0x6ABE
-#define GL_STRUCT_ANGLEX 0x6ABF
 
 // Hidden enum for the NULL D3D device type.
 #define EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE 0x6AC0
diff --git a/src/common/gen_uniform_type_table.py b/src/common/gen_uniform_type_table.py
new file mode 100644
index 0000000..6f4ecfa
--- /dev/null
+++ b/src/common/gen_uniform_type_table.py
@@ -0,0 +1,249 @@
+#!/usr/bin/python
+# Copyright 2017 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.
+#
+# gen_uniform_type_table.py:
+#  Code generation for OpenGL uniform type info tables.
+
+from datetime import date
+
+import sys
+
+all_uniform_types = [
+    "GL_NONE",
+    "GL_BOOL",
+    "GL_BOOL_VEC2",
+    "GL_BOOL_VEC3",
+    "GL_BOOL_VEC4",
+    "GL_FLOAT",
+    "GL_FLOAT_MAT2",
+    "GL_FLOAT_MAT2x3",
+    "GL_FLOAT_MAT2x4",
+    "GL_FLOAT_MAT3",
+    "GL_FLOAT_MAT3x2",
+    "GL_FLOAT_MAT3x4",
+    "GL_FLOAT_MAT4",
+    "GL_FLOAT_MAT4x2",
+    "GL_FLOAT_MAT4x3",
+    "GL_FLOAT_VEC2",
+    "GL_FLOAT_VEC3",
+    "GL_FLOAT_VEC4",
+    "GL_IMAGE_2D",
+    "GL_IMAGE_2D_ARRAY",
+    "GL_IMAGE_3D",
+    "GL_IMAGE_CUBE",
+    "GL_INT",
+    "GL_INT_IMAGE_2D",
+    "GL_INT_IMAGE_2D_ARRAY",
+    "GL_INT_IMAGE_3D",
+    "GL_INT_IMAGE_CUBE",
+    "GL_INT_SAMPLER_2D",
+    "GL_INT_SAMPLER_2D_ARRAY",
+    "GL_INT_SAMPLER_2D_MULTISAMPLE",
+    "GL_INT_SAMPLER_3D",
+    "GL_INT_SAMPLER_CUBE",
+    "GL_INT_VEC2",
+    "GL_INT_VEC3",
+    "GL_INT_VEC4",
+    "GL_SAMPLER_2D",
+    "GL_SAMPLER_2D_ARRAY",
+    "GL_SAMPLER_2D_ARRAY_SHADOW",
+    "GL_SAMPLER_2D_MULTISAMPLE",
+    "GL_SAMPLER_2D_RECT_ANGLE",
+    "GL_SAMPLER_2D_SHADOW",
+    "GL_SAMPLER_3D",
+    "GL_SAMPLER_CUBE",
+    "GL_SAMPLER_CUBE_SHADOW",
+    "GL_SAMPLER_EXTERNAL_OES",
+    "GL_UNSIGNED_INT",
+    "GL_UNSIGNED_INT_ATOMIC_COUNTER",
+    "GL_UNSIGNED_INT_IMAGE_2D",
+    "GL_UNSIGNED_INT_IMAGE_2D_ARRAY",
+    "GL_UNSIGNED_INT_IMAGE_3D",
+    "GL_UNSIGNED_INT_IMAGE_CUBE",
+    "GL_UNSIGNED_INT_SAMPLER_2D",
+    "GL_UNSIGNED_INT_SAMPLER_2D_ARRAY",
+    "GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE",
+    "GL_UNSIGNED_INT_SAMPLER_3D",
+    "GL_UNSIGNED_INT_SAMPLER_CUBE",
+    "GL_UNSIGNED_INT_VEC2",
+    "GL_UNSIGNED_INT_VEC3",
+    "GL_UNSIGNED_INT_VEC4"
+]
+
+# Uniform texture types.
+texture_types = {"2D":"2D", "CUBE": "CUBE_MAP", "2D_ARRAY": "2D_ARRAY", "3D": "3D", "MULTISAMPLE": "MULTISAMPLE", "RECT": "RECTANGLE"}
+
+template_cpp = """// GENERATED FILE - DO NOT EDIT.
+// Generated by {script_name}.
+//
+// Copyright {copyright_year} 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.
+//
+// Uniform type info table:
+//   Metadata about a particular uniform format, indexed by GL type.
+
+#include <array>
+#include "common/utilities.h"
+
+using namespace angle;
+
+namespace gl
+{{
+
+namespace
+{{
+constexpr std::array<UniformTypeInfo, {total_count}> kInfoTable =
+{{{{
+{uniform_type_info_data}
+}}}};
+
+size_t GetTypeInfoIndex(GLenum uniformType)
+{{
+    switch (uniformType)
+    {{
+{uniform_type_index_cases}
+        default:
+            UNREACHABLE();
+            return 0;
+    }}
+}}
+}}  // anonymous namespace
+
+const UniformTypeInfo &GetUniformTypeInfo(GLenum uniformType)
+{{
+    ASSERT(kInfoTable[GetTypeInfoIndex(uniformType)].type == uniformType);
+    return kInfoTable[GetTypeInfoIndex(uniformType)];
+}}
+
+}}  // namespace gl
+"""
+
+type_info_data_template = """{{{type}, {component_type}, {texture_type}, {transposed_type}, {bool_type}, {rows}, {columns}, {components}, {component_size}, {internal_size}, {external_size}, {is_sampler}, {is_matrix}, {is_image} }}"""
+type_index_case_template = """case {enum_value}: return {index_value};"""
+
+def cpp_bool(value):
+    return "true" if value else "false"
+
+def get_component_type(uniform_type):
+    if uniform_type.find("GL_BOOL") == 0:
+        return "GL_BOOL"
+    elif uniform_type.find("GL_FLOAT") == 0:
+        return "GL_FLOAT"
+    elif uniform_type.find("GL_INT") == 0:
+        return "GL_INT"
+    elif uniform_type.find("GL_UNSIGNED_INT") == 0:
+        return "GL_UNSIGNED_INT"
+    elif uniform_type == "GL_NONE":
+        return "GL_NONE"
+    else:
+        return "GL_INT"
+
+def get_texture_type(uniform_type):
+    for sampler_type, tex_type in texture_types.items():
+        if sampler_type in uniform_type:
+            return "GL_TEXTURE_" + tex_type
+    return "GL_NONE"
+
+def get_transposed_type(uniform_type):
+    if "_MAT" in uniform_type:
+        if "x" in uniform_type:
+            return "GL_FLOAT_MAT" + uniform_type[-1] + "x" + uniform_type[uniform_type.find("_MAT")+4]
+        else:
+            return uniform_type
+    else:
+        return "GL_NONE"
+
+def get_bool_type(uniform_type):
+    if uniform_type == "GL_INT" or uniform_type == "GL_UNSIGNED_INT" or uniform_type == "GL_FLOAT":
+        return "GL_BOOL"
+    elif "_VEC" in uniform_type:
+        return "GL_BOOL_VEC" + uniform_type[-1]
+    else:
+        return "GL_NONE"
+
+def get_rows(uniform_type):
+    if uniform_type == "GL_NONE":
+        return "0"
+    elif "_MAT" in uniform_type:
+        return uniform_type[-1]
+    else:
+        return "1"
+
+def get_columns(uniform_type):
+    if uniform_type == "GL_NONE":
+        return "0"
+    elif "_VEC" in uniform_type:
+        return uniform_type[-1]
+    elif "_MAT" in uniform_type:
+        return uniform_type[uniform_type.find("_MAT") + 4]
+    else:
+        return "1"
+
+def get_components(uniform_type):
+    return str(int(get_rows(uniform_type)) * int(get_columns(uniform_type)))
+
+def get_component_size(uniform_type):
+    component_type = get_component_type(uniform_type)
+    if (component_type) == "GL_BOOL":
+        return "sizeof(GLint)"
+    elif (component_type) == "GL_FLOAT":
+        return "sizeof(GLfloat)"
+    elif (component_type) == "GL_INT":
+        return "sizeof(GLint)"
+    elif (component_type) == "GL_UNSIGNED_INT":
+        return "sizeof(GLuint)"
+    elif (component_type) == "GL_NONE":
+        return "0"
+    else:
+        raise "Invalid component type: " + component_type
+
+def get_internal_size(uniform_type):
+    return get_component_size(uniform_type) + " * " + str(int(get_rows(uniform_type)) * 4)
+
+def get_external_size(uniform_type):
+    return get_component_size(uniform_type) + " * " + get_components(uniform_type)
+
+def get_is_sampler(uniform_type):
+    return cpp_bool("_SAMPLER_" in uniform_type)
+
+def get_is_matrix(uniform_type):
+    return cpp_bool("_MAT" in uniform_type)
+
+def get_is_image(uniform_type):
+    return cpp_bool("_IMAGE_" in uniform_type)
+
+def gen_type_info(uniform_type):
+    return type_info_data_template.format(
+        type = uniform_type,
+        component_type = get_component_type(uniform_type),
+        texture_type = get_texture_type(uniform_type),
+        transposed_type = get_transposed_type(uniform_type),
+        bool_type = get_bool_type(uniform_type),
+        rows = get_rows(uniform_type),
+        columns = get_columns(uniform_type),
+        components = get_components(uniform_type),
+        component_size = get_component_size(uniform_type),
+        internal_size = get_internal_size(uniform_type),
+        external_size = get_external_size(uniform_type),
+        is_sampler = get_is_sampler(uniform_type),
+        is_matrix = get_is_matrix(uniform_type),
+        is_image = get_is_image(uniform_type))
+
+def gen_type_index_case(index, uniform_type):
+    return "case " + uniform_type + ": return " + str(index) + ";"
+
+uniform_type_info_data = ",\n".join([gen_type_info(uniform_type) for uniform_type in all_uniform_types])
+uniform_type_index_cases = "\n".join([gen_type_index_case(index, uniform_type) for index, uniform_type in enumerate(all_uniform_types)])
+
+with open('uniform_type_info_autogen.cpp', 'wt') as out_file:
+    output_cpp = template_cpp.format(
+        script_name = sys.argv[0],
+        copyright_year = date.today().year,
+        total_count = len(all_uniform_types),
+        uniform_type_info_data = uniform_type_info_data,
+        uniform_type_index_cases = uniform_type_index_cases)
+    out_file.write(output_cpp)
+    out_file.close()
diff --git a/src/common/uniform_type_info_autogen.cpp b/src/common/uniform_type_info_autogen.cpp
new file mode 100644
index 0000000..10e35a4
--- /dev/null
+++ b/src/common/uniform_type_info_autogen.cpp
@@ -0,0 +1,275 @@
+// GENERATED FILE - DO NOT EDIT.
+// Generated by gen_uniform_type_table.py.
+//
+// Copyright 2017 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.
+//
+// Uniform type info table:
+//   Metadata about a particular uniform format, indexed by GL type.
+
+#include <array>
+#include "common/utilities.h"
+
+using namespace angle;
+
+namespace gl
+{
+
+namespace
+{
+constexpr std::array<UniformTypeInfo, 59> kInfoTable = {
+    {{GL_NONE, GL_NONE, GL_NONE, GL_NONE, GL_NONE, 0, 0, 0, 0, 0 * 0, 0 * 0, false, false, false},
+     {GL_BOOL, GL_BOOL, GL_NONE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4,
+      sizeof(GLint) * 1, false, false, false},
+     {GL_BOOL_VEC2, GL_BOOL, GL_NONE, GL_NONE, GL_BOOL_VEC2, 1, 2, 2, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 2, false, false, false},
+     {GL_BOOL_VEC3, GL_BOOL, GL_NONE, GL_NONE, GL_BOOL_VEC3, 1, 3, 3, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 3, false, false, false},
+     {GL_BOOL_VEC4, GL_BOOL, GL_NONE, GL_NONE, GL_BOOL_VEC4, 1, 4, 4, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 4, false, false, false},
+     {GL_FLOAT, GL_FLOAT, GL_NONE, GL_NONE, GL_BOOL, 1, 1, 1, sizeof(GLfloat), sizeof(GLfloat) * 4,
+      sizeof(GLfloat) * 1, false, false, false},
+     {GL_FLOAT_MAT2, GL_FLOAT, GL_NONE, GL_FLOAT_MAT2, GL_NONE, 2, 2, 4, sizeof(GLfloat),
+      sizeof(GLfloat) * 8, sizeof(GLfloat) * 4, false, true, false},
+     {GL_FLOAT_MAT2x3, GL_FLOAT, GL_NONE, GL_FLOAT_MAT3x2, GL_NONE, 3, 2, 6, sizeof(GLfloat),
+      sizeof(GLfloat) * 12, sizeof(GLfloat) * 6, false, true, false},
+     {GL_FLOAT_MAT2x4, GL_FLOAT, GL_NONE, GL_FLOAT_MAT4x2, GL_NONE, 4, 2, 8, sizeof(GLfloat),
+      sizeof(GLfloat) * 16, sizeof(GLfloat) * 8, false, true, false},
+     {GL_FLOAT_MAT3, GL_FLOAT, GL_NONE, GL_FLOAT_MAT3, GL_NONE, 3, 3, 9, sizeof(GLfloat),
+      sizeof(GLfloat) * 12, sizeof(GLfloat) * 9, false, true, false},
+     {GL_FLOAT_MAT3x2, GL_FLOAT, GL_NONE, GL_FLOAT_MAT2x3, GL_NONE, 2, 3, 6, sizeof(GLfloat),
+      sizeof(GLfloat) * 8, sizeof(GLfloat) * 6, false, true, false},
+     {GL_FLOAT_MAT3x4, GL_FLOAT, GL_NONE, GL_FLOAT_MAT4x3, GL_NONE, 4, 3, 12, sizeof(GLfloat),
+      sizeof(GLfloat) * 16, sizeof(GLfloat) * 12, false, true, false},
+     {GL_FLOAT_MAT4, GL_FLOAT, GL_NONE, GL_FLOAT_MAT4, GL_NONE, 4, 4, 16, sizeof(GLfloat),
+      sizeof(GLfloat) * 16, sizeof(GLfloat) * 16, false, true, false},
+     {GL_FLOAT_MAT4x2, GL_FLOAT, GL_NONE, GL_FLOAT_MAT2x4, GL_NONE, 2, 4, 8, sizeof(GLfloat),
+      sizeof(GLfloat) * 8, sizeof(GLfloat) * 8, false, true, false},
+     {GL_FLOAT_MAT4x3, GL_FLOAT, GL_NONE, GL_FLOAT_MAT3x4, GL_NONE, 3, 4, 12, sizeof(GLfloat),
+      sizeof(GLfloat) * 12, sizeof(GLfloat) * 12, false, true, false},
+     {GL_FLOAT_VEC2, GL_FLOAT, GL_NONE, GL_NONE, GL_BOOL_VEC2, 1, 2, 2, sizeof(GLfloat),
+      sizeof(GLfloat) * 4, sizeof(GLfloat) * 2, false, false, false},
+     {GL_FLOAT_VEC3, GL_FLOAT, GL_NONE, GL_NONE, GL_BOOL_VEC3, 1, 3, 3, sizeof(GLfloat),
+      sizeof(GLfloat) * 4, sizeof(GLfloat) * 3, false, false, false},
+     {GL_FLOAT_VEC4, GL_FLOAT, GL_NONE, GL_NONE, GL_BOOL_VEC4, 1, 4, 4, sizeof(GLfloat),
+      sizeof(GLfloat) * 4, sizeof(GLfloat) * 4, false, false, false},
+     {GL_IMAGE_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_IMAGE_2D_ARRAY, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_IMAGE_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_IMAGE_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_INT, GL_INT, GL_NONE, GL_NONE, GL_BOOL, 1, 1, 1, sizeof(GLint), sizeof(GLint) * 4,
+      sizeof(GLint) * 1, false, false, false},
+     {GL_INT_IMAGE_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_INT_IMAGE_2D_ARRAY, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_INT_IMAGE_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_INT_IMAGE_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, false, false, true},
+     {GL_INT_SAMPLER_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_INT_SAMPLER_2D_ARRAY, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_INT_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLint), sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_INT_SAMPLER_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_INT_SAMPLER_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_INT_VEC2, GL_INT, GL_NONE, GL_NONE, GL_BOOL_VEC2, 1, 2, 2, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 2, false, false, false},
+     {GL_INT_VEC3, GL_INT, GL_NONE, GL_NONE, GL_BOOL_VEC3, 1, 3, 3, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 3, false, false, false},
+     {GL_INT_VEC4, GL_INT, GL_NONE, GL_NONE, GL_BOOL_VEC4, 1, 4, 4, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 4, false, false, false},
+     {GL_SAMPLER_2D, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_2D_ARRAY, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_2D_ARRAY_SHADOW, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_2D_MULTISAMPLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_2D_RECT_ANGLE, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_2D_SHADOW, GL_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_3D, GL_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_CUBE, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_CUBE_SHADOW, GL_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_SAMPLER_EXTERNAL_OES, GL_INT, GL_NONE, GL_NONE, GL_NONE, 1, 1, 1, sizeof(GLint),
+      sizeof(GLint) * 4, sizeof(GLint) * 1, true, false, false},
+     {GL_UNSIGNED_INT, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_BOOL, 1, 1, 1, sizeof(GLuint),
+      sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, false},
+     {GL_UNSIGNED_INT_ATOMIC_COUNTER, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, false},
+     {GL_UNSIGNED_INT_IMAGE_2D, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, true},
+     {GL_UNSIGNED_INT_IMAGE_2D_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, true},
+     {GL_UNSIGNED_INT_IMAGE_3D, GL_UNSIGNED_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, true},
+     {GL_UNSIGNED_INT_IMAGE_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, false, false, true},
+     {GL_UNSIGNED_INT_SAMPLER_2D, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
+     {GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
+     {GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_UNSIGNED_INT, GL_TEXTURE_2D, GL_NONE, GL_NONE, 1,
+      1, 1, sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
+     {GL_UNSIGNED_INT_SAMPLER_3D, GL_UNSIGNED_INT, GL_TEXTURE_3D, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
+     {GL_UNSIGNED_INT_SAMPLER_CUBE, GL_UNSIGNED_INT, GL_TEXTURE_CUBE_MAP, GL_NONE, GL_NONE, 1, 1, 1,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 1, true, false, false},
+     {GL_UNSIGNED_INT_VEC2, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_BOOL_VEC2, 1, 2, 2,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 2, false, false, false},
+     {GL_UNSIGNED_INT_VEC3, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_BOOL_VEC3, 1, 3, 3,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 3, false, false, false},
+     {GL_UNSIGNED_INT_VEC4, GL_UNSIGNED_INT, GL_NONE, GL_NONE, GL_BOOL_VEC4, 1, 4, 4,
+      sizeof(GLuint), sizeof(GLuint) * 4, sizeof(GLuint) * 4, false, false, false}}};
+
+size_t GetTypeInfoIndex(GLenum uniformType)
+{
+    switch (uniformType)
+    {
+        case GL_NONE:
+            return 0;
+        case GL_BOOL:
+            return 1;
+        case GL_BOOL_VEC2:
+            return 2;
+        case GL_BOOL_VEC3:
+            return 3;
+        case GL_BOOL_VEC4:
+            return 4;
+        case GL_FLOAT:
+            return 5;
+        case GL_FLOAT_MAT2:
+            return 6;
+        case GL_FLOAT_MAT2x3:
+            return 7;
+        case GL_FLOAT_MAT2x4:
+            return 8;
+        case GL_FLOAT_MAT3:
+            return 9;
+        case GL_FLOAT_MAT3x2:
+            return 10;
+        case GL_FLOAT_MAT3x4:
+            return 11;
+        case GL_FLOAT_MAT4:
+            return 12;
+        case GL_FLOAT_MAT4x2:
+            return 13;
+        case GL_FLOAT_MAT4x3:
+            return 14;
+        case GL_FLOAT_VEC2:
+            return 15;
+        case GL_FLOAT_VEC3:
+            return 16;
+        case GL_FLOAT_VEC4:
+            return 17;
+        case GL_IMAGE_2D:
+            return 18;
+        case GL_IMAGE_2D_ARRAY:
+            return 19;
+        case GL_IMAGE_3D:
+            return 20;
+        case GL_IMAGE_CUBE:
+            return 21;
+        case GL_INT:
+            return 22;
+        case GL_INT_IMAGE_2D:
+            return 23;
+        case GL_INT_IMAGE_2D_ARRAY:
+            return 24;
+        case GL_INT_IMAGE_3D:
+            return 25;
+        case GL_INT_IMAGE_CUBE:
+            return 26;
+        case GL_INT_SAMPLER_2D:
+            return 27;
+        case GL_INT_SAMPLER_2D_ARRAY:
+            return 28;
+        case GL_INT_SAMPLER_2D_MULTISAMPLE:
+            return 29;
+        case GL_INT_SAMPLER_3D:
+            return 30;
+        case GL_INT_SAMPLER_CUBE:
+            return 31;
+        case GL_INT_VEC2:
+            return 32;
+        case GL_INT_VEC3:
+            return 33;
+        case GL_INT_VEC4:
+            return 34;
+        case GL_SAMPLER_2D:
+            return 35;
+        case GL_SAMPLER_2D_ARRAY:
+            return 36;
+        case GL_SAMPLER_2D_ARRAY_SHADOW:
+            return 37;
+        case GL_SAMPLER_2D_MULTISAMPLE:
+            return 38;
+        case GL_SAMPLER_2D_RECT_ANGLE:
+            return 39;
+        case GL_SAMPLER_2D_SHADOW:
+            return 40;
+        case GL_SAMPLER_3D:
+            return 41;
+        case GL_SAMPLER_CUBE:
+            return 42;
+        case GL_SAMPLER_CUBE_SHADOW:
+            return 43;
+        case GL_SAMPLER_EXTERNAL_OES:
+            return 44;
+        case GL_UNSIGNED_INT:
+            return 45;
+        case GL_UNSIGNED_INT_ATOMIC_COUNTER:
+            return 46;
+        case GL_UNSIGNED_INT_IMAGE_2D:
+            return 47;
+        case GL_UNSIGNED_INT_IMAGE_2D_ARRAY:
+            return 48;
+        case GL_UNSIGNED_INT_IMAGE_3D:
+            return 49;
+        case GL_UNSIGNED_INT_IMAGE_CUBE:
+            return 50;
+        case GL_UNSIGNED_INT_SAMPLER_2D:
+            return 51;
+        case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
+            return 52;
+        case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
+            return 53;
+        case GL_UNSIGNED_INT_SAMPLER_3D:
+            return 54;
+        case GL_UNSIGNED_INT_SAMPLER_CUBE:
+            return 55;
+        case GL_UNSIGNED_INT_VEC2:
+            return 56;
+        case GL_UNSIGNED_INT_VEC3:
+            return 57;
+        case GL_UNSIGNED_INT_VEC4:
+            return 58;
+        default:
+            UNREACHABLE();
+            return 0;
+    }
+}
+}  // anonymous namespace
+
+const UniformTypeInfo &GetUniformTypeInfo(GLenum uniformType)
+{
+    ASSERT(kInfoTable[GetTypeInfoIndex(uniformType)].type == uniformType);
+    return kInfoTable[GetTypeInfoIndex(uniformType)];
+}
+
+}  // namespace gl
diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp
index 427e55e..ab1c3ba 100644
--- a/src/common/utilities.cpp
+++ b/src/common/utilities.cpp
@@ -229,7 +229,6 @@
     switch (type)
     {
       case GL_NONE:
-      case GL_STRUCT_ANGLEX:
         return 0;
       case GL_BOOL:
       case GL_FLOAT:
@@ -305,7 +304,6 @@
     switch (type)
     {
       case GL_NONE:
-      case GL_STRUCT_ANGLEX:
         return 0;
       case GL_BOOL:
       case GL_FLOAT:
diff --git a/src/common/utilities.h b/src/common/utilities.h
index 1710bb5..1f007ca 100644
--- a/src/common/utilities.h
+++ b/src/common/utilities.h
@@ -23,11 +23,9 @@
 
 int VariableComponentCount(GLenum type);
 GLenum VariableComponentType(GLenum type);
-bool IsVariableComponentTypeBool(GLenum type);
 size_t VariableComponentSize(GLenum type);
 size_t VariableInternalSize(GLenum type);
 size_t VariableExternalSize(GLenum type);
-GLenum VariableBoolVectorType(GLenum type);
 int VariableRowCount(GLenum type);
 int VariableColumnCount(GLenum type);
 bool IsSamplerType(GLenum type);
@@ -41,17 +39,7 @@
 int MatrixRegisterCount(GLenum type, bool isRowMajorMatrix);
 int MatrixComponentCount(GLenum type, bool isRowMajorMatrix);
 int VariableSortOrder(GLenum type);
-
-// Inlined for speed
-ANGLE_INLINE bool IsVariableComponentTypeBool(GLenum type)
-{
-    static_assert((GL_BOOL_VEC2 == GL_BOOL + 1) && (GL_BOOL_VEC3 == GL_BOOL + 2) &&
-                      (GL_BOOL_VEC4 == GL_BOOL + 3),
-                  "GL_BOOL and GL_BOOL_VEC2-4 are contiguous");
-    ASSERT((static_cast<uint32_t>(type - GL_BOOL) <= 3) ==
-           (VariableComponentType(type) == GL_BOOL));
-    return (static_cast<uint32_t>(type - GL_BOOL) <= 3);
-}
+GLenum VariableBoolVectorType(GLenum type);
 
 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
 
@@ -157,6 +145,57 @@
 
 unsigned int ParseAndStripArrayIndex(std::string *name);
 
+struct UniformTypeInfo final : angle::NonCopyable
+{
+    constexpr UniformTypeInfo(GLenum type,
+                              GLenum componentType,
+                              GLenum samplerTextureType,
+                              GLenum transposedMatrixType,
+                              GLenum boolVectorType,
+                              int rowCount,
+                              int columnCount,
+                              int componentCount,
+                              size_t componentSize,
+                              size_t internalSize,
+                              size_t externalSize,
+                              bool isSampler,
+                              bool isMatrixType,
+                              bool isImageType)
+        : type(type),
+          componentType(componentType),
+          samplerTextureType(samplerTextureType),
+          transposedMatrixType(transposedMatrixType),
+          boolVectorType(boolVectorType),
+          rowCount(rowCount),
+          columnCount(columnCount),
+          componentCount(componentCount),
+          componentSize(componentSize),
+          internalSize(internalSize),
+          externalSize(externalSize),
+          isSampler(isSampler),
+          isMatrixType(isMatrixType),
+          isImageType(isImageType)
+    {
+    }
+
+    GLenum type;
+    GLenum componentType;
+    GLenum samplerTextureType;
+    GLenum transposedMatrixType;
+    GLenum boolVectorType;
+    int rowCount;
+    int columnCount;
+    int componentCount;
+    size_t componentSize;
+    size_t internalSize;
+    size_t externalSize;
+    bool isSampler;
+    bool isMatrixType;
+    bool isImageType;
+};
+
+const UniformTypeInfo &GetUniformTypeInfo(GLenum uniformType);
+
 }  // namespace gl
 
 namespace egl
diff --git a/src/compiler/translator/CollectVariables.cpp b/src/compiler/translator/CollectVariables.cpp
index fed5a2e..b8a1dab 100644
--- a/src/compiler/translator/CollectVariables.cpp
+++ b/src/compiler/translator/CollectVariables.cpp
@@ -352,7 +352,7 @@
             const char kName[] = "gl_DepthRange";
             info.name          = kName;
             info.mappedName    = kName;
-            info.type          = GL_STRUCT_ANGLEX;
+            info.type          = GL_NONE;
             info.arraySize     = 0;
             info.precision     = GL_NONE;
             info.staticUse     = true;
@@ -556,8 +556,8 @@
     }
     else
     {
-        // Note: this enum value is not exposed outside ANGLE
-        variableOut->type       = GL_STRUCT_ANGLEX;
+        // Structures use a NONE type that isn't exposed outside ANGLE.
+        variableOut->type       = GL_NONE;
         variableOut->structName = structure->name().c_str();
 
         const TFieldList &fields = structure->fields();
diff --git a/src/libANGLE/MemoryProgramCache.cpp b/src/libANGLE/MemoryProgramCache.cpp
index c86c58b..8586a92 100644
--- a/src/libANGLE/MemoryProgramCache.cpp
+++ b/src/libANGLE/MemoryProgramCache.cpp
@@ -12,6 +12,7 @@
 #include <GLSLANG/ShaderVars.h>
 #include <anglebase/sha1.h>
 
+#include "common/utilities.h"
 #include "common/version.h"
 #include "libANGLE/BinaryStream.h"
 #include "libANGLE/Context.h"
@@ -206,6 +207,8 @@
         uniform.blockInfo.matrixStride     = stream.readInt<int>();
         uniform.blockInfo.isRowMajorMatrix = stream.readBool();
 
+        uniform.typeInfo = &GetUniformTypeInfo(uniform.type);
+
         state->mUniforms.push_back(uniform);
     }
 
diff --git a/src/libANGLE/Shader.cpp b/src/libANGLE/Shader.cpp
index 3e24616..e063396 100644
--- a/src/libANGLE/Shader.cpp
+++ b/src/libANGLE/Shader.cpp
@@ -61,12 +61,12 @@
     }
 
     // Special case for handling structs: we sort these to the end of the list
-    if (x.type == GL_STRUCT_ANGLEX)
+    if (x.type == GL_NONE)
     {
         return false;
     }
 
-    if (y.type == GL_STRUCT_ANGLEX)
+    if (y.type == GL_NONE)
     {
         return true;
     }
diff --git a/src/libANGLE/Uniform.cpp b/src/libANGLE/Uniform.cpp
index f98bb32..7a11db6 100644
--- a/src/libANGLE/Uniform.cpp
+++ b/src/libANGLE/Uniform.cpp
@@ -14,7 +14,7 @@
 {
 
 LinkedUniform::LinkedUniform()
-    : bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
+    : typeInfo(nullptr), bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
 {
 }
 
@@ -27,7 +27,7 @@
                              const int locationIn,
                              const int bufferIndexIn,
                              const sh::BlockMemberInfo &blockInfoIn)
-    : bufferIndex(bufferIndexIn), blockInfo(blockInfoIn)
+    : typeInfo(&GetUniformTypeInfo(typeIn)), bufferIndex(bufferIndexIn), blockInfo(blockInfoIn)
 {
     type      = typeIn;
     precision = precisionIn;
@@ -39,18 +39,25 @@
 }
 
 LinkedUniform::LinkedUniform(const sh::Uniform &uniform)
-    : sh::Uniform(uniform), bufferIndex(-1), blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
+    : sh::Uniform(uniform),
+      typeInfo(&GetUniformTypeInfo(type)),
+      bufferIndex(-1),
+      blockInfo(sh::BlockMemberInfo::getDefaultBlockInfo())
 {
 }
 
 LinkedUniform::LinkedUniform(const LinkedUniform &uniform)
-    : sh::Uniform(uniform), bufferIndex(uniform.bufferIndex), blockInfo(uniform.blockInfo)
+    : sh::Uniform(uniform),
+      typeInfo(uniform.typeInfo),
+      bufferIndex(uniform.bufferIndex),
+      blockInfo(uniform.blockInfo)
 {
 }
 
 LinkedUniform &LinkedUniform::operator=(const LinkedUniform &uniform)
 {
     sh::Uniform::operator=(uniform);
+    typeInfo             = uniform.typeInfo;
     bufferIndex          = uniform.bufferIndex;
     blockInfo            = uniform.blockInfo;
 
@@ -68,12 +75,12 @@
 
 bool LinkedUniform::isSampler() const
 {
-    return IsSamplerType(type);
+    return typeInfo->isSampler;
 }
 
 bool LinkedUniform::isImage() const
 {
-    return IsImageType(type);
+    return typeInfo->isImageType;
 }
 
 bool LinkedUniform::isAtomicCounter() const
@@ -88,12 +95,12 @@
 
 size_t LinkedUniform::getElementSize() const
 {
-    return VariableExternalSize(type);
+    return typeInfo->externalSize;
 }
 
 size_t LinkedUniform::getElementComponents() const
 {
-    return VariableComponentCount(type);
+    return typeInfo->componentCount;
 }
 
 ShaderVariableBuffer::ShaderVariableBuffer()
diff --git a/src/libANGLE/Uniform.h b/src/libANGLE/Uniform.h
index 05ad0f5..2d0e465 100644
--- a/src/libANGLE/Uniform.h
+++ b/src/libANGLE/Uniform.h
@@ -18,6 +18,7 @@
 
 namespace gl
 {
+struct UniformTypeInfo;
 
 // Helper struct representing a single shader uniform
 struct LinkedUniform : public sh::Uniform
@@ -45,6 +46,8 @@
     size_t getElementSize() const;
     size_t getElementComponents() const;
 
+    const UniformTypeInfo *typeInfo;
+
     // Identifies the containing buffer backed resource -- interface block or atomic counter buffer.
     int bufferIndex;
     sh::BlockMemberInfo blockInfo;
diff --git a/src/libGLESv2.gypi b/src/libGLESv2.gypi
index 63c47a9..621447a 100644
--- a/src/libGLESv2.gypi
+++ b/src/libGLESv2.gypi
@@ -40,6 +40,7 @@
             'common/third_party/murmurhash/MurmurHash3.h',
             'common/tls.cpp',
             'common/tls.h',
+            'common/uniform_type_info_autogen.cpp',
             'common/utilities.cpp',
             'common/utilities.h',
             'common/vector_utils.h',
diff --git a/src/tests/compiler_tests/VariablePacker_test.cpp b/src/tests/compiler_tests/VariablePacker_test.cpp
index 1244606..aaf3023 100644
--- a/src/tests/compiler_tests/VariablePacker_test.cpp
+++ b/src/tests/compiler_tests/VariablePacker_test.cpp
@@ -218,13 +218,13 @@
 
     // Test example from GLSL ES 3.0 spec chapter 11, but with structs
     std::vector<sh::ShaderVariable> vars;
-    vars.push_back(sh::ShaderVariable(GL_STRUCT_ANGLEX, 0));
+    vars.push_back(sh::ShaderVariable(GL_NONE, 0));
 
     sh::ShaderVariable &parentStruct = vars[0];
     parentStruct.fields.push_back(sh::ShaderVariable(GL_FLOAT_VEC4, 0));
     parentStruct.fields.push_back(sh::ShaderVariable(GL_FLOAT_MAT3, 0));
 
-    parentStruct.fields.push_back(sh::ShaderVariable(GL_STRUCT_ANGLEX, 0));
+    parentStruct.fields.push_back(sh::ShaderVariable(GL_NONE, 0));
     sh::ShaderVariable &innerStruct = parentStruct.fields.back();
     innerStruct.fields.push_back(sh::ShaderVariable(GL_FLOAT_MAT3, 0));
     innerStruct.fields.push_back(sh::ShaderVariable(GL_FLOAT_VEC2, 6));