Implement GetMultismaplefvANGLE and SampleMaskiANGLE of texture multisample extension

This patch adds GetMultismaplefvANGLE and SampleMaskiANGLE api.

TEST=TextureMultisampleTest.CheckSamplePositions*
TEST=NegativeTextureMultisampleTest.Negtive*

BUG=angleproject:2275

Change-Id: Ib1e8b856059229bbe88328a28cf2a892f4673214
Reviewed-on: https://chromium-review.googlesource.com/c/1319252
Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/TextureMultisampleTest.cpp b/src/tests/gl_tests/TextureMultisampleTest.cpp
index 78ecfb4..b008e9c 100644
--- a/src/tests/gl_tests/TextureMultisampleTest.cpp
+++ b/src/tests/gl_tests/TextureMultisampleTest.cpp
@@ -72,6 +72,9 @@
     void getTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params);
     void getTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params);
 
+    void getMultisamplefv(GLenum pname, GLuint index, GLfloat *val);
+    void sampleMaski(GLuint maskNumber, GLbitfield mask);
+
     GLuint mFramebuffer = 0;
     GLuint mTexture     = 0;
 
@@ -229,6 +232,7 @@
         glGetTexLevelParameterfv(target, level, pname, params);
     }
 }
+
 void TextureMultisampleTest::getTexLevelParameteriv(GLenum target,
                                                     GLint level,
                                                     GLenum pname,
@@ -245,6 +249,32 @@
     }
 }
 
+void TextureMultisampleTest::getMultisamplefv(GLenum pname, GLuint index, GLfloat *val)
+{
+    if (getClientMajorVersion() <= 3 && getClientMinorVersion() < 1 &&
+        ensureExtensionEnabled("GL_ANGLE_texture_multisample"))
+    {
+        glGetMultisamplefvANGLE(pname, index, val);
+    }
+    else
+    {
+        glGetMultisamplefv(pname, index, val);
+    }
+}
+
+void TextureMultisampleTest::sampleMaski(GLuint maskNumber, GLbitfield mask)
+{
+    if (getClientMajorVersion() <= 3 && getClientMinorVersion() < 1 &&
+        ensureExtensionEnabled("GL_ANGLE_texture_multisample"))
+    {
+        glSampleMaskiANGLE(maskNumber, mask);
+    }
+    else
+    {
+        glSampleMaski(maskNumber, mask);
+    }
+}
+
 // Tests that if es version < 3.1, GL_TEXTURE_2D_MULTISAMPLE is not supported in
 // GetInternalformativ. Checks that the number of samples returned is valid in case of ES >= 3.1.
 TEST_P(TextureMultisampleTest, MultisampleTargetGetInternalFormativBase)
@@ -380,7 +410,7 @@
 // The value of sample position should be equal to standard pattern on D3D.
 TEST_P(TextureMultisampleTest, CheckSamplePositions)
 {
-    ANGLE_SKIP_TEST_IF(!IsD3D11() || (getClientMajorVersion() <= 3 && getClientMinorVersion() < 1));
+    ANGLE_SKIP_TEST_IF(!IsD3D11());
 
     GLsizei maxSamples = 0;
     glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
@@ -394,7 +424,7 @@
         GLTexture texture;
         size_t indexKey = static_cast<size_t>(ceil(log2(sampleCount)));
         glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, texture);
-        glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA8, 1, 1, GL_TRUE);
+        texStorageMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA8, 1, 1, GL_TRUE);
         glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE,
                                texture, 0);
         EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
@@ -402,7 +432,7 @@
 
         for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
         {
-            glGetMultisamplefv(GL_SAMPLE_POSITION, sampleIndex, samplePosition);
+            getMultisamplefv(GL_SAMPLE_POSITION, sampleIndex, samplePosition);
             EXPECT_EQ(samplePosition[0], kSamplePositions[indexKey][2 * sampleIndex]);
             EXPECT_EQ(samplePosition[1], kSamplePositions[indexKey][2 * sampleIndex + 1]);
         }
@@ -461,6 +491,20 @@
     }
 }
 
+TEST_P(TextureMultisampleTest, SampleMaski)
+{
+    ANGLE_SKIP_TEST_IF(lessThanES31MultisampleExtNotSupported());
+
+    GLint maxSampleMaskWords = 0;
+    glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &maxSampleMaskWords);
+    sampleMaski(maxSampleMaskWords - 1, 0x1);
+    ASSERT_GL_NO_ERROR();
+
+    glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &maxSampleMaskWords);
+    sampleMaski(maxSampleMaskWords, 0x1);
+    ASSERT_GL_ERROR(GL_INVALID_VALUE);
+}
+
 // Negative tests of multisample texture. When context less than ES 3.1 and ANGLE_texture_multsample
 // not enabled, the feature isn't supported.
 TEST_P(NegativeTextureMultisampleTest, Negtive)
@@ -501,6 +545,12 @@
     getTexLevelParameteriv(GL_TEXTURE_2D_MULTISAMPLE, 0, GL_TEXTURE_FIXED_SAMPLE_LOCATIONS,
                            &fixedSampleLocation);
     ASSERT_GL_ERROR(GL_INVALID_OPERATION);
+
+    GLint maxSampleMaskWords = 0;
+    glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &maxSampleMaskWords);
+    ASSERT_GL_ERROR(GL_INVALID_ENUM);
+    sampleMaski(maxSampleMaskWords - 1, 0x1);
+    ASSERT_GL_ERROR(GL_INVALID_OPERATION);
 }
 
 // Tests that GL_TEXTURE_2D_MULTISAMPLE_ARRAY is not supported in GetInternalformativ when the