Unifying the various texture interfaces where possible

BUG=angle:688
Change-Id: I43be738e0a42f7a7e1448e1d9300b30d4bc54125
Reviewed-on: https://chromium-review.googlesource.com/209343
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Brandon Jones <bajones@chromium.org>
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 53ebf09..fe39829 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -44,6 +44,7 @@
 void Texture::setUsage(GLenum usage)
 {
     mUsage = usage;
+    getImplementation()->setUsage(usage);
 }
 
 void Texture::getSamplerStateWithNativeOffset(SamplerState *sampler)
@@ -99,6 +100,11 @@
     return getImplementation()->getNativeTexture();
 }
 
+void Texture::generateMipmaps()
+{
+    getImplementation()->generateMipmaps();
+}
+
 void Texture::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
 {
     getImplementation()->copySubImage(target, level, xoffset, yoffset, zoffset, x, y, width, height, source);
@@ -125,6 +131,11 @@
     return log2(std::max(std::max(getBaseLevelWidth(), getBaseLevelHeight()), getBaseLevelDepth())) + 1;
 }
 
+const rx::Image *Texture::getBaseLevelImage() const
+{
+    return (getImplementation()->getLayerCount(0) > 0 ? getImplementation()->getImage(0, 0) : NULL);
+}
+
 Texture2D::Texture2D(rx::Texture2DImpl *impl, GLuint id)
     : Texture(id, GL_TEXTURE_2D),
       mTexture(impl)
@@ -143,16 +154,10 @@
     }
 }
 
-void Texture2D::setUsage(GLenum usage)
-{
-    mUsage = usage;
-    mTexture->setUsage(usage);
-}
-
 GLsizei Texture2D::getWidth(GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(level)->getWidth();
+        return mTexture->getImage(level, 0)->getWidth();
     else
         return 0;
 }
@@ -160,7 +165,7 @@
 GLsizei Texture2D::getHeight(GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(level)->getHeight();
+        return mTexture->getImage(level, 0)->getHeight();
     else
         return 0;
 }
@@ -168,7 +173,7 @@
 GLenum Texture2D::getInternalFormat(GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(level)->getInternalFormat();
+        return mTexture->getImage(level, 0)->getInternalFormat();
     else
         return GL_NONE;
 }
@@ -176,25 +181,16 @@
 GLenum Texture2D::getActualFormat(GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(level)->getActualFormat();
+        return mTexture->getImage(level, 0)->getActualFormat();
     else
         return GL_NONE;
 }
 
-void Texture2D::redefineImage(GLint level, GLenum internalformat, GLsizei width, GLsizei height)
+void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
     releaseTexImage();
 
-    mTexture->redefineImage(level, internalformat, width, height);
-}
-
-void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
-{
-    GLenum sizedInternalFormat = IsSizedInternalFormat(internalFormat) ? internalFormat
-                                                                       : GetSizedInternalFormat(format, type);
-    redefineImage(level, sizedInternalFormat, width, height);
-
-    mTexture->setImage(level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_2D, level, width, height, 1, internalFormat, format, type, unpack, pixels);
 }
 
 void Texture2D::bindTexImage(egl::Surface *surface)
@@ -220,36 +216,33 @@
 
 void Texture2D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
 {
-    // compressed formats don't have separate sized internal formats-- we can just use the compressed format directly
-    redefineImage(level, format, width, height);
+    releaseTexImage();
 
-    mTexture->setCompressedImage(level, format, width, height, imageSize, pixels);
+    mTexture->setCompressedImage(GL_TEXTURE_2D, level, format, width, height, 1, imageSize, pixels);
 }
 
 void Texture2D::subImage(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->subImage(level, xoffset, yoffset, width, height, format, type, unpack, pixels);
+    mTexture->subImage(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
 }
 
 void Texture2D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
 {
-    mTexture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, pixels);
+    mTexture->subImageCompressed(GL_TEXTURE_2D, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
 }
 
 void Texture2D::copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
 {
-    GLenum sizedInternalFormat = IsSizedInternalFormat(format) ? format
-                                                               : GetSizedInternalFormat(format, GL_UNSIGNED_BYTE);
-    redefineImage(level, sizedInternalFormat, width, height);
+    releaseTexImage();
 
-    mTexture->copyImage(level, format, x, y, width, height, source);
+    mTexture->copyImage(GL_TEXTURE_2D, level, format, x, y, width, height, source);
 }
 
 void Texture2D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height)
 {
     mImmutable = true;
 
-    mTexture->storage(levels, internalformat, width, height);
+    mTexture->storage(GL_TEXTURE_2D, levels, internalformat, width, height, 1);
 }
 
 bool Texture2D::isCompressed(GLint level) const
@@ -264,36 +257,24 @@
 
 void Texture2D::generateMipmaps()
 {
-    // Purge array levels 1 through q and reset them to represent the generated mipmap levels.
-    int levelCount = mipLevels();
-    for (int level = 1; level < levelCount; level++)
-    {
-        redefineImage(level, getBaseLevelInternalFormat(),
-                      std::max(getBaseLevelWidth() >> level, 1),
-                      std::max(getBaseLevelHeight() >> level, 1));
-    }
+    releaseTexImage();
 
     mTexture->generateMipmaps();
 }
 
