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, ...@@ -604,38 +604,32 @@ void Framebuffer::setAttachment(GLenum type,
mData.mDepthAttachment.detach(); mData.mDepthAttachment.detach();
mData.mStencilAttachment.detach(); mData.mStencilAttachment.detach();
} }
mImpl->setDepthStencilAttachment(&mData.mDepthAttachment); mImpl->onUpdateDepthStencilAttachment();
} }
else else
{ {
FramebufferAttachment *attachment = nullptr;
switch (binding) switch (binding)
{ {
case GL_DEPTH: case GL_DEPTH:
case GL_DEPTH_ATTACHMENT: case GL_DEPTH_ATTACHMENT:
attachment = &mData.mDepthAttachment; mData.mDepthAttachment.attach(type, binding, textureIndex, resource);
attachment->attach(type, binding, textureIndex, resource); mImpl->onUpdateDepthAttachment();
mImpl->setDepthAttachment(attachment);
break; break;
case GL_STENCIL: case GL_STENCIL:
case GL_STENCIL_ATTACHMENT: case GL_STENCIL_ATTACHMENT:
attachment = &mData.mStencilAttachment; mData.mStencilAttachment.attach(type, binding, textureIndex, resource);
attachment->attach(type, binding, textureIndex, resource); mImpl->onUpdateStencilAttachment();
mImpl->setStencilAttachment(attachment);
break; break;
case GL_BACK: case GL_BACK:
attachment = &mData.mColorAttachments[0]; mData.mColorAttachments[0].attach(type, binding, textureIndex, resource);
attachment->attach(type, binding, textureIndex, resource); mImpl->onUpdateColorAttachment(0);
mImpl->setColorAttachment(0, attachment);
break; break;
default: default:
{ {
size_t colorIndex = binding - GL_COLOR_ATTACHMENT0; size_t colorIndex = binding - GL_COLOR_ATTACHMENT0;
ASSERT(colorIndex < mData.mColorAttachments.size()); ASSERT(colorIndex < mData.mColorAttachments.size());
attachment = &mData.mColorAttachments[colorIndex]; mData.mColorAttachments[colorIndex].attach(type, binding, textureIndex, resource);
attachment->attach(type, binding, textureIndex, resource); mImpl->onUpdateColorAttachment(colorIndex);
mImpl->setColorAttachment(colorIndex, attachment);
} }
break; break;
} }
......
...@@ -31,10 +31,10 @@ class FramebufferImpl : angle::NonCopyable ...@@ -31,10 +31,10 @@ class FramebufferImpl : angle::NonCopyable
explicit FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { } explicit FramebufferImpl(const gl::Framebuffer::Data &data) : mData(data) { }
virtual ~FramebufferImpl() { } virtual ~FramebufferImpl() { }
virtual void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) = 0; virtual void onUpdateColorAttachment(size_t index) = 0;
virtual void setDepthAttachment(const gl::FramebufferAttachment *attachment) = 0; virtual void onUpdateDepthAttachment() = 0;
virtual void setStencilAttachment(const gl::FramebufferAttachment *attachment) = 0; virtual void onUpdateStencilAttachment() = 0;
virtual void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) = 0; virtual void onUpdateDepthStencilAttachment() = 0;
virtual void setDrawBuffers(size_t count, const GLenum *buffers) = 0; virtual void setDrawBuffers(size_t count, const GLenum *buffers) = 0;
virtual void setReadBuffer(GLenum buffer) = 0; virtual void setReadBuffer(GLenum buffer) = 0;
......
...@@ -97,20 +97,20 @@ FramebufferD3D::~FramebufferD3D() ...@@ -97,20 +97,20 @@ FramebufferD3D::~FramebufferD3D()
{ {
} }
void FramebufferD3D::setColorAttachment(size_t, const gl::FramebufferAttachment *) void FramebufferD3D::onUpdateColorAttachment(size_t /*index*/)
{ {
mInvalidateColorAttachmentCache = true; 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 ...@@ -58,10 +58,10 @@ class FramebufferD3D : public FramebufferImpl
FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer); FramebufferD3D(const gl::Framebuffer::Data &data, RendererD3D *renderer);
virtual ~FramebufferD3D(); virtual ~FramebufferD3D();
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override; void onUpdateColorAttachment(size_t index) override;
void setDepthAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateDepthAttachment() override;
void setStencilAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateStencilAttachment() override;
void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateDepthStencilAttachment() override;
void setDrawBuffers(size_t count, const GLenum *buffers) override; void setDrawBuffers(size_t count, const GLenum *buffers) override;
void setReadBuffer(GLenum buffer) override; void setReadBuffer(GLenum buffer) override;
......
...@@ -93,39 +93,47 @@ static void BindFramebufferAttachment(const FunctionsGL *functions, GLenum attac ...@@ -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) if (mFramebufferID != 0)
{ {
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); 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) if (mFramebufferID != 0)
{ {
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); 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) if (mFramebufferID != 0)
{ {
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); 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) if (mFramebufferID != 0)
{ {
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); 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 ...@@ -23,10 +23,10 @@ class FramebufferGL : public FramebufferImpl
FramebufferGL(const gl::Framebuffer::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager, bool isDefault); FramebufferGL(const gl::Framebuffer::Data &data, const FunctionsGL *functions, StateManagerGL *stateManager, bool isDefault);
~FramebufferGL() override; ~FramebufferGL() override;
void setColorAttachment(size_t index, const gl::FramebufferAttachment *attachment) override; void onUpdateColorAttachment(size_t index) override;
void setDepthAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateDepthAttachment() override;
void setStencilAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateStencilAttachment() override;
void setDepthStencilAttachment(const gl::FramebufferAttachment *attachment) override; void onUpdateDepthStencilAttachment() override;
void setDrawBuffers(size_t count, const GLenum *buffers) override; void setDrawBuffers(size_t count, const GLenum *buffers) override;
void setReadBuffer(GLenum buffer) 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