Validate uniform sampler values.

Generate GL_INVALID_VALUE when setting a sampler uniform with a value
outside the range [0, GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS).
Add a test for the new behavior.
Remove TextureLimitsTest.DrawWithTexturePastMaximum, which is made
obsolete by the new test.

BUG=angleproject:1711

Change-Id: I9a4ea13b8cb47742816476689bd3932ce267fd0a
Reviewed-on: https://chromium-review.googlesource.com/430196
Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES.cpp b/src/libANGLE/validationES.cpp
index 505b903..2297f6f 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -1417,7 +1417,7 @@
     return true;
 }
 
-bool ValidateUniform1ivValue(gl::Context *context,
+bool ValidateUniform1ivValue(ValidationContext *context,
                              GLenum uniformType,
                              GLsizei count,
                              const GLint *value)
@@ -1432,7 +1432,16 @@
 
     if (IsSamplerType(uniformType))
     {
-        // TODO(fjhenigman): check values against GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
+        // Check that the values are in range.
+        const GLint max = context->getCaps().maxCombinedTextureImageUnits;
+        for (GLsizei i = 0; i < count; ++i)
+        {
+            if (value[i] < 0 || value[i] >= max)
+            {
+                context->handleError(Error(GL_INVALID_VALUE, "sampler uniform value out of range"));
+                return false;
+            }
+        }
         return true;
     }