-const rx::Image *Texture2D::getBaseLevelImage() const
-{
-    return mTexture->getImage(0);
-}
-
 unsigned int Texture2D::getRenderTargetSerial(GLint level)
 {
-    return mTexture->getRenderTargetSerial(level);
+    return mTexture->getRenderTargetSerial(level, 0);
 }
 
 rx::RenderTarget *Texture2D::getRenderTarget(GLint level)
 {
-    return mTexture->getRenderTarget(level);
+    return mTexture->getRenderTarget(level, 0);
 }
 
-rx::RenderTarget *Texture2D::getDepthSencil(GLint level)
+rx::RenderTarget *Texture2D::getDepthStencil(GLint level)
 {
-    return mTexture->getDepthSencil(level);
+    return mTexture->getDepthStencil(level, 0);
 }
 
 TextureCubeMap::TextureCubeMap(rx::TextureCubeImpl *impl, GLuint id)
@@ -307,16 +288,10 @@
     SafeDelete(mTexture);
 }
 
-void TextureCubeMap::setUsage(GLenum usage)
-{
-    mUsage = usage;
-    mTexture->setUsage(usage);
-}
-
 GLsizei TextureCubeMap::getWidth(GLenum target, GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(target, level)->getWidth();
+        return mTexture->getImage(level, targetToLayerIndex(target))->getWidth();
     else
         return 0;
 }
@@ -324,7 +299,7 @@
 GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(target, level)->getHeight();
+        return mTexture->getImage(level, targetToLayerIndex(target))->getHeight();
     else
         return 0;
 }
@@ -332,7 +307,7 @@
 GLenum TextureCubeMap::getInternalFormat(GLenum target, GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(target, level)->getInternalFormat();
+        return mTexture->getImage(level, targetToLayerIndex(target))->getInternalFormat();
     else
         return GL_NONE;
 }
@@ -340,54 +315,54 @@
 GLenum TextureCubeMap::getActualFormat(GLenum target, GLint level) const
 {
     if (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS)
-        return mTexture->getImage(target, level)->getActualFormat();
+        return mTexture->getImage(level, targetToLayerIndex(target))->getActualFormat();
     else
         return GL_NONE;
 }
 
 void TextureCubeMap::setImagePosX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(0, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setImageNegX(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(1, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, level, width, height, 1, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setImagePosY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(2, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setImageNegY(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(3, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, level, width, height, 1, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setImagePosZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(4, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, level, width, height, 4, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setImageNegZ(GLint level, GLsizei width, GLsizei height, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(5, level, width, height, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, level, width, height, 5, internalFormat, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
 {
-    mTexture->setCompressedImage(target, level, format, width, height, imageSize, pixels);
+    mTexture->setCompressedImage(target, level, format, width, height, 1, imageSize, pixels);
 }
 
 void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->subImage(target, level, xoffset, yoffset, width, height, format, type, unpack, pixels);
+    mTexture->subImage(target, level, xoffset, yoffset, 0, width, height, 1, format, type, unpack, pixels);
 }
 
 void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
 {
-    mTexture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, pixels);
+    mTexture->subImageCompressed(target, level, xoffset, yoffset, 0, width, height, 1, format, imageSize, pixels);
 }
 
 // Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
@@ -415,34 +390,44 @@
 {
     mImmutable = true;
 
-    mTexture->storage(levels, internalformat, size);
-}
-
-void TextureCubeMap::generateMipmaps()
-{
-    mTexture->generateMipmaps();
-}
-
-const rx::Image *TextureCubeMap::getBaseLevelImage() const
-{
-    // Note: if we are not cube-complete, there is no single base level image that can describe all
-    // cube faces, so this method is only well-defined for a cube-complete base level.
-    return mTexture->getImage(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0);
+    mTexture->storage(GL_TEXTURE_CUBE_MAP, levels, internalformat, size, size, 1);
 }
 
 unsigned int TextureCubeMap::getRenderTargetSerial(GLenum target, GLint level)
 {
-    return mTexture->getRenderTargetSerial(target, level);
+    return mTexture->getRenderTargetSerial(level, targetToLayerIndex(target));
+}
+
+int TextureCubeMap::targetToLayerIndex(GLenum target)
+{
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5);
+
+    return target - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+}
+
+GLenum TextureCubeMap::layerIndexToTarget(GLint layer)
+{
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_X - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 1);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 2);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 3);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_POSITIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 4);
+    META_ASSERT(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z - GL_TEXTURE_CUBE_MAP_POSITIVE_X == 5);
+
+    return GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
 }
 
 rx::RenderTarget *TextureCubeMap::getRenderTarget(GLenum target, GLint level)
 {
-    return mTexture->getRenderTarget(target, level);
+    return mTexture->getRenderTarget(level, targetToLayerIndex(target));
 }
 
 rx::RenderTarget *TextureCubeMap::getDepthStencil(GLenum target, GLint level)
 {
-    return mTexture->getDepthStencil(target, level);
+    return mTexture->getDepthStencil(level, targetToLayerIndex(target));
 }
 
 Texture3D::Texture3D(rx::Texture3DImpl *impl, GLuint id)
@@ -456,35 +441,29 @@
     SafeDelete(mTexture);
 }
 
-void Texture3D::setUsage(GLenum usage)
-{
-    mUsage = usage;
-    mTexture->setUsage(usage);
-}
-
 GLsizei Texture3D::getWidth(GLint level) const
 {
-    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level)->getWidth() : 0;
+    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getWidth() : 0;
 }
 
 GLsizei Texture3D::getHeight(GLint level) const
 {
-    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level)->getHeight() : 0;
+    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getHeight() : 0;
 }
 
 GLsizei Texture3D::getDepth(GLint level) const
 {
-    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level)->getDepth() : 0;
+    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getDepth() : 0;
 }
 
 GLenum Texture3D::getInternalFormat(GLint level) const
 {
-    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level)->getInternalFormat() : GL_NONE;
+    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getInternalFormat() : GL_NONE;
 }
 
 GLenum Texture3D::getActualFormat(GLint level) const
 {
-    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level)->getActualFormat() : GL_NONE;
+    return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS) ? mTexture->getImage(level, 0)->getActualFormat() : GL_NONE;
 }
 
 bool Texture3D::isCompressed(GLint level) const
