Add an ImageIndex helper struct to index into tex levels.
This encapsulates the three values needed to index into the image
array. It will simplify the logic for querying texture images from
the base calss.
BUG=angle:732
Change-Id: I31c55b3f972fd4d96ab540ec8498ef4b9b2ba16b
Reviewed-on: https://chromium-review.googlesource.com/213856
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index 4f74532..f5010b3 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -114,6 +114,30 @@
return (baseImage ? baseImage->getInternalFormat() : GL_NONE);
}
+GLsizei Texture::getWidth(const ImageIndex &index) const
+{
+ rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
+ return image->getWidth();
+}
+
+GLsizei Texture::getHeight(const ImageIndex &index) const
+{
+ rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
+ return image->getHeight();
+}
+
+GLenum Texture::getInternalFormat(const ImageIndex &index) const
+{
+ rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
+ return image->getInternalFormat();
+}
+
+GLenum Texture::getActualFormat(const ImageIndex &index) const
+{
+ rx::Image *image = mTexture->getImage(index.mipIndex, index.layerIndex);
+ return image->getActualFormat();
+}
+
rx::TextureStorageInterface *Texture::getNativeTexture()
{
return getImplementation()->getNativeTexture();
diff --git a/src/libGLESv2/Texture.h b/src/libGLESv2/Texture.h
index 3008a84..d7053d3 100644
--- a/src/libGLESv2/Texture.h
+++ b/src/libGLESv2/Texture.h
@@ -38,6 +38,7 @@
{
class Framebuffer;
class FramebufferAttachment;
+struct ImageIndex;
bool IsMipmapFiltered(const gl::SamplerState &samplerState);
@@ -62,6 +63,11 @@
GLint getBaseLevelDepth() const;
GLenum getBaseLevelInternalFormat() const;
+ GLsizei getWidth(const ImageIndex &index) const;
+ GLsizei getHeight(const ImageIndex &index) const;
+ GLenum getInternalFormat(const ImageIndex &index) const;
+ GLenum getActualFormat(const ImageIndex &index) const;
+
virtual bool isSamplerComplete(const SamplerState &samplerState, const TextureCapsMap &textureCaps, const Extensions &extensions, int clientVersion) const = 0;
rx::TextureStorageInterface *getNativeTexture();
@@ -259,6 +265,54 @@
bool isLevelComplete(int level) const;
};
+struct ImageIndex
+{
+ GLenum type;
+ GLint mipIndex;
+ GLint layerIndex;
+
+ ImageIndex(const ImageIndex &other)
+ : type(other.type),
+ mipIndex(other.mipIndex),
+ layerIndex(other.layerIndex)
+ {}
+
+ ImageIndex &operator=(const ImageIndex &other)
+ {
+ type = other.type;
+ mipIndex = other.mipIndex;
+ layerIndex = other.layerIndex;
+ return *this;
+ }
+
+ static ImageIndex Make2D(GLint mipIndex)
+ {
+ return ImageIndex(GL_TEXTURE_2D, mipIndex, 0);
+ }
+
+ static ImageIndex MakeCube(GLenum target, GLint mipIndex)
+ {
+ return ImageIndex(target, mipIndex, TextureCubeMap::targetToLayerIndex(target));
+ }
+
+ static ImageIndex Make2DArray(GLint mipIndex, GLint layerIndex)
+ {
+ return ImageIndex(GL_TEXTURE_2D_ARRAY, mipIndex, layerIndex);
+ }
+
+ static ImageIndex Make3D(GLint mipIndex, GLint layerIndex = 0)
+ {
+ return ImageIndex(GL_TEXTURE_3D, mipIndex, layerIndex);
+ }
+
+ private:
+ ImageIndex(GLenum typeIn, GLint mipIndexIn, GLint layerIndexIn)
+ : type(typeIn),
+ mipIndex(mipIndexIn),
+ layerIndex(layerIndexIn)
+ {}
+};
+
}
#endif // LIBGLESV2_TEXTURE_H_