ES31: Implement multisampled Textures.

Implement TexStorage2DMultisample and getMultisamplefv entry point.
Also modify sample state for Textures and Framebuffers.

BUG=angleproject:1590
TEST=angle_unittests
TEST=angle_end2end_tests
TEST=dEQP-GLES31.functional.texture.multisample.samples_*.sample_position
TEST=dEQP-GLES31.functional.texture.multisample.samples_*.use_texture_color_2d
TEST=dEQP-GLES31.functional.texture.multisample.samples_*.use_texture_depth_2d
TEST=dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_different_sample_count_tex_tex
TEST=dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_different_sample_count_tex_rbo
TEST=dEQP-GLES31.functional.texture.multisample.negative.fbo_attach_non_zero_level
TEST=dEQP-GLES31.functional.texture.multisample.negative.texture_high_sample_count
TEST=dEQP-GLES31.functional.texture.multisample.negative.texture_zero_sample_count
TEST=dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_1_texture_2d
TEST=dEQP-GLES31.functional.shaders.builtin_functions.texture_size.samples_4_texture_2d

Change-Id: I8fa7bd4e73b95745858a3e16b1b92004b4a18712
Reviewed-on: https://chromium-review.googlesource.com/414309
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/gl/FramebufferGL.cpp b/src/libANGLE/renderer/gl/FramebufferGL.cpp
index daa89bf..fcf5eb6 100644
--- a/src/libANGLE/renderer/gl/FramebufferGL.cpp
+++ b/src/libANGLE/renderer/gl/FramebufferGL.cpp
@@ -85,10 +85,12 @@
             const Texture *texture     = attachment->getTexture();
             const TextureGL *textureGL = GetImplAs<TextureGL>(texture);
 
-            if (texture->getTarget() == GL_TEXTURE_2D)
+            if (texture->getTarget() == GL_TEXTURE_2D ||
+                texture->getTarget() == GL_TEXTURE_2D_MULTISAMPLE)
             {
-                functions->framebufferTexture2D(GL_FRAMEBUFFER, attachmentPoint, GL_TEXTURE_2D,
-                                                textureGL->getTextureID(), attachment->mipLevel());
+                functions->framebufferTexture2D(GL_FRAMEBUFFER, attachmentPoint,
+                                                texture->getTarget(), textureGL->getTextureID(),
+                                                attachment->mipLevel());
             }
             else if (texture->getTarget() == GL_TEXTURE_CUBE_MAP)
             {
@@ -367,6 +369,13 @@
     return gl::NoError();
 }
 
+gl::Error FramebufferGL::getSamplePosition(size_t index, GLfloat *xy) const
+{
+    mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
+    mFunctions->getMultisamplefv(GL_SAMPLE_POSITION, static_cast<GLuint>(index), xy);
+    return gl::NoError();
+}
+
 bool FramebufferGL::checkStatus() const
 {
     mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);