@@ -499,39 +478,29 @@
 
 void Texture3D::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(level, width, height, depth, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_3D, level, width, height, depth, internalFormat, format, type, unpack, pixels);
 }
 
 void Texture3D::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
 {
-    mTexture->setCompressedImage(level, format, width, height, depth, imageSize, pixels);
+    mTexture->setCompressedImage(GL_TEXTURE_3D, level, format, width, height, depth, imageSize, pixels);
 }
 
 void Texture3D::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
+    mTexture->subImage(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
 }
 
 void Texture3D::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
 {
-    mTexture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
+    mTexture->subImageCompressed(GL_TEXTURE_3D, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
 }
 
 void Texture3D::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
 {
     mImmutable = true;
 
-    mTexture->storage(levels, internalformat, width, height, depth);
-}
-
-void Texture3D::generateMipmaps()
-{
-    mTexture->generateMipmaps();
-}
-
-const rx::Image *Texture3D::getBaseLevelImage() const
-{
-    return mTexture->getImage(0);
+    mTexture->storage(GL_TEXTURE_3D, levels, internalformat, width, height, depth);
 }
 
 unsigned int Texture3D::getRenderTargetSerial(GLint level, GLint layer)
@@ -561,12 +530,6 @@
     SafeDelete(mTexture);
 }
 
-void Texture2DArray::setUsage(GLenum usage)
-{
-    mUsage = usage;
-    mTexture->setUsage(usage);
-}
-
 GLsizei Texture2DArray::getWidth(GLint level) const
 {
     return (level < IMPLEMENTATION_MAX_TEXTURE_LEVELS && mTexture->getLayerCount(level) > 0) ? mTexture->getImage(level, 0)->getWidth() : 0;
@@ -604,39 +567,29 @@
 
 void Texture2DArray::setImage(GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum internalFormat, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->setImage(level, width, height, depth, internalFormat, format, type, unpack, pixels);
+    mTexture->setImage(GL_TEXTURE_2D_ARRAY, level, width, height, depth, internalFormat, format, type, unpack, pixels);
 }
 
 void Texture2DArray::setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels)
 {
-    mTexture->setCompressedImage(level, format, width, height, depth, imageSize, pixels);
+    mTexture->setCompressedImage(GL_TEXTURE_2D_ARRAY, level, format, width, height, depth, imageSize, pixels);
 }
 
 void Texture2DArray::subImage(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const PixelUnpackState &unpack, const void *pixels)
 {
-    mTexture->subImage(level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
+    mTexture->subImage(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, type, unpack, pixels);
 }
 
 void Texture2DArray::subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels)
 {
-    mTexture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
+    mTexture->subImageCompressed(GL_TEXTURE_2D_ARRAY, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, pixels);
 }
 
 void Texture2DArray::storage(GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth)
 {
     mImmutable = true;
 
-    mTexture->storage(levels, internalformat, width, height, depth);
-}
-
-void Texture2DArray::generateMipmaps()
-{
-    mTexture->generateMipmaps();
-}
-
-const rx::Image *Texture2DArray::getBaseLevelImage() const
-{
-    return (mTexture->getLayerCount(0) > 0 ? mTexture->getImage(0, 0) : NULL);
+    mTexture->storage(GL_TEXTURE_2D_ARRAY, levels, internalformat, width, height, depth);
 }
 
 unsigned int Texture2DArray::getRenderTargetSerial(GLint level, GLint layer)