Commit 7936a6d3 by Jamie Madill

Move the texture index to attachment base.

This will let us squash the attachment types in a follow-up patch. BUG=angleproject:963 Change-Id: I1efb2e41aa08766189499995b3150aec6fd61c4e Reviewed-on: https://chromium-review.googlesource.com/263486Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent f30a9ba9
......@@ -22,8 +22,11 @@ namespace gl
////// FramebufferAttachment Implementation //////
FramebufferAttachment::FramebufferAttachment(GLenum binding, RefCountObject *resource)
: mBinding(binding)
FramebufferAttachment::FramebufferAttachment(GLenum binding,
const ImageIndex &textureIndex,
RefCountObject *resource)
: mBinding(binding),
mTextureIndex(textureIndex)
{
mResource.set(resource);
}
......@@ -78,61 +81,68 @@ GLuint FramebufferAttachment::id() const
return mResource->id();
}
///// TextureAttachment Implementation ////////
TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
: FramebufferAttachment(binding, texture),
mIndex(index)
const ImageIndex *FramebufferAttachment::getTextureImageIndex() const
{
ASSERT(type() == GL_TEXTURE);
return &mTextureIndex;
}
TextureAttachment::~TextureAttachment()
GLenum FramebufferAttachment::cubeMapFace() const
{
ASSERT(type() == GL_TEXTURE);
return IsCubeMapTextureTarget(mTextureIndex.type) ? mTextureIndex.type : GL_NONE;
}
GLsizei TextureAttachment::getSamples() const
GLint FramebufferAttachment::mipLevel() const
{
return 0;
ASSERT(type() == GL_TEXTURE);
return mTextureIndex.mipIndex;
}
GLsizei TextureAttachment::getWidth() const
GLint FramebufferAttachment::layer() const
{
return getTexture()->getWidth(mIndex.type, mIndex.mipIndex);
ASSERT(type() == GL_TEXTURE);
if (mTextureIndex.type == GL_TEXTURE_2D_ARRAY || mTextureIndex.type == GL_TEXTURE_3D)
{
return mTextureIndex.layerIndex;
}
return 0;
}
GLsizei TextureAttachment::getHeight() const
///// TextureAttachment Implementation ////////
TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index)
: FramebufferAttachment(binding, index, texture)
{
return getTexture()->getHeight(mIndex.type, mIndex.mipIndex);
}
GLenum TextureAttachment::getInternalFormat() const
TextureAttachment::~TextureAttachment()
{
return getTexture()->getInternalFormat(mIndex.type, mIndex.mipIndex);
}
GLenum TextureAttachment::type() const
GLsizei TextureAttachment::getSamples() const
{
return GL_TEXTURE;
return 0;
}
GLint TextureAttachment::mipLevel() const
GLsizei TextureAttachment::getWidth() const
{
return mIndex.mipIndex;
return getTexture()->getWidth(mTextureIndex.type, mTextureIndex.mipIndex);
}
GLenum TextureAttachment::cubeMapFace() const
GLsizei TextureAttachment::getHeight() const
{
return IsCubeMapTextureTarget(mIndex.type) ? mIndex.type : GL_NONE;
return getTexture()->getHeight(mTextureIndex.type, mTextureIndex.mipIndex);
}
GLint TextureAttachment::layer() const
GLenum TextureAttachment::getInternalFormat() const
{
return mIndex.layerIndex;
return getTexture()->getInternalFormat(mTextureIndex.type, mTextureIndex.mipIndex);
}
const ImageIndex *TextureAttachment::getTextureImageIndex() const
GLenum TextureAttachment::type() const
{
return &mIndex;
return GL_TEXTURE;
}
Renderbuffer *TextureAttachment::getRenderbuffer() const
......@@ -144,7 +154,7 @@ Renderbuffer *TextureAttachment::getRenderbuffer() const
////// RenderbufferAttachment Implementation //////
RenderbufferAttachment::RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer)
: FramebufferAttachment(binding, renderbuffer)
: FramebufferAttachment(binding, ImageIndex::MakeInvalid(), renderbuffer)
{
ASSERT(renderbuffer);
}
......@@ -178,35 +188,14 @@ GLenum RenderbufferAttachment::type() const
return GL_RENDERBUFFER;
}
GLint RenderbufferAttachment::mipLevel() const
{
return 0;
}
GLenum RenderbufferAttachment::cubeMapFace() const
{
return GL_NONE;
}
GLint RenderbufferAttachment::layer() const
{
return 0;
}
Texture *RenderbufferAttachment::getTexture() const
{
UNREACHABLE();
return nullptr;
}
const ImageIndex *RenderbufferAttachment::getTextureImageIndex() const
{
UNREACHABLE();
return nullptr;
}
DefaultAttachment::DefaultAttachment(GLenum binding, egl::Surface *surface)
: FramebufferAttachment(binding, surface)
: FramebufferAttachment(binding, ImageIndex::MakeInvalid(), surface)
{
}
......@@ -241,33 +230,12 @@ GLenum DefaultAttachment::type() const
return GL_FRAMEBUFFER_DEFAULT;
}
GLint DefaultAttachment::mipLevel() const
{
return 0;
}
GLenum DefaultAttachment::cubeMapFace() const
{
return GL_NONE;
}
GLint DefaultAttachment::layer() const
{
return 0;
}
Texture *DefaultAttachment::getTexture() const
{
UNREACHABLE();
return nullptr;
}
const ImageIndex *DefaultAttachment::getTextureImageIndex() const
{
UNREACHABLE();
return nullptr;
}
Renderbuffer *DefaultAttachment::getRenderbuffer() const
{
UNREACHABLE();
......
......@@ -29,7 +29,9 @@ class Renderbuffer;
class FramebufferAttachment : angle::NonCopyable
{
public:
explicit FramebufferAttachment(GLenum binding, RefCountObject *resource);
FramebufferAttachment(GLenum binding,
const ImageIndex &textureIndex,
RefCountObject *resource);
virtual ~FramebufferAttachment();
// Helper methods
......@@ -49,6 +51,12 @@ class FramebufferAttachment : angle::NonCopyable
GLuint id() const;
// These methods are only legal to call on Texture attachments
const ImageIndex *getTextureImageIndex() const;
GLenum cubeMapFace() const;
GLint mipLevel() const;
GLint layer() const;
// Child class interface
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
......@@ -56,16 +64,13 @@ class FramebufferAttachment : angle::NonCopyable
virtual GLsizei getSamples() const = 0;
virtual GLenum type() const = 0;
virtual GLint mipLevel() const = 0;
virtual GLenum cubeMapFace() const = 0;
virtual GLint layer() const = 0;
virtual Texture *getTexture() const = 0;
virtual const ImageIndex *getTextureImageIndex() const = 0;
virtual Renderbuffer *getRenderbuffer() const = 0;
protected:
GLenum mBinding;
ImageIndex mTextureIndex;
BindingPointer<RefCountObject> mResource;
};
......@@ -82,20 +87,13 @@ class TextureAttachment : public FramebufferAttachment
virtual GLenum getInternalFormat() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLenum cubeMapFace() const;
virtual GLint layer() const;
virtual const ImageIndex *getTextureImageIndex() const;
virtual Renderbuffer *getRenderbuffer() const;
Texture *getTexture() const override
{
return rx::GetAs<Texture>(mResource.get());
}
private:
ImageIndex mIndex;
};
class RenderbufferAttachment : public FramebufferAttachment
......@@ -111,12 +109,8 @@ class RenderbufferAttachment : public FramebufferAttachment
virtual GLsizei getSamples() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLenum cubeMapFace() const;
virtual GLint layer() const;
virtual Texture *getTexture() const;
virtual const ImageIndex *getTextureImageIndex() const;
Renderbuffer *getRenderbuffer() const override
{
......@@ -137,12 +131,8 @@ class DefaultAttachment : public FramebufferAttachment
virtual GLsizei getSamples() const;
virtual GLenum type() const;
virtual GLint mipLevel() const;
virtual GLenum cubeMapFace() const;
virtual GLint layer() const;
virtual Texture *getTexture() const;
virtual const ImageIndex *getTextureImageIndex() const;
virtual Renderbuffer *getRenderbuffer() const;
const egl::Surface *getSurface() const
......
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