Change the component type of STENCIL_INDEX8 to UNSIGNED_NORMALIZED

That way RenderbufferStorageMultisample accepts STENCIL_INDEX8 as
an internal format for a multisampled buffer (samples > 0) as it
isn't concerned by the restriction on integer component types anymore.
This is consistent with the component type returned by the NVIDIA driver.

BUG=angle:812

Change-Id: Ic03f502ffa082b1011e8127213a5c1df0617ef43
Reviewed-on: https://chromium-review.googlesource.com/227470
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/validationES.cpp b/src/libGLESv2/validationES.cpp
index 265f4b4..382653f 100644
--- a/src/libGLESv2/validationES.cpp
+++ b/src/libGLESv2/validationES.cpp
@@ -288,9 +288,8 @@
     return true;
 }
 
-bool ValidateRenderbufferStorageParameters(gl::Context *context, GLenum target, GLsizei samples,
-                                           GLenum internalformat, GLsizei width, GLsizei height,
-                                           bool angleExtension)
+bool ValidateRenderbufferStorageParametersBase(gl::Context *context, GLenum target, GLsizei samples,
+                                               GLenum internalformat, GLsizei width, GLsizei height)
 {
     switch (target)
     {
@@ -316,8 +315,7 @@
 
     // ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
     // sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
-    // only sized internal formats. The ES3 spec (section 4.4.2) does, however, state that the
-    // internal format must be sized and not an integer format if samples is greater than zero.
+    // only sized internal formats.
     const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
     if (formatInfo.pixelBytes == 0)
     {
@@ -325,47 +323,12 @@
         return false;
     }
 
-    if ((formatInfo.componentType == GL_UNSIGNED_INT || formatInfo.componentType == GL_INT) && samples > 0)
-    {
-        context->recordError(Error(GL_INVALID_OPERATION));
-        return false;
-    }
-
     if (static_cast<GLuint>(std::max(width, height)) > context->getCaps().maxRenderbufferSize)
     {
         context->recordError(Error(GL_INVALID_VALUE));
         return false;
     }
 
-    // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
-    // to MAX_SAMPLES_ANGLE (Context::getMaxSupportedSamples) while the ES3.0 spec (section 4.4.2)
-    // states that samples must be less than or equal to the maximum samples for the specified
-    // internal format.
-    if (angleExtension)
-    {
-        ASSERT(context->getExtensions().framebufferMultisample);
-        if (static_cast<GLuint>(samples) > context->getExtensions().maxSamples)
-        {
-            context->recordError(Error(GL_INVALID_VALUE));
-            return false;
-        }
-
-        // Check if this specific format supports enough samples
-        if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
-        {
-            context->recordError(Error(GL_OUT_OF_MEMORY));
-            return false;
-        }
-    }
-    else
-    {
-        if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
-        {
-            context->recordError(Error(GL_INVALID_VALUE));
-            return false;
-        }
-    }
-
     GLuint handle = context->getState().getRenderbufferId();
     if (handle == 0)
     {
@@ -376,6 +339,33 @@
     return true;
 }
 
+bool ValidateRenderbufferStorageParametersANGLE(gl::Context *context, GLenum target, GLsizei samples,
+                                                GLenum internalformat, GLsizei width, GLsizei height)
+{
+    ASSERT(context->getExtensions().framebufferMultisample);
+
+    // ANGLE_framebuffer_multisample states that the value of samples must be less than or equal
+    // to MAX_SAMPLES_ANGLE (Context::getExtensions().maxSamples) otherwise GL_INVALID_VALUE is
+    // generated.
+    if (static_cast<GLuint>(samples) > context->getExtensions().maxSamples)
+    {
+        context->recordError(Error(GL_INVALID_VALUE));
+        return false;
+    }
+
+    // ANGLE_framebuffer_multisample states GL_OUT_OF_MEMORY is generated on a failure to create
+    // the specified storage. This is different than ES 3.0 in which a sample number higher
+    // than the maximum sample number supported  by this format generates a GL_INVALID_VALUE.
+    const TextureCaps &formatCaps = context->getTextureCaps().get(internalformat);
+    if (static_cast<GLuint>(samples) > formatCaps.getMaxSamples())
+    {
+        context->recordError(Error(GL_OUT_OF_MEMORY));
+        return false;
+    }
+
+    return ValidateRenderbufferStorageParametersBase(context, target, samples, internalformat, width, height);
+}
+
 bool ValidateFramebufferRenderbufferParameters(gl::Context *context, GLenum target, GLenum attachment,
                                                GLenum renderbuffertarget, GLuint renderbuffer)
 {