Commit 945f7329 by Jamie Madill

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/213856Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6d708263
......@@ -114,6 +114,30 @@ GLenum Texture::getBaseLevelInternalFormat() const
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();
......
......@@ -38,6 +38,7 @@ namespace gl
{
class Framebuffer;
class FramebufferAttachment;
struct ImageIndex;
bool IsMipmapFiltered(const gl::SamplerState &samplerState);
......@@ -62,6 +63,11 @@ class Texture : public RefCountObject
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 @@ class Texture2DArray : public Texture
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_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment