Updated gl::IsInternalTextureTarget to have a client version parameter.

TRAC #23470

Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
Author: Geoff Lang
diff --git a/src/common/utilities.cpp b/src/common/utilities.cpp
index 1c91c78..f0aea9d 100644
--- a/src/common/utilities.cpp
+++ b/src/common/utilities.cpp
@@ -459,9 +459,22 @@
     return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
 }
 
-bool IsInternalTextureTarget(GLenum target)
+bool IsInternalTextureTarget(GLenum target, GLuint clientVersion)
 {
-    return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
+    if (clientVersion == 2)
+    {
+        return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
+    }
+    else if (clientVersion == 3)
+    {
+        return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target) ||
+               target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY;
+    }
+    else
+    {
+        UNREACHABLE();
+        return false;
+    }
 }
 
 bool IsTriangleMode(GLenum drawMode)
diff --git a/src/common/utilities.h b/src/common/utilities.h
index 41e1936..5e1b6a5 100644
--- a/src/common/utilities.h
+++ b/src/common/utilities.h
@@ -40,7 +40,7 @@
 int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
 
 bool IsCubemapTextureTarget(GLenum target);
-bool IsInternalTextureTarget(GLenum target);
+bool IsInternalTextureTarget(GLenum target, GLuint clientVersion);
 
 bool IsTriangleMode(GLenum drawMode);
 
diff --git a/src/libGLESv2/Framebuffer.cpp b/src/libGLESv2/Framebuffer.cpp
index 39d0285..86c6269 100644
--- a/src/libGLESv2/Framebuffer.cpp
+++ b/src/libGLESv2/Framebuffer.cpp
@@ -177,18 +177,18 @@
     for (unsigned int colorAttachment = 0; colorAttachment < IMPLEMENTATION_MAX_DRAW_BUFFERS; colorAttachment++)
     {
         if (mColorbuffers[colorAttachment].id() == texture &&
-            IsInternalTextureTarget(mColorbuffers[colorAttachment].type()))
+            IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer->getCurrentClientVersion()))
         {
             mColorbuffers[colorAttachment].set(NULL, GL_NONE, 0, 0);
         }
     }
 
-    if (mDepthbuffer.id() == texture && IsInternalTextureTarget(mDepthbuffer.type()))
+    if (mDepthbuffer.id() == texture && IsInternalTextureTarget(mDepthbuffer.type(), mRenderer->getCurrentClientVersion()))
     {
         mDepthbuffer.set(NULL, GL_NONE, 0, 0);
     }
 
-    if (mStencilbuffer.id() == texture && IsInternalTextureTarget(mStencilbuffer.type()))
+    if (mStencilbuffer.id() == texture && IsInternalTextureTarget(mStencilbuffer.type(), mRenderer->getCurrentClientVersion()))
     {
         mStencilbuffer.set(NULL, GL_NONE, 0, 0);
     }
@@ -478,7 +478,7 @@
                     return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
                 }
             }
-            else if (IsInternalTextureTarget(mColorbuffers[colorAttachment].type()))
+            else if (IsInternalTextureTarget(mColorbuffers[colorAttachment].type(), mRenderer->getCurrentClientVersion()))
             {
                 GLint internalformat = colorbuffer->getInternalFormat();
 
@@ -568,7 +568,7 @@
                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
             }
         }
-        else if (IsInternalTextureTarget(mDepthbuffer.type()))
+        else if (IsInternalTextureTarget(mDepthbuffer.type(), mRenderer->getCurrentClientVersion()))
         {
             GLint internalformat = depthbuffer->getInternalFormat();
 
@@ -627,7 +627,7 @@
                 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
             }
         }
-        else if (IsInternalTextureTarget(mStencilbuffer.type()))
+        else if (IsInternalTextureTarget(mStencilbuffer.type(), mRenderer->getCurrentClientVersion()))
         {
             GLint internalformat = stencilbuffer->getInternalFormat();
 
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 86ff931..458bf5b 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -800,7 +800,7 @@
                                        GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height,
                                        GLint border)
 {
-    if (!gl::IsInternalTextureTarget(target))
+    if (!gl::IsInternalTextureTarget(target, context->getClientVersion()))
     {
         return gl::error(GL_INVALID_ENUM, false);
     }
@@ -5290,7 +5290,7 @@
             {
                 attachmentObjectType = attachmentType;
             }
-            else if (gl::IsInternalTextureTarget(attachmentType))
+            else if (gl::IsInternalTextureTarget(attachmentType, context->getClientVersion()))
             {
                 attachmentObjectType = GL_TEXTURE;
             }