Add uniform1iv validation functions.

Add two new validation functions: ValidateUniform1iv() and
ValidateProgramUniform1iv().
No functional change, just hooks for additional sampler uniform validation
that will come later.
This also lets us skip the sampler test in the more generic
ValidateUniformValue() function.

BUG=angleproject:1711

Change-Id: Ia6b7b45c22c2cf4b49a55fac62410ca4c91d09f4
Reviewed-on: https://chromium-review.googlesource.com/436884
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 43fa7ef..505b903 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1417,12 +1417,34 @@
     return true;
 }
 
+bool ValidateUniform1ivValue(gl::Context *context,
+                             GLenum uniformType,
+                             GLsizei count,
+                             const GLint *value)
+{
+    // Value type is GL_INT, because we only get here from glUniform1i{v}.
+    // It is compatible with INT or BOOL.
+    // Do these cheap tests first, for a little extra speed.
+    if (GL_INT == uniformType || GL_BOOL == uniformType)
+    {
+        return true;
+    }
+
+    if (IsSamplerType(uniformType))
+    {
+        // TODO(fjhenigman): check values against GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
+        return true;
+    }
+
+    context->handleError(Error(GL_INVALID_OPERATION, "wrong type of value for uniform"));
+    return false;
+}
+
 bool ValidateUniformValue(gl::Context *context, GLenum valueType, GLenum uniformType)
 {
     // Check that the value type is compatible with uniform type.
-    // Do the cheaper tests first, for a little extra speed.
-    if (valueType == uniformType || (valueType == GL_INT && IsSamplerType(uniformType)) ||
-        VariableBoolVectorType(valueType) == uniformType)
+    // Do the cheaper test first, for a little extra speed.
+    if (valueType == uniformType || VariableBoolVectorType(valueType) == uniformType)
     {
         return true;
     }
@@ -2793,6 +2815,25 @@
            ValidateUniformValue(context, valueType, uniform->type);
 }
 
+bool ValidateProgramUniform1iv(gl::Context *context,
+                               GLuint program,
+                               GLint location,
+                               GLsizei count,
+                               const GLint *value)
+{
+    // Check for ES31 program uniform entry points
+    if (context->getClientVersion() < Version(3, 1))
+    {
+        context->handleError(Error(GL_INVALID_OPERATION));
+        return false;
+    }
+
+    const LinkedUniform *uniform = nullptr;
+    gl::Program *programObject   = GetValidProgram(context, program);
+    return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
+           ValidateUniform1ivValue(context, uniform->type, count, value);
+}
+
 bool ValidateProgramUniformMatrix(gl::Context *context,
                                   GLenum valueType,
                                   GLuint program,
@@ -2828,6 +2869,14 @@
            ValidateUniformValue(context, valueType, uniform->type);
 }
 
+bool ValidateUniform1iv(gl::Context *context, GLint location, GLsizei count, const GLint *value)
+{
+    const LinkedUniform *uniform = nullptr;
+    gl::Program *programObject   = context->getGLState().getProgram();
+    return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
+           ValidateUniform1ivValue(context, uniform->type, count, value);
+}
+
 bool ValidateUniformMatrix(gl::Context *context,
                            GLenum valueType,
                            GLint location,