Re-re-re-land "Move Uniform and UBO info to the gl::Program layer."

This data was previously stored entirely in the Impl level. Move
as much as possible to the GL level, using a read-only view in the
Impl level. Some information in D3D-specific, and should be stored
separately in the Impl.

This patch has a lot of refactoring that splits the D3D and GL info,
and moves as much validation as possible to the GL layer, where it
is shared between the back-ends.

Re-land with fix for dEQP unused uniforms. The fix involves storing
a local copy of all uniform data in the GL layer. This will also
let us validate sampler indexes during draw calls at the GL layer.

Re-re-land with a fix for multiply defined symbols on Clang.

Re-re-re-land with a fix for boolean uniforms and Uniform{1234}f.

BUG=angleproject:1123
TEST=end2end_tests,Canary WebGL (D3D11/GL), dEQP-GLES2+3.functional.uniform_api

Change-Id: Ia40820a5ce2f34ec2d27648b1dc940a8955e9999
Reviewed-on: https://chromium-review.googlesource.com/298440
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index ed642a7..b858d6f 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1096,8 +1096,11 @@
     return true;
 }
 
-static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniformType,
-                                      GLint location, GLsizei count, LinkedUniform **uniformOut)
+static bool ValidateUniformCommonBase(gl::Context *context,
+                                      GLenum targetUniformType,
+                                      GLint location,
+                                      GLsizei count,
+                                      const LinkedUniform **uniformOut)
 {
     if (count < 0)
     {
@@ -1124,16 +1127,16 @@
         return false;
     }
 
-    LinkedUniform *uniform = program->getUniformByLocation(location);
+    const LinkedUniform &uniform = program->getUniformByLocation(location);
 
     // attempting to write an array to a non-array uniform is an INVALID_OPERATION
-    if (!uniform->isArray() && count > 1)
+    if (!uniform.isArray() && count > 1)
     {
         context->recordError(Error(GL_INVALID_OPERATION));
         return false;
     }
 
-    *uniformOut = uniform;
+    *uniformOut = &uniform;
     return true;
 }
 
@@ -1146,7 +1149,7 @@
         return false;
     }
 
-    LinkedUniform *uniform = NULL;
+    const LinkedUniform *uniform = nullptr;
     if (!ValidateUniformCommonBase(context, uniformType, location, count, &uniform))
     {
         return false;
@@ -1181,7 +1184,7 @@
         return false;
     }
 
-    LinkedUniform *uniform = NULL;
+    const LinkedUniform *uniform = nullptr;
     if (!ValidateUniformCommonBase(context, matrixType, location, count, &uniform))
     {
         return false;
@@ -1477,7 +1480,7 @@
     // Uniform buffer validation
     for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++)
     {
-        const gl::UniformBlock *uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex);
+        const gl::UniformBlock &uniformBlock = program->getUniformBlockByIndex(uniformBlockIndex);
         GLuint blockBinding = program->getUniformBlockBinding(uniformBlockIndex);
         const gl::Buffer *uniformBuffer = state.getIndexedUniformBuffer(blockBinding);
 
@@ -1496,7 +1499,7 @@
             uniformBufferSize = static_cast<size_t>(uniformBuffer->getSize());
         }
 
-        if (uniformBufferSize < uniformBlock->dataSize)
+        if (uniformBufferSize < uniformBlock.dataSize)
         {
             // undefined behaviour
             context->recordError(Error(GL_INVALID_OPERATION, "It is undefined behaviour to use a uniform buffer that is too small."));
@@ -1896,8 +1899,8 @@
     ASSERT(programObject);
 
     // sized queries -- ensure the provided buffer is large enough
-    LinkedUniform *uniform = programObject->getUniformByLocation(location);
-    size_t requiredBytes = VariableExternalSize(uniform->type);
+    const LinkedUniform &uniform = programObject->getUniformByLocation(location);
+    size_t requiredBytes = VariableExternalSize(uniform.type);
     if (static_cast<size_t>(bufSize) < requiredBytes)
     {
         context->recordError(Error(GL_INVALID_OPERATION));