diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp | 286 |
1 files changed, 96 insertions, 190 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp b/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp index e56fc750ad..352a326c23 100644 --- a/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp +++ b/src/3rdparty/angle/src/libANGLE/FramebufferAttachment.cpp @@ -20,283 +20,189 @@ namespace gl { -////// FramebufferAttachment Implementation ////// +////// FramebufferAttachment::Target Implementation ////// -FramebufferAttachment::FramebufferAttachment(GLenum binding) - : mBinding(binding) +FramebufferAttachment::Target::Target() + : mBinding(GL_NONE), + mTextureIndex(ImageIndex::MakeInvalid()) { } -FramebufferAttachment::~FramebufferAttachment() +FramebufferAttachment::Target::Target(GLenum binding, const ImageIndex &imageIndex) + : mBinding(binding), + mTextureIndex(imageIndex) { } -GLuint FramebufferAttachment::getRedSize() const +FramebufferAttachment::Target::Target(const Target &other) + : mBinding(other.mBinding), + mTextureIndex(other.mTextureIndex) { - return GetInternalFormatInfo(getInternalFormat()).redBits; } -GLuint FramebufferAttachment::getGreenSize() const +FramebufferAttachment::Target &FramebufferAttachment::Target::operator=(const Target &other) { - return GetInternalFormatInfo(getInternalFormat()).greenBits; + this->mBinding = other.mBinding; + this->mTextureIndex = other.mTextureIndex; + return *this; } -GLuint FramebufferAttachment::getBlueSize() const -{ - return GetInternalFormatInfo(getInternalFormat()).blueBits; -} - -GLuint FramebufferAttachment::getAlphaSize() const -{ - return GetInternalFormatInfo(getInternalFormat()).alphaBits; -} - -GLuint FramebufferAttachment::getDepthSize() const -{ - return GetInternalFormatInfo(getInternalFormat()).depthBits; -} - -GLuint FramebufferAttachment::getStencilSize() const -{ - return GetInternalFormatInfo(getInternalFormat()).stencilBits; -} - -GLenum FramebufferAttachment::getComponentType() const -{ - return GetInternalFormatInfo(getInternalFormat()).componentType; -} - -GLenum FramebufferAttachment::getColorEncoding() const -{ - return GetInternalFormatInfo(getInternalFormat()).colorEncoding; -} - -///// TextureAttachment Implementation //////// - -TextureAttachment::TextureAttachment(GLenum binding, Texture *texture, const ImageIndex &index) - : FramebufferAttachment(binding), - mIndex(index) -{ - mTexture.set(texture); -} - -TextureAttachment::~TextureAttachment() -{ - mTexture.set(NULL); -} - -GLsizei TextureAttachment::getSamples() const -{ - return 0; -} - -GLuint TextureAttachment::id() const -{ - return mTexture->id(); -} - -GLsizei TextureAttachment::getWidth() const -{ - return mTexture->getWidth(mIndex.type, mIndex.mipIndex); -} - -GLsizei TextureAttachment::getHeight() const -{ - return mTexture->getHeight(mIndex.type, mIndex.mipIndex); -} - -GLenum TextureAttachment::getInternalFormat() const -{ - return mTexture->getInternalFormat(mIndex.type, mIndex.mipIndex); -} - -GLenum TextureAttachment::type() const -{ - return GL_TEXTURE; -} - -GLint TextureAttachment::mipLevel() const -{ - return mIndex.mipIndex; -} - -GLenum TextureAttachment::cubeMapFace() const -{ - return IsCubeMapTextureTarget(mIndex.type) ? mIndex.type : GL_NONE; -} - -GLint TextureAttachment::layer() const -{ - return mIndex.layerIndex; -} - -Texture *TextureAttachment::getTexture() const -{ - return mTexture.get(); -} - -const ImageIndex *TextureAttachment::getTextureImageIndex() const -{ - return &mIndex; -} - -Renderbuffer *TextureAttachment::getRenderbuffer() const -{ - UNREACHABLE(); - return NULL; -} - -////// RenderbufferAttachment Implementation ////// +////// FramebufferAttachment Implementation ////// -RenderbufferAttachment::RenderbufferAttachment(GLenum binding, Renderbuffer *renderbuffer) - : FramebufferAttachment(binding) +FramebufferAttachment::FramebufferAttachment() + : mType(GL_NONE), mResource(nullptr) { - ASSERT(renderbuffer); - mRenderbuffer.set(renderbuffer); } -RenderbufferAttachment::~RenderbufferAttachment() +FramebufferAttachment::FramebufferAttachment(GLenum type, + GLenum binding, + const ImageIndex &textureIndex, + FramebufferAttachmentObject *resource) + : mResource(nullptr) { - mRenderbuffer.set(NULL); + attach(type, binding, textureIndex, resource); } -GLsizei RenderbufferAttachment::getWidth() const +FramebufferAttachment::FramebufferAttachment(const FramebufferAttachment &other) + : mResource(nullptr) { - return mRenderbuffer->getWidth(); + attach(other.mType, other.mTarget.binding(), other.mTarget.textureIndex(), other.mResource); } -GLsizei RenderbufferAttachment::getHeight() const +FramebufferAttachment &FramebufferAttachment::operator=(const FramebufferAttachment &other) { - return mRenderbuffer->getHeight(); + attach(other.mType, other.mTarget.binding(), other.mTarget.textureIndex(), other.mResource); + return *this; } -GLenum RenderbufferAttachment::getInternalFormat() const +FramebufferAttachment::~FramebufferAttachment() { - return mRenderbuffer->getInternalFormat(); + detach(); } -GLsizei RenderbufferAttachment::getSamples() const +void FramebufferAttachment::detach() { - return mRenderbuffer->getSamples(); -} + mType = GL_NONE; + if (mResource != nullptr) + { + mResource->onDetach(); + mResource = nullptr; + } -GLuint RenderbufferAttachment::id() const -{ - return mRenderbuffer->id(); + // not technically necessary, could omit for performance + mTarget = Target(); } -GLenum RenderbufferAttachment::type() const +void FramebufferAttachment::attach(GLenum type, + GLenum binding, + const ImageIndex &textureIndex, + FramebufferAttachmentObject *resource) { - return GL_RENDERBUFFER; -} + mType = type; + mTarget = Target(binding, textureIndex); -GLint RenderbufferAttachment::mipLevel() const -{ - return 0; + if (resource) + { + resource->onAttach(); + } + if (mResource != nullptr) + { + mResource->onDetach(); + } + mResource = resource; } -GLenum RenderbufferAttachment::cubeMapFace() const +GLuint FramebufferAttachment::getRedSize() const { - return GL_NONE; + return GetInternalFormatInfo(getInternalFormat()).redBits; } -GLint RenderbufferAttachment::layer() const +GLuint FramebufferAttachment::getGreenSize() const { - return 0; + return GetInternalFormatInfo(getInternalFormat()).greenBits; } -Texture *RenderbufferAttachment::getTexture() const +GLuint FramebufferAttachment::getBlueSize() const { - UNREACHABLE(); - return NULL; + return GetInternalFormatInfo(getInternalFormat()).blueBits; } -const ImageIndex *RenderbufferAttachment::getTextureImageIndex() const +GLuint FramebufferAttachment::getAlphaSize() const { - UNREACHABLE(); - return NULL; + return GetInternalFormatInfo(getInternalFormat()).alphaBits; } -Renderbuffer *RenderbufferAttachment::getRenderbuffer() const +GLuint FramebufferAttachment::getDepthSize() const { - return mRenderbuffer.get(); + return GetInternalFormatInfo(getInternalFormat()).depthBits; } - -DefaultAttachment::DefaultAttachment(GLenum binding, egl::Surface *surface) - : FramebufferAttachment(binding) +GLuint FramebufferAttachment::getStencilSize() const { - mSurface.set(surface); + return GetInternalFormatInfo(getInternalFormat()).stencilBits; } -DefaultAttachment::~DefaultAttachment() +GLenum FramebufferAttachment::getComponentType() const { - mSurface.set(nullptr); + return GetInternalFormatInfo(getInternalFormat()).componentType; } -GLsizei DefaultAttachment::getWidth() const +GLenum FramebufferAttachment::getColorEncoding() const { - return mSurface->getWidth(); + return GetInternalFormatInfo(getInternalFormat()).colorEncoding; } -GLsizei DefaultAttachment::getHeight() const +GLuint FramebufferAttachment::id() const { - return mSurface->getHeight(); + return mResource->getId(); } -GLenum DefaultAttachment::getInternalFormat() const +const ImageIndex &FramebufferAttachment::getTextureImageIndex() const { - const egl::Config *config = mSurface->getConfig(); - return (getBinding() == GL_BACK ? config->renderTargetFormat : config->depthStencilFormat); + ASSERT(type() == GL_TEXTURE); + return mTarget.textureIndex(); } -GLsizei DefaultAttachment::getSamples() const +GLenum FramebufferAttachment::cubeMapFace() const { - const egl::Config *config = mSurface->getConfig(); - return config->samples; -} + ASSERT(mType == GL_TEXTURE); -GLuint DefaultAttachment::id() const -{ - return 0; + const auto &index = mTarget.textureIndex(); + return IsCubeMapTextureTarget(index.type) ? index.type : GL_NONE; } -GLenum DefaultAttachment::type() const +GLint FramebufferAttachment::mipLevel() const { - return GL_FRAMEBUFFER_DEFAULT; + ASSERT(type() == GL_TEXTURE); + return mTarget.textureIndex().mipIndex; } -GLint DefaultAttachment::mipLevel() const +GLint FramebufferAttachment::layer() const { - return 0; -} + ASSERT(mType == GL_TEXTURE); -GLenum DefaultAttachment::cubeMapFace() const -{ - return GL_NONE; -} + const auto &index = mTarget.textureIndex(); -GLint DefaultAttachment::layer() const -{ + if (index.type == GL_TEXTURE_2D_ARRAY || index.type == GL_TEXTURE_3D) + { + return index.layerIndex; + } return 0; } -Texture *DefaultAttachment::getTexture() const +Texture *FramebufferAttachment::getTexture() const { - UNREACHABLE(); - return NULL; + return rx::GetAs<Texture>(mResource); } -const ImageIndex *DefaultAttachment::getTextureImageIndex() const +Renderbuffer *FramebufferAttachment::getRenderbuffer() const { - UNREACHABLE(); - return NULL; + return rx::GetAs<Renderbuffer>(mResource); } -Renderbuffer *DefaultAttachment::getRenderbuffer() const +const egl::Surface *FramebufferAttachment::getSurface() const { - UNREACHABLE(); - return NULL; + return rx::GetAs<egl::Surface>(mResource); } } |