Commit 9dd95808 by Geoff Lang

Add set*Attachment methods to FramebufferImpl.

BUG=angle:841 Change-Id: Ie819c253a900d105d768aee168a6a2de89754ccc Reviewed-on: https://chromium-review.googlesource.com/232393Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent f1b85f31
...@@ -195,6 +195,18 @@ void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers) ...@@ -195,6 +195,18 @@ void Framebuffer::setDrawBuffers(size_t count, const GLenum *buffers)
ASSERT(count <= ArraySize(mDrawBufferStates)); ASSERT(count <= ArraySize(mDrawBufferStates));
std::copy(buffers, buffers + count, mDrawBufferStates); std::copy(buffers, buffers + count, mDrawBufferStates);
std::fill(mDrawBufferStates + count, mDrawBufferStates + ArraySize(mDrawBufferStates), GL_NONE); std::fill(mDrawBufferStates + count, mDrawBufferStates + ArraySize(mDrawBufferStates), GL_NONE);
mImpl->setDrawBuffers(count, buffers);
}
GLenum Framebuffer::getReadBufferState() const
{
return mReadBufferState;
}
void Framebuffer::setReadBuffer(GLenum buffer)
{
mReadBufferState = buffer;
mImpl->setReadBuffer(buffer);
} }
bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const bool Framebuffer::isEnabledColorAttachment(unsigned int colorAttachment) const
...@@ -536,21 +548,25 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -536,21 +548,25 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
size_t colorAttachment = attachment - GL_COLOR_ATTACHMENT0; size_t colorAttachment = attachment - GL_COLOR_ATTACHMENT0;
SafeDelete(mColorbuffers[colorAttachment]); SafeDelete(mColorbuffers[colorAttachment]);
mColorbuffers[colorAttachment] = attachmentObj; mColorbuffers[colorAttachment] = attachmentObj;
mImpl->setColorAttachment(colorAttachment, attachmentObj);
} }
else if (attachment == GL_BACK) else if (attachment == GL_BACK)
{ {
SafeDelete(mColorbuffers[0]); SafeDelete(mColorbuffers[0]);
mColorbuffers[0] = attachmentObj; mColorbuffers[0] = attachmentObj;
mImpl->setColorAttachment(0, attachmentObj);
} }
else if (attachment == GL_DEPTH_ATTACHMENT || attachment == GL_DEPTH) else if (attachment == GL_DEPTH_ATTACHMENT || attachment == GL_DEPTH)
{ {
SafeDelete(mDepthbuffer); SafeDelete(mDepthbuffer);
mDepthbuffer = attachmentObj; mDepthbuffer = attachmentObj;
mImpl->setDepthttachment(attachmentObj);
} }
else if (attachment == GL_STENCIL_ATTACHMENT || attachment == GL_STENCIL) else if (attachment == GL_STENCIL_ATTACHMENT || attachment == GL_STENCIL)
{ {
SafeDelete(mStencilbuffer); SafeDelete(mStencilbuffer);
mStencilbuffer = attachmentObj; mStencilbuffer = attachmentObj;
mImpl->setStencilAttachment(attachmentObj);
} }
else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT || attachment == GL_DEPTH_STENCIL) else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT || attachment == GL_DEPTH_STENCIL)
{ {
...@@ -561,6 +577,7 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -561,6 +577,7 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
if (attachmentObj && attachmentObj->getDepthSize() > 0 && attachmentObj->getStencilSize() > 0) if (attachmentObj && attachmentObj->getDepthSize() > 0 && attachmentObj->getStencilSize() > 0)
{ {
mDepthbuffer = attachmentObj; mDepthbuffer = attachmentObj;
mImpl->setDepthttachment(attachmentObj);
// Make a new attachment object to ensure we do not double-delete // Make a new attachment object to ensure we do not double-delete
// See angle issue 686 // See angle issue 686
...@@ -568,10 +585,12 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach ...@@ -568,10 +585,12 @@ void Framebuffer::setAttachment(GLenum attachment, FramebufferAttachment *attach
{ {
mStencilbuffer = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(), mStencilbuffer = new TextureAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getTexture(),
*attachmentObj->getTextureImageIndex()); *attachmentObj->getTextureImageIndex());
mImpl->setStencilAttachment(mStencilbuffer);
} }
else if (attachmentObj->type() == GL_RENDERBUFFER) else if (attachmentObj->type() == GL_RENDERBUFFER)
{ {
mStencilbuffer = new RenderbufferAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getRenderbuffer()); mStencilbuffer = new RenderbufferAttachment(GL_DEPTH_STENCIL_ATTACHMENT, attachmentObj->getRenderbuffer());
mImpl->setStencilAttachment(mStencilbuffer);
} }
else else
{ {
...@@ -601,8 +620,10 @@ DefaultFramebuffer::DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAtt ...@@ -601,8 +620,10 @@ DefaultFramebuffer::DefaultFramebuffer(rx::FramebufferImpl *impl, rx::DefaultAtt
setAttachment(GL_STENCIL, new DefaultAttachment(GL_STENCIL, stencilAttachment)); setAttachment(GL_STENCIL, new DefaultAttachment(GL_STENCIL, stencilAttachment));
} }
mDrawBufferStates[0] = GL_BACK; GLenum drawBufferState = GL_BACK;
mReadBufferState = GL_BACK; setDrawBuffers(1, &drawBufferState);
setReadBuffer(GL_BACK);
} }
} }
...@@ -72,6 +72,9 @@ class Framebuffer ...@@ -72,6 +72,9 @@ class Framebuffer
GLenum getDrawBufferState(unsigned int colorAttachment) const; GLenum getDrawBufferState(unsigned int colorAttachment) const;
void setDrawBuffers(size_t count, const GLenum *buffers); void setDrawBuffers(size_t count, const GLenum *buffers);
GLenum getReadBufferState() const;
void setReadBuffer(GLenum buffer);
bool isEnabledColorAttachment(unsigned int colorAttachment) const; bool isEnabledColorAttachment(unsigned int colorAttachment) const;
bool hasEnabledColorAttachment() const; bool hasEnabledColorAttachment() const;
bool hasStencil() const; bool hasStencil() const;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace gl namespace gl
{ {
class FramebufferAttachment;
struct Rectangle; struct Rectangle;
} }
...@@ -38,6 +39,14 @@ class FramebufferImpl ...@@ -38,6 +39,14 @@ class FramebufferImpl
public: public:
virtual ~FramebufferImpl() {}; virtual ~FramebufferImpl() {};
virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void setStencilAttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void setDrawBuffers(size_t count, const GLenum *buffers) = 0;
virtual void setReadBuffer(GLenum buffer) = 0;
virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0; virtual gl::Error invalidate(size_t count, const GLenum *attachments) = 0;
virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0; virtual gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) = 0;
}; };
......
...@@ -74,6 +74,30 @@ FramebufferD3D::~FramebufferD3D() ...@@ -74,6 +74,30 @@ FramebufferD3D::~FramebufferD3D()
{ {
} }
void FramebufferD3D::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment)
{
}
void FramebufferD3D::setDepthttachment(const gl::FramebufferAttachment *attachment)
{
}
void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *attachment)
{
}
void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *attachment)
{
}
void FramebufferD3D::setDrawBuffers(size_t count, const GLenum *buffers)
{
}
void FramebufferD3D::setReadBuffer(GLenum buffer)
{
}
gl::Error FramebufferD3D::invalidate(size_t, const GLenum *) gl::Error FramebufferD3D::invalidate(size_t, const GLenum *)
{ {
// No-op in D3D // No-op in D3D
......
...@@ -47,6 +47,14 @@ class FramebufferD3D : public FramebufferImpl ...@@ -47,6 +47,14 @@ class FramebufferD3D : public FramebufferImpl
FramebufferD3D(RendererD3D *renderer); FramebufferD3D(RendererD3D *renderer);
virtual ~FramebufferD3D(); virtual ~FramebufferD3D();
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
void setDepthttachment(const gl::FramebufferAttachment *attachment) override;
void setStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void setDrawBuffers(size_t count, const GLenum *buffers) override;
void setReadBuffer(GLenum buffer) override;
gl::Error invalidate(size_t count, const GLenum *attachments) override; gl::Error invalidate(size_t count, const GLenum *attachments) override;
gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override; gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) 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