Commit 7d75e2b7 by Jamie Madill

Simplify message to FBO Impls of attachment changes.

We don't need to pass attachment pointers, since they are now value types, and no longer change their address. BUG=angleproject:963 Change-Id: I02cdce0886512cc847930f61c5bfb62fc1d7cd1a Reviewed-on: https://chromium-review.googlesource.com/265938Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 2e295e23
......@@ -604,38 +604,32 @@ void Framebuffer::setAttachment(GLenum type,
mData.mDepthAttachment.detach();
mData.mStencilAttachment.detach();
}
mImpl->setDepthStencilAttachment(&mData.mDepthAttachment);
mImpl->onUpdateDepthStencilAttachment();
}
else
{
FramebufferAttachment *attachment = nullptr;
switch (binding)
{
case GL_DEPTH:
case GL_DEPTH_ATTACHMENT:
attachment = &mData.mDepthAttachment;
attachment->attach(type, binding, textureIndex, resource);
mImpl->setDepthAttachment(attachment);
mData.mDepthAttachment.attach(type, binding, textureIndex, resource);
mImpl->onUpdateDepthAttachment();
break;
case GL_STENCIL:
case GL_STENCIL_ATTACHMENT:
attachment = &mData.mStencilAttachment;
attachment->attach(type, binding, textureIndex, resource);
mImpl->setStencilAttachment(attachment);
mData.mStencilAttachment.attach(type, binding, textureIndex, resource);
mImpl->onUpdateStencilAttachment();
break;
case GL_BACK:
attachment = &mData.mColorAttachments[0];
attachment->attach(type, binding, textureIndex, resource);
mImpl->setColorAttachment(0, attachment);
mData.mColorAttachments[0].attach(type, binding, textureIndex, resource);
mImpl->onUpdateColorAttachment(0);
break;
default:
{
size_t colorIndex = binding - GL_COLOR_ATTACHMENT0;
ASSERT(colorIndex < mData.mColorAttachments.size());
attachment = &mData.mColorAttachments[colorIndex];
attachment->attach(type, binding, textureIndex, resource);
mImpl->setColorAttachment(colorIndex, attachment);
mData.mColorAttachments[colorIndex].attach(type, binding, textureIndex, resource);
mImpl->onUpdateColorAttachment(colorIndex);
}
break;
}
......
......@@ -31,10 +31,10 @@ class FramebufferImpl : angle::NonCopyable
explicit FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { }
virtual ~FramebufferImpl() { }
virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthAttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void setStencilAttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) = 0;
virtual void onUpdateColorAttachment(size_t index) = 0;
virtual void onUpdateDepthAttachment() = 0;
virtual void onUpdateStencilAttachment() = 0;
virtual void onUpdateDepthStencilAttachment() = 0;
virtual void setDrawBuffers(size_t count, const GLenum *buffers) = 0;
virtual void setReadBuffer(GLenum buffer) = 0;
......
......@@ -97,20 +97,20 @@ FramebufferD3D::~FramebufferD3D()
{
}
void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *)
void FramebufferD3D::onUpdateColorAttachment(size_t /*index*/)
{
mInvalidateColorAttachmentCache = true;
}
void FramebufferD3D::setDepthAttachment(const gl::FramebufferAttachment *)
void FramebufferD3D::onUpdateDepthAttachment()
{
}
void FramebufferD3D::setStencilAttachment(const gl::FramebufferAttachment *)
void FramebufferD3D::onUpdateStencilAttachment()
{
}
void FramebufferD3D::setDepthStencilAttachment(const gl::FramebufferAttachment *)
void FramebufferD3D::onUpdateDepthStencilAttachment()
{
}
......
......@@ -58,10 +58,10 @@ class FramebufferD3D : public FramebufferImpl
FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer);
virtual ~FramebufferD3D();
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
void setDepthAttachment(const gl::FramebufferAttachment *attachment) override;
void setStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void onUpdateColorAttachment(size_t index) override;
void onUpdateDepthAttachment() override;
void onUpdateStencilAttachment() override;
void onUpdateDepthStencilAttachment() override;
void setDrawBuffers(size_t count, const GLenum *buffers) override;
void setReadBuffer(GLenum buffer) override;
......
......@@ -93,39 +93,47 @@ static void BindFramebufferAttachment(const FunctionsGL *functions, GLenum attac
}
}
void FramebufferGL::setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment)
void FramebufferGL::onUpdateColorAttachment(size_t index)
{
if (mFramebufferID != 0)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
BindFramebufferAttachment(mFunctions, GL_COLOR_ATTACHMENT0 + index, attachment);
BindFramebufferAttachment(mFunctions,
GL_COLOR_ATTACHMENT0 + index,
mData.getColorAttachment(static_cast<unsigned int>(index)));
}
}
void FramebufferGL::setDepthAttachment(const gl::FramebufferAttachment *attachment)
void FramebufferGL::onUpdateDepthAttachment()
{
if (mFramebufferID != 0)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
BindFramebufferAttachment(mFunctions, GL_DEPTH_ATTACHMENT, attachment);
BindFramebufferAttachment(mFunctions,
GL_DEPTH_ATTACHMENT,
mData.getDepthAttachment());
}
}
void FramebufferGL::setStencilAttachment(const gl::FramebufferAttachment *attachment)
void FramebufferGL::onUpdateStencilAttachment()
{
if (mFramebufferID != 0)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
BindFramebufferAttachment(mFunctions, GL_STENCIL_ATTACHMENT, attachment);
BindFramebufferAttachment(mFunctions,
GL_STENCIL_ATTACHMENT,
mData.getStencilAttachment());
}
}
void FramebufferGL::setDepthStencilAttachment(const gl::FramebufferAttachment *attachment)
void FramebufferGL::onUpdateDepthStencilAttachment()
{
if (mFramebufferID != 0)
{
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
BindFramebufferAttachment(mFunctions, GL_DEPTH_STENCIL_ATTACHMENT, attachment);
BindFramebufferAttachment(mFunctions,
GL_DEPTH_STENCIL_ATTACHMENT,
mData.getDepthStencilAttachment());
}
}
......
......@@ -23,10 +23,10 @@ class FramebufferGL : public FramebufferImpl
FramebufferGL(const gl::Framebuffer::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager, bool isDefault);
~FramebufferGL() override;
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override;
void setDepthAttachment(const gl::FramebufferAttachment *attachment) override;
void setStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) override;
void onUpdateColorAttachment(size_t index) override;
void onUpdateDepthAttachment() override;
void onUpdateStencilAttachment() override;
void onUpdateDepthStencilAttachment() override;
void setDrawBuffers(size_t count, const GLenum *buffers) override;
void setReadBuffer(GLenum buffer) 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