ES3.1: multisample renderbuffer can support interger format.

BUG=angleproject:2315

Change-Id: I3ef289a6043745c822e1c9b0a1b363ac81292c4c
Reviewed-on: https://chromium-review.googlesource.com/878021
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index c300d17..25a6433 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -2619,13 +2619,17 @@
     }
 
     // The ES3 spec(section 4.4.2) states that the internal format must be sized and not an integer
-    // format if samples is greater than zero.
+    // format if samples is greater than zero. In ES3.1(section 9.2.5), it can support integer
+    // multisample renderbuffer, but the samples should not be greater than MAX_INTEGER_SAMPLES.
     const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat);
-    if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) &&
-        samples > 0)
+    if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT))
     {
-        context->handleError(InvalidOperation());
-        return false;
+        if ((samples > 0 && context->getClientVersion() == ES_3_0) ||
+            static_cast<GLuint>(samples) > context->getCaps().maxIntegerSamples)
+        {
+            context->handleError(InvalidOperation());
+            return false;
+        }
     }
 
     // The behavior is different than the ANGLE version, which would generate a GL_OUT_OF_MEMORY.