Commit d1405e51 by Jamie Madill

Share FBO state with object and Impl.

This patch introduces a new Framebuffer::Data class, which stores attachment related state. This will eliminate the need to store duplicated state between the classes. BUG=angleproject:930 Change-Id: I80de4db39ab99d623b0ad8306bf3cbb794cd8bd5 Reviewed-on: https://chromium-review.googlesource.com/254100Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 0af26e10
......@@ -184,10 +184,8 @@ void Context::makeCurrent(egl::Surface *surface)
mHasBeenCurrent = true;
}
Framebuffer *framebufferZero = new DefaultFramebuffer(mRenderer->createFramebuffer(),
mRenderer->createDefaultAttachment(GL_BACK, surface),
mRenderer->createDefaultAttachment(GL_DEPTH, surface),
mRenderer->createDefaultAttachment(GL_STENCIL, surface));
// TODO(jmadill): do not allocate new pointers here
Framebuffer *framebufferZero = new DefaultFramebuffer(mCaps, mRenderer, surface);
setFramebufferZero(framebufferZero);
......@@ -523,7 +521,7 @@ void Context::bindReadFramebuffer(GLuint framebuffer)
{
if (!getFramebuffer(framebuffer))
{
mFramebufferMap[framebuffer] = new Framebuffer(mRenderer->createFramebuffer(), framebuffer);
mFramebufferMap[framebuffer] = new Framebuffer(mCaps, mRenderer, framebuffer);
}
mState.setReadFramebufferBinding(getFramebuffer(framebuffer));
......@@ -533,7 +531,7 @@ void Context::bindDrawFramebuffer(GLuint framebuffer)
{
if (!getFramebuffer(framebuffer))
{
mFramebufferMap[framebuffer] = new Framebuffer(mRenderer->createFramebuffer(), framebuffer);
mFramebufferMap[framebuffer] = new Framebuffer(mCaps, mRenderer, framebuffer);
}
mState.setDrawFramebufferBinding(getFramebuffer(framebuffer));
......
......@@ -20,23 +20,29 @@
namespace rx
{
class RenderbufferImpl;
struct Workarounds;
class DefaultAttachmentImpl;
class FramebufferImpl;
class RenderbufferImpl;
class Renderer;
struct Workarounds;
}
namespace egl
{
class Surface;
}
namespace gl
{
class FramebufferAttachment;
class Texture;
class Renderbuffer;
struct ImageIndex;
struct Caps;
struct Extensions;
class State;
class Texture;
class TextureCapsMap;
struct Caps;
struct Data;
class State;
struct Extensions;
struct ImageIndex;
struct Rectangle;
typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
......@@ -44,7 +50,25 @@ typedef std::vector<FramebufferAttachment *> ColorbufferInfo;
class Framebuffer
{
public:
Framebuffer(rx::FramebufferImpl *impl, GLuint id);
class Data final
{
public:
Data(const Caps &caps);
~Data();
std::vector<FramebufferAttachment *> mColorAttachments;
FramebufferAttachment *mDepthAttachment;
FramebufferAttachment *mStencilAttachment;
std::vector<GLenum> mDrawBufferStates;
GLenum mReadBufferState;
private:
DISALLOW_COPY_AND_ASSIGN(Data);
};
Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id);
virtual ~Framebuffer();
const rx::FramebufferImpl *getImplementation() const { return mImpl; }
......@@ -108,17 +132,12 @@ class Framebuffer
protected:
void setAttachment(GLenum attachment, FramebufferAttachment *attachmentObj);
void detachResourceById(GLenum resourceType, GLuint resourceId);
Data mData;
rx::FramebufferImpl *mImpl;
GLuint mId;
FramebufferAttachment *mColorbuffers[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mDrawBufferStates[IMPLEMENTATION_MAX_DRAW_BUFFERS];
GLenum mReadBufferState;
FramebufferAttachment *mDepthbuffer;
FramebufferAttachment *mStencilbuffer;
private:
DISALLOW_COPY_AND_ASSIGN(Framebuffer);
};
......@@ -126,8 +145,7 @@ class Framebuffer
class DefaultFramebuffer : public Framebuffer
{
public:
DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAttachmentImpl *colorAttachment,
rx::DefaultAttachmentImpl *depthAttachment, rx::DefaultAttachmentImpl *stencilAttachment);
DefaultFramebuffer(const gl::Caps &caps, rx::Renderer *renderer, egl::Surface *surface);
private:
DISALLOW_COPY_AND_ASSIGN(DefaultFramebuffer);
......
......@@ -12,6 +12,7 @@
#include "angle_gl.h"
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
namespace gl
{
......@@ -27,8 +28,8 @@ namespace rx
class FramebufferImpl
{
public:
FramebufferImpl() {}
virtual ~FramebufferImpl() {};
FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { }
virtual ~FramebufferImpl() { }
virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthttachment(const gl::FramebufferAttachment *attachment) = 0;
......@@ -56,6 +57,11 @@ class FramebufferImpl
virtual GLenum checkStatus() const = 0;
const gl::Framebuffer::Data &getData() const { return mData; }
protected:
const gl::Framebuffer::Data &mData;
private:
DISALLOW_COPY_AND_ASSIGN(FramebufferImpl);
};
......
......@@ -12,6 +12,7 @@
#include "libANGLE/Caps.h"
#include "libANGLE/Error.h"
#include "libANGLE/Framebuffer.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/renderer/Workarounds.h"
......@@ -31,7 +32,6 @@ class Surface;
namespace gl
{
class Buffer;
class Framebuffer;
struct Data;
}
......@@ -76,7 +76,7 @@ class Renderer
// Framebuffer creation
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) = 0;
virtual FramebufferImpl *createFramebuffer() = 0;
virtual FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) = 0;
// Texture creation
virtual TextureImpl *createTexture(GLenum target) = 0;
......
......@@ -61,8 +61,9 @@ RenderTargetD3D *DefaultAttachmentD3D::getRenderTarget() const
}
FramebufferD3D::FramebufferD3D(RendererD3D *renderer)
: mRenderer(renderer),
FramebufferD3D::FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer)
: FramebufferImpl(data),
mRenderer(renderer),
mColorBuffers(renderer->getRendererCaps().maxColorAttachments),
mDepthbuffer(nullptr),
mStencilbuffer(nullptr),
......
......@@ -51,7 +51,7 @@ class DefaultAttachmentD3D : public DefaultAttachmentImpl
class FramebufferD3D : public FramebufferImpl
{
public:
FramebufferD3D(RendererD3D *renderer);
FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer);
virtual ~FramebufferD3D();
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
......
......@@ -24,8 +24,8 @@
namespace rx
{
Framebuffer11::Framebuffer11(Renderer11 *renderer)
: FramebufferD3D(renderer),
Framebuffer11::Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer)
: FramebufferD3D(data, renderer),
mRenderer(renderer)
{
ASSERT(mRenderer != nullptr);
......
......@@ -18,7 +18,7 @@ class Renderer11;
class Framebuffer11 : public FramebufferD3D
{
public:
Framebuffer11(Renderer11 *renderer);
Framebuffer11(const gl::Framebuffer::Data &data, Renderer11 *renderer);
virtual ~Framebuffer11();
// Invalidate the cached swizzles of all bound texture attachments.
......
......@@ -2626,9 +2626,9 @@ DefaultAttachmentImpl *Renderer11::createDefaultAttachment(GLenum type, egl::Sur
}
}
FramebufferImpl *Renderer11::createFramebuffer()
FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new Framebuffer11(this);
return new Framebuffer11(data, this);
}
CompilerImpl *Renderer11::createCompiler(const gl::Data &data)
......
......@@ -149,8 +149,8 @@ class Renderer11 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
virtual FramebufferImpl *createFramebuffer() override;
DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation
virtual CompilerImpl *createCompiler(const gl::Data &data);
......
......@@ -21,8 +21,8 @@
namespace rx
{
Framebuffer9::Framebuffer9(Renderer9 *renderer)
: FramebufferD3D(renderer),
Framebuffer9::Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer)
: FramebufferD3D(data, renderer),
mRenderer(renderer)
{
ASSERT(mRenderer != nullptr);
......
......@@ -18,7 +18,7 @@ class Renderer9;
class Framebuffer9 : public FramebufferD3D
{
public:
Framebuffer9(Renderer9 *renderer);
Framebuffer9(const gl::Framebuffer::Data &data, Renderer9 *renderer);
virtual ~Framebuffer9();
private:
......
......@@ -2650,9 +2650,9 @@ DefaultAttachmentImpl *Renderer9::createDefaultAttachment(GLenum type, egl::Surf
}
}
FramebufferImpl *Renderer9::createFramebuffer()
FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new Framebuffer9(this);
return new Framebuffer9(data, this);
}
CompilerImpl *Renderer9::createCompiler(const gl::Data &data)
......
......@@ -158,8 +158,8 @@ class Renderer9 : public RendererD3D
virtual gl::Error createRenderTarget(int width, int height, GLenum format, GLsizei samples, RenderTargetD3D **outRT);
// Framebuffer creation
virtual DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
virtual FramebufferImpl *createFramebuffer() override;
DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Shader creation
virtual CompilerImpl *createCompiler(const gl::Data &data);
......
......@@ -13,8 +13,8 @@
namespace rx
{
FramebufferGL::FramebufferGL()
: FramebufferImpl()
FramebufferGL::FramebufferGL(const gl::Framebuffer::Data &data)
: FramebufferImpl(data)
{}
FramebufferGL::~FramebufferGL()
......
......@@ -17,7 +17,7 @@ namespace rx
class FramebufferGL : public FramebufferImpl
{
public:
FramebufferGL();
FramebufferGL(const gl::Framebuffer::Data &data);
~FramebufferGL() override;
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
......
......@@ -100,9 +100,9 @@ DefaultAttachmentImpl *RendererGL::createDefaultAttachment(GLenum type, egl::Sur
return new DefaultAttachmentGL();
}
FramebufferImpl *RendererGL::createFramebuffer()
FramebufferImpl *RendererGL::createFramebuffer(const gl::Framebuffer::Data &data)
{
return new FramebufferGL();
return new FramebufferGL(data);
}
TextureImpl *RendererGL::createTexture(GLenum target)
......
......@@ -38,7 +38,7 @@ class RendererGL : public Renderer
// Framebuffer creation
DefaultAttachmentImpl *createDefaultAttachment(GLenum type, egl::Surface *surface) override;
FramebufferImpl *createFramebuffer() override;
FramebufferImpl *createFramebuffer(const gl::Framebuffer::Data &data) override;
// Texture creation
TextureImpl *createTexture(GLenum target) override;
......
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