Commit afc21c06 by Jamie Madill

Move FBO attachment code to new source file.

Since FBO attachments and Renderbuffers are semantically distinct, make a new location for attachments to live. BUG=angle:660 Change-Id: I51753f8a814e89641637c5d8293f7e9a573a7ba5 Reviewed-on: https://chromium-review.googlesource.com/201833Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3c7fa226
......@@ -152,6 +152,7 @@
<ClInclude Include="..\..\src\libGLESv2\Fence.h"/>
<ClInclude Include="..\..\src\libGLESv2\angletypes.h"/>
<ClInclude Include="..\..\src\libGLESv2\main.h"/>
<ClInclude Include="..\..\src\libGLESv2\FramebufferAttachment.h"/>
<ClInclude Include="..\..\src\libGLESv2\Framebuffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\formatutils.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\IndexDataManager.h"/>
......@@ -304,6 +305,7 @@
<ClCompile Include="..\..\src\libGLESv2\Float16ToFloat32.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\ResourceManager.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\validationES3.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\FramebufferAttachment.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\Query.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\libGLESv2.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\formatutils.cpp"/>
......
......@@ -153,6 +153,9 @@
<ClInclude Include="..\..\src\libGLESv2\Buffer.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\FramebufferAttachment.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\RenderbufferProxySet.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
......@@ -231,6 +234,9 @@
<ClCompile Include="..\..\src\libGLESv2\ProgramBinary.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\FramebufferAttachment.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\Sampler.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......
#include "precompiled.h"
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferAttachment.cpp: the gl::FramebufferAttachment class and its derived classes
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/TextureStorage.h"
#include "common/utilities.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/Renderbuffer.h"
namespace gl
{
FramebufferAttachmentInterface::FramebufferAttachmentInterface()
{
}
// The default case for classes inherited from FramebufferAttachmentInterface is not to
// need to do anything upon the reference count to the parent FramebufferAttachment incrementing
// or decrementing.
void FramebufferAttachmentInterface::addProxyRef(const FramebufferAttachment *proxy)
{
}
void FramebufferAttachmentInterface::releaseProxy(const FramebufferAttachment *proxy)
{
}
///// Texture2DAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level)
{
mTexture2D.set(texture);
}
Texture2DAttachment::~Texture2DAttachment()
{
mTexture2D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void Texture2DAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture2D->addProxyRef(proxy);
}
void Texture2DAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture2D->releaseProxy(proxy);
}
rx::RenderTarget *Texture2DAttachment::getRenderTarget()
{
return mTexture2D->getRenderTarget(mLevel);
}
rx::RenderTarget *Texture2DAttachment::getDepthStencil()
{
return mTexture2D->getDepthSencil(mLevel);
}
rx::TextureStorage *Texture2DAttachment::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DAttachment::getWidth() const
{
return mTexture2D->getWidth(mLevel);
}
GLsizei Texture2DAttachment::getHeight() const
{
return mTexture2D->getHeight(mLevel);
}
GLenum Texture2DAttachment::getInternalFormat() const
{
return mTexture2D->getInternalFormat(mLevel);
}
GLenum Texture2DAttachment::getActualFormat() const
{
return mTexture2D->getActualFormat(mLevel);
}
GLsizei Texture2DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DAttachment::getSerial() const
{
return mTexture2D->getRenderTargetSerial(mLevel);
}
bool Texture2DAttachment::isTexture() const
{
return true;
}
unsigned int Texture2DAttachment::getTextureSerial() const
{
return mTexture2D->getTextureSerial();
}
///// TextureCubeMapAttachment Implementation ////////
TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level)
: mFaceTarget(faceTarget), mLevel(level)
{
mTextureCubeMap.set(texture);
}
TextureCubeMapAttachment::~TextureCubeMapAttachment()
{
mTextureCubeMap.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void TextureCubeMapAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTextureCubeMap->addProxyRef(proxy);
}
void TextureCubeMapAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTextureCubeMap->releaseProxy(proxy);
}
rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
{
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
}
rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil()
{
return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel);
}
rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage()
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
}
GLsizei TextureCubeMapAttachment::getWidth() const
{
return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getHeight() const
{
return mTextureCubeMap->getHeight(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getInternalFormat() const
{
return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getActualFormat() const
{
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getSamples() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getSerial() const
{
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
}
bool TextureCubeMapAttachment::isTexture() const
{
return true;
}
unsigned int TextureCubeMapAttachment::getTextureSerial() const
{
return mTextureCubeMap->getTextureSerial();
}
///// Texture3DAttachment Implementation ////////
Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture3D.set(texture);
}
Texture3DAttachment::~Texture3DAttachment()
{
mTexture3D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void Texture3DAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture3D->addProxyRef(proxy);
}
void Texture3DAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture3D->releaseProxy(proxy);
}
rx::RenderTarget *Texture3DAttachment::getRenderTarget()
{
return mTexture3D->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture3DAttachment::getDepthStencil()
{
return mTexture3D->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture3DAttachment::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture3DAttachment::getWidth() const
{
return mTexture3D->getWidth(mLevel);
}
GLsizei Texture3DAttachment::getHeight() const
{
return mTexture3D->getHeight(mLevel);
}
GLenum Texture3DAttachment::getInternalFormat() const
{
return mTexture3D->getInternalFormat(mLevel);
}
GLenum Texture3DAttachment::getActualFormat() const
{
return mTexture3D->getActualFormat(mLevel);
}
GLsizei Texture3DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture3DAttachment::getSerial() const
{
return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
}
bool Texture3DAttachment::isTexture() const
{
return true;
}
unsigned int Texture3DAttachment::getTextureSerial() const
{
return mTexture3D->getTextureSerial();
}
////// Texture2DArrayAttachment Implementation //////
Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture2DArray.set(texture);
}
Texture2DArrayAttachment::~Texture2DArrayAttachment()
{
mTexture2DArray.set(NULL);
}
void Texture2DArrayAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture2DArray->addProxyRef(proxy);
}
void Texture2DArrayAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture2DArray->releaseProxy(proxy);
}
rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
{
return mTexture2DArray->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil()
{
return mTexture2DArray->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DArrayAttachment::getWidth() const
{
return mTexture2DArray->getWidth(mLevel);
}
GLsizei Texture2DArrayAttachment::getHeight() const
{
return mTexture2DArray->getHeight(mLevel);
}
GLenum Texture2DArrayAttachment::getInternalFormat() const
{
return mTexture2DArray->getInternalFormat(mLevel);
}
GLenum Texture2DArrayAttachment::getActualFormat() const
{
return mTexture2DArray->getActualFormat(mLevel);
}
GLsizei Texture2DArrayAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DArrayAttachment::getSerial() const
{
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
}
bool Texture2DArrayAttachment::isTexture() const
{
return true;
}
unsigned int Texture2DArrayAttachment::getTextureSerial() const
{
return mTexture2DArray->getTextureSerial();
}
////// FramebufferAttachment Implementation //////
FramebufferAttachment::FramebufferAttachment(rx::Renderer *renderer, GLuint id, FramebufferAttachmentInterface *instance) : RefCountObject(id)
{
ASSERT(instance != NULL);
mInstance = instance;
ASSERT(renderer != NULL);
mRenderer = renderer;
}
FramebufferAttachment::~FramebufferAttachment()
{
delete mInstance;
}
// The FramebufferAttachmentInterface contained in this FramebufferAttachment may need to maintain
// its own reference count, so we pass it on here.
void FramebufferAttachment::addRef() const
{
mInstance->addProxyRef(this);
RefCountObject::addRef();
}
void FramebufferAttachment::release() const
{
mInstance->releaseProxy(this);
RefCountObject::release();
}
rx::RenderTarget *FramebufferAttachment::getRenderTarget()
{
return mInstance->getRenderTarget();
}
rx::RenderTarget *FramebufferAttachment::getDepthStencil()
{
return mInstance->getDepthStencil();
}
rx::TextureStorage *FramebufferAttachment::getTextureStorage()
{
return mInstance->getTextureStorage();
}
GLsizei FramebufferAttachment::getWidth() const
{
return mInstance->getWidth();
}
GLsizei FramebufferAttachment::getHeight() const
{
return mInstance->getHeight();
}
GLenum FramebufferAttachment::getInternalFormat() const
{
return mInstance->getInternalFormat();
}
GLenum FramebufferAttachment::getActualFormat() const
{
return mInstance->getActualFormat();
}
GLuint FramebufferAttachment::getRedSize() const
{
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getGreenSize() const
{
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getBlueSize() const
{
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getAlphaSize() const
{
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getDepthSize() const
{
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getStencilSize() const
{
return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLenum FramebufferAttachment::getComponentType() const
{
return gl::GetComponentType(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLenum FramebufferAttachment::getColorEncoding() const
{
return gl::GetColorEncoding(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLsizei FramebufferAttachment::getSamples() const
{
return mInstance->getSamples();
}
unsigned int FramebufferAttachment::getSerial() const
{
return mInstance->getSerial();
}
bool FramebufferAttachment::isTexture() const
{
return mInstance->isTexture();
}
unsigned int FramebufferAttachment::getTextureSerial() const
{
return mInstance->getTextureSerial();
}
void FramebufferAttachment::setStorage(RenderbufferStorage *newStorage)
{
ASSERT(newStorage != NULL);
delete mInstance;
mInstance = newStorage;
}
}
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferAttachment.h: Defines the wrapper class gl::FramebufferAttachment, as well as the
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
#ifndef LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
#define LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include "common/angleutils.h"
#include "common/RefCountObject.h"
namespace rx
{
class Renderer;
class RenderTarget;
class TextureStorage;
}
namespace gl
{
class Texture2D;
class TextureCubeMap;
class Texture3D;
class Texture2DArray;
class FramebufferAttachment;
class FramebufferAttachmentInterface;
class RenderbufferStorage;
// FramebufferAttachment implements the GL renderbuffer object.
// It's only a proxy for a FramebufferAttachmentInterface instance; the internal object
// can change whenever glRenderbufferStorage is called.
class FramebufferAttachment : public RefCountObject
{
public:
FramebufferAttachment(rx::Renderer *renderer, GLuint id, FramebufferAttachmentInterface *storage);
virtual ~FramebufferAttachment();
// These functions from RefCountObject are overloaded here because
// Textures need to maintain their own count of references to them via
// Renderbuffers/RenderbufferTextures. These functions invoke those
// reference counting functions on the FramebufferAttachmentInterface.
void addRef() const;
void release() const;
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
GLsizei getWidth() const;
GLsizei getHeight() const;
GLenum getInternalFormat() const;
GLenum getActualFormat() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
GLenum getComponentType() const;
GLenum getColorEncoding() const;
GLsizei getSamples() const;
unsigned int getSerial() const;
bool isTexture() const;
unsigned int getTextureSerial() const;
void setStorage(RenderbufferStorage *newStorage);
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
rx::Renderer const *mRenderer;
FramebufferAttachmentInterface *mInstance;
};
class FramebufferAttachmentInterface
{
public:
FramebufferAttachmentInterface();
virtual ~FramebufferAttachmentInterface() {};
virtual void addProxyRef(const FramebufferAttachment *proxy);
virtual void releaseProxy(const FramebufferAttachment *proxy);
virtual rx::RenderTarget *getRenderTarget() = 0;
virtual rx::RenderTarget *getDepthStencil() = 0;
virtual rx::TextureStorage *getTextureStorage() = 0;
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
virtual unsigned int getSerial() const = 0;
virtual bool isTexture() const = 0;
virtual unsigned int getTextureSerial() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachmentInterface);
};
class Texture2DAttachment : public FramebufferAttachmentInterface
{
public:
Texture2DAttachment(Texture2D *texture, GLint level);
virtual ~Texture2DAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
BindingPointer <Texture2D> mTexture2D;
const GLint mLevel;
};
class TextureCubeMapAttachment : public FramebufferAttachmentInterface
{
public:
TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level);
virtual ~TextureCubeMapAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment);
BindingPointer <TextureCubeMap> mTextureCubeMap;
const GLint mLevel;
const GLenum mFaceTarget;
};
class Texture3DAttachment : public FramebufferAttachmentInterface
{
public:
Texture3DAttachment(Texture3D *texture, GLint level, GLint layer);
virtual ~Texture3DAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment);
BindingPointer<Texture3D> mTexture3D;
const GLint mLevel;
const GLint mLayer;
};
class Texture2DArrayAttachment : public FramebufferAttachmentInterface
{
public:
Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer);
virtual ~Texture2DArrayAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment);
BindingPointer<Texture2DArray> mTexture2DArray;
const GLint mLevel;
const GLint mLayer;
};
}
#endif // LIBGLESV2_FRAMEBUFFERATTACHMENT_H_
......@@ -22,473 +22,6 @@ namespace gl
{
unsigned int RenderbufferStorage::mCurrentSerial = 1;
FramebufferAttachmentInterface::FramebufferAttachmentInterface()
{
}
// The default case for classes inherited from FramebufferAttachmentInterface is not to
// need to do anything upon the reference count to the parent FramebufferAttachment incrementing
// or decrementing.
void FramebufferAttachmentInterface::addProxyRef(const FramebufferAttachment *proxy)
{
}
void FramebufferAttachmentInterface::releaseProxy(const FramebufferAttachment *proxy)
{
}
///// Texture2DAttachment Implementation ////////
Texture2DAttachment::Texture2DAttachment(Texture2D *texture, GLint level) : mLevel(level)
{
mTexture2D.set(texture);
}
Texture2DAttachment::~Texture2DAttachment()
{
mTexture2D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void Texture2DAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture2D->addProxyRef(proxy);
}
void Texture2DAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture2D->releaseProxy(proxy);
}
rx::RenderTarget *Texture2DAttachment::getRenderTarget()
{
return mTexture2D->getRenderTarget(mLevel);
}
rx::RenderTarget *Texture2DAttachment::getDepthStencil()
{
return mTexture2D->getDepthSencil(mLevel);
}
rx::TextureStorage *Texture2DAttachment::getTextureStorage()
{
return mTexture2D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DAttachment::getWidth() const
{
return mTexture2D->getWidth(mLevel);
}
GLsizei Texture2DAttachment::getHeight() const
{
return mTexture2D->getHeight(mLevel);
}
GLenum Texture2DAttachment::getInternalFormat() const
{
return mTexture2D->getInternalFormat(mLevel);
}
GLenum Texture2DAttachment::getActualFormat() const
{
return mTexture2D->getActualFormat(mLevel);
}
GLsizei Texture2DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DAttachment::getSerial() const
{
return mTexture2D->getRenderTargetSerial(mLevel);
}
bool Texture2DAttachment::isTexture() const
{
return true;
}
unsigned int Texture2DAttachment::getTextureSerial() const
{
return mTexture2D->getTextureSerial();
}
///// TextureCubeMapAttachment Implementation ////////
TextureCubeMapAttachment::TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level)
: mFaceTarget(faceTarget), mLevel(level)
{
mTextureCubeMap.set(texture);
}
TextureCubeMapAttachment::~TextureCubeMapAttachment()
{
mTextureCubeMap.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void TextureCubeMapAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTextureCubeMap->addProxyRef(proxy);
}
void TextureCubeMapAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTextureCubeMap->releaseProxy(proxy);
}
rx::RenderTarget *TextureCubeMapAttachment::getRenderTarget()
{
return mTextureCubeMap->getRenderTarget(mFaceTarget, mLevel);
}
rx::RenderTarget *TextureCubeMapAttachment::getDepthStencil()
{
return mTextureCubeMap->getDepthStencil(mFaceTarget, mLevel);
}
rx::TextureStorage *TextureCubeMapAttachment::getTextureStorage()
{
return mTextureCubeMap->getNativeTexture()->getStorageInstance();
}
GLsizei TextureCubeMapAttachment::getWidth() const
{
return mTextureCubeMap->getWidth(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getHeight() const
{
return mTextureCubeMap->getHeight(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getInternalFormat() const
{
return mTextureCubeMap->getInternalFormat(mFaceTarget, mLevel);
}
GLenum TextureCubeMapAttachment::getActualFormat() const
{
return mTextureCubeMap->getActualFormat(mFaceTarget, mLevel);
}
GLsizei TextureCubeMapAttachment::getSamples() const
{
return 0;
}
unsigned int TextureCubeMapAttachment::getSerial() const
{
return mTextureCubeMap->getRenderTargetSerial(mFaceTarget, mLevel);
}
bool TextureCubeMapAttachment::isTexture() const
{
return true;
}
unsigned int TextureCubeMapAttachment::getTextureSerial() const
{
return mTextureCubeMap->getTextureSerial();
}
///// Texture3DAttachment Implementation ////////
Texture3DAttachment::Texture3DAttachment(Texture3D *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture3D.set(texture);
}
Texture3DAttachment::~Texture3DAttachment()
{
mTexture3D.set(NULL);
}
// Textures need to maintain their own reference count for references via
// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
void Texture3DAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture3D->addProxyRef(proxy);
}
void Texture3DAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture3D->releaseProxy(proxy);
}
rx::RenderTarget *Texture3DAttachment::getRenderTarget()
{
return mTexture3D->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture3DAttachment::getDepthStencil()
{
return mTexture3D->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture3DAttachment::getTextureStorage()
{
return mTexture3D->getNativeTexture()->getStorageInstance();
}
GLsizei Texture3DAttachment::getWidth() const
{
return mTexture3D->getWidth(mLevel);
}
GLsizei Texture3DAttachment::getHeight() const
{
return mTexture3D->getHeight(mLevel);
}
GLenum Texture3DAttachment::getInternalFormat() const
{
return mTexture3D->getInternalFormat(mLevel);
}
GLenum Texture3DAttachment::getActualFormat() const
{
return mTexture3D->getActualFormat(mLevel);
}
GLsizei Texture3DAttachment::getSamples() const
{
return 0;
}
unsigned int Texture3DAttachment::getSerial() const
{
return mTexture3D->getRenderTargetSerial(mLevel, mLayer);
}
bool Texture3DAttachment::isTexture() const
{
return true;
}
unsigned int Texture3DAttachment::getTextureSerial() const
{
return mTexture3D->getTextureSerial();
}
////// Texture2DArrayAttachment Implementation //////
Texture2DArrayAttachment::Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer)
: mLevel(level), mLayer(layer)
{
mTexture2DArray.set(texture);
}
Texture2DArrayAttachment::~Texture2DArrayAttachment()
{
mTexture2DArray.set(NULL);
}
void Texture2DArrayAttachment::addProxyRef(const FramebufferAttachment *proxy)
{
mTexture2DArray->addProxyRef(proxy);
}
void Texture2DArrayAttachment::releaseProxy(const FramebufferAttachment *proxy)
{
mTexture2DArray->releaseProxy(proxy);
}
rx::RenderTarget *Texture2DArrayAttachment::getRenderTarget()
{
return mTexture2DArray->getRenderTarget(mLevel, mLayer);
}
rx::RenderTarget *Texture2DArrayAttachment::getDepthStencil()
{
return mTexture2DArray->getDepthStencil(mLevel, mLayer);
}
rx::TextureStorage *Texture2DArrayAttachment::getTextureStorage()
{
return mTexture2DArray->getNativeTexture()->getStorageInstance();
}
GLsizei Texture2DArrayAttachment::getWidth() const
{
return mTexture2DArray->getWidth(mLevel);
}
GLsizei Texture2DArrayAttachment::getHeight() const
{
return mTexture2DArray->getHeight(mLevel);
}
GLenum Texture2DArrayAttachment::getInternalFormat() const
{
return mTexture2DArray->getInternalFormat(mLevel);
}
GLenum Texture2DArrayAttachment::getActualFormat() const
{
return mTexture2DArray->getActualFormat(mLevel);
}
GLsizei Texture2DArrayAttachment::getSamples() const
{
return 0;
}
unsigned int Texture2DArrayAttachment::getSerial() const
{
return mTexture2DArray->getRenderTargetSerial(mLevel, mLayer);
}
bool Texture2DArrayAttachment::isTexture() const
{
return true;
}
unsigned int Texture2DArrayAttachment::getTextureSerial() const
{
return mTexture2DArray->getTextureSerial();
}
////// FramebufferAttachment Implementation //////
FramebufferAttachment::FramebufferAttachment(rx::Renderer *renderer, GLuint id, FramebufferAttachmentInterface *instance) : RefCountObject(id)
{
ASSERT(instance != NULL);
mInstance = instance;
ASSERT(renderer != NULL);
mRenderer = renderer;
}
FramebufferAttachment::~FramebufferAttachment()
{
delete mInstance;
}
// The FramebufferAttachmentInterface contained in this FramebufferAttachment may need to maintain
// its own reference count, so we pass it on here.
void FramebufferAttachment::addRef() const
{
mInstance->addProxyRef(this);
RefCountObject::addRef();
}
void FramebufferAttachment::release() const
{
mInstance->releaseProxy(this);
RefCountObject::release();
}
rx::RenderTarget *FramebufferAttachment::getRenderTarget()
{
return mInstance->getRenderTarget();
}
rx::RenderTarget *FramebufferAttachment::getDepthStencil()
{
return mInstance->getDepthStencil();
}
rx::TextureStorage *FramebufferAttachment::getTextureStorage()
{
return mInstance->getTextureStorage();
}
GLsizei FramebufferAttachment::getWidth() const
{
return mInstance->getWidth();
}
GLsizei FramebufferAttachment::getHeight() const
{
return mInstance->getHeight();
}
GLenum FramebufferAttachment::getInternalFormat() const
{
return mInstance->getInternalFormat();
}
GLenum FramebufferAttachment::getActualFormat() const
{
return mInstance->getActualFormat();
}
GLuint FramebufferAttachment::getRedSize() const
{
return gl::GetRedBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getGreenSize() const
{
return gl::GetGreenBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getBlueSize() const
{
return gl::GetBlueBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getAlphaSize() const
{
return gl::GetAlphaBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getDepthSize() const
{
return gl::GetDepthBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLuint FramebufferAttachment::getStencilSize() const
{
return gl::GetStencilBits(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLenum FramebufferAttachment::getComponentType() const
{
return gl::GetComponentType(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLenum FramebufferAttachment::getColorEncoding() const
{
return gl::GetColorEncoding(getActualFormat(), mRenderer->getCurrentClientVersion());
}
GLsizei FramebufferAttachment::getSamples() const
{
return mInstance->getSamples();
}
unsigned int FramebufferAttachment::getSerial() const
{
return mInstance->getSerial();
}
bool FramebufferAttachment::isTexture() const
{
return mInstance->isTexture();
}
unsigned int FramebufferAttachment::getTextureSerial() const
{
return mInstance->getTextureSerial();
}
void FramebufferAttachment::setStorage(RenderbufferStorage *newStorage)
{
ASSERT(newStorage != NULL);
delete mInstance;
mInstance = newStorage;
}
RenderbufferStorage::RenderbufferStorage() : mSerial(issueSerials(1))
{
mWidth = 0;
......
......@@ -17,6 +17,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/FramebufferAttachment.h"
namespace rx
{
......@@ -28,173 +29,6 @@ class TextureStorage;
namespace gl
{
class Texture2D;
class TextureCubeMap;
class Texture3D;
class Texture2DArray;
class FramebufferAttachment;
class Colorbuffer;
class DepthStencilbuffer;
class FramebufferAttachmentInterface
{
public:
FramebufferAttachmentInterface();
virtual ~FramebufferAttachmentInterface() {};
virtual void addProxyRef(const FramebufferAttachment *proxy);
virtual void releaseProxy(const FramebufferAttachment *proxy);
virtual rx::RenderTarget *getRenderTarget() = 0;
virtual rx::RenderTarget *getDepthStencil() = 0;
virtual rx::TextureStorage *getTextureStorage() = 0;
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLenum getActualFormat() const = 0;
virtual GLsizei getSamples() const = 0;
virtual unsigned int getSerial() const = 0;
virtual bool isTexture() const = 0;
virtual unsigned int getTextureSerial() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachmentInterface);
};
class Texture2DAttachment : public FramebufferAttachmentInterface
{
public:
Texture2DAttachment(Texture2D *texture, GLint level);
virtual ~Texture2DAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DAttachment);
BindingPointer <Texture2D> mTexture2D;
const GLint mLevel;
};
class TextureCubeMapAttachment : public FramebufferAttachmentInterface
{
public:
TextureCubeMapAttachment(TextureCubeMap *texture, GLenum faceTarget, GLint level);
virtual ~TextureCubeMapAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(TextureCubeMapAttachment);
BindingPointer <TextureCubeMap> mTextureCubeMap;
const GLint mLevel;
const GLenum mFaceTarget;
};
class Texture3DAttachment : public FramebufferAttachmentInterface
{
public:
Texture3DAttachment(Texture3D *texture, GLint level, GLint layer);
virtual ~Texture3DAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture3DAttachment);
BindingPointer<Texture3D> mTexture3D;
const GLint mLevel;
const GLint mLayer;
};
class Texture2DArrayAttachment : public FramebufferAttachmentInterface
{
public:
Texture2DArrayAttachment(Texture2DArray *texture, GLint level, GLint layer);
virtual ~Texture2DArrayAttachment();
void addProxyRef(const FramebufferAttachment *proxy);
void releaseProxy(const FramebufferAttachment *proxy);
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
virtual GLsizei getWidth() const;
virtual GLsizei getHeight() const;
virtual GLenum getInternalFormat() const;
virtual GLenum getActualFormat() const;
virtual GLsizei getSamples() const;
virtual unsigned int getSerial() const;
virtual bool isTexture() const;
virtual unsigned int getTextureSerial() const;
private:
DISALLOW_COPY_AND_ASSIGN(Texture2DArrayAttachment);
BindingPointer<Texture2DArray> mTexture2DArray;
const GLint mLevel;
const GLint mLayer;
};
// A class derived from RenderbufferStorage is created whenever glRenderbufferStorage
// is called. The specific concrete type depends on whether the internal format is
......@@ -238,55 +72,6 @@ class RenderbufferStorage : public FramebufferAttachmentInterface
static unsigned int mCurrentSerial;
};
// FramebufferAttachment implements the GL renderbuffer object.
// It's only a proxy for a FramebufferAttachmentInterface instance; the internal object
// can change whenever glRenderbufferStorage is called.
class FramebufferAttachment : public RefCountObject
{
public:
FramebufferAttachment(rx::Renderer *renderer, GLuint id, FramebufferAttachmentInterface *storage);
virtual ~FramebufferAttachment();
// These functions from RefCountObject are overloaded here because
// Textures need to maintain their own count of references to them via
// Renderbuffers/RenderbufferTextures. These functions invoke those
// reference counting functions on the FramebufferAttachmentInterface.
void addRef() const;
void release() const;
rx::RenderTarget *getRenderTarget();
rx::RenderTarget *getDepthStencil();
rx::TextureStorage *getTextureStorage();
GLsizei getWidth() const;
GLsizei getHeight() const;
GLenum getInternalFormat() const;
GLenum getActualFormat() const;
GLuint getRedSize() const;
GLuint getGreenSize() const;
GLuint getBlueSize() const;
GLuint getAlphaSize() const;
GLuint getDepthSize() const;
GLuint getStencilSize() const;
GLenum getComponentType() const;
GLenum getColorEncoding() const;
GLsizei getSamples() const;
unsigned int getSerial() const;
bool isTexture() const;
unsigned int getTextureSerial() const;
void setStorage(RenderbufferStorage *newStorage);
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferAttachment);
rx::Renderer const *mRenderer;
FramebufferAttachmentInterface *mInstance;
};
class Colorbuffer : public RenderbufferStorage
{
public:
......
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