Commit 19fa1c6f by Jamie Madill Committed by Commit Bot

Return an Error from Framebuffer::syncState.

This pipes errors up from the Impl to the top level. There are still a few places were error swallowing is needed, because the Framebuffer API doesn't support returning an error. Bug: angleproject:2372 Change-Id: Idc06bda1817fd28075940f69874d8b6ba69194f9 Reviewed-on: https://chromium-review.googlesource.com/954290 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent 66546be2
......@@ -1199,7 +1199,8 @@ GLenum Framebuffer::checkStatusImpl(const Context *context)
}
}
syncState(context);
// TODO(jmadill): Don't swallow an error here. http://anglebug.com/2372
ANGLE_SWALLOW_ERR(syncState(context));
if (!mImpl->checkStatus(context))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
......@@ -1781,12 +1782,12 @@ void Framebuffer::resetAttachment(const Context *context, GLenum binding)
setAttachment(context, GL_NONE, binding, ImageIndex::MakeInvalid(), nullptr);
}
void Framebuffer::syncState(const Context *context)
Error Framebuffer::syncState(const Context *context)
{
if (mDirtyBits.any())
{
mDirtyBitsGuard = mDirtyBits;
mImpl->syncState(context, mDirtyBits);
ANGLE_TRY(mImpl->syncState(context, mDirtyBits));
mDirtyBits.reset();
if (mId != 0)
{
......@@ -1794,6 +1795,7 @@ void Framebuffer::syncState(const Context *context)
}
mDirtyBitsGuard.reset();
}
return NoError();
}
void Framebuffer::onSubjectStateChange(const Context *context,
......
......@@ -305,7 +305,7 @@ class Framebuffer final : public angle::ObserverInterface, public LabeledObject
using DirtyBits = angle::BitSet<DIRTY_BIT_MAX>;
bool hasAnyDirtyBit() const { return mDirtyBits.any(); }
void syncState(const Context *context);
Error syncState(const Context *context);
// Observer implementation
void onSubjectStateChange(const Context *context,
......
......@@ -2243,11 +2243,11 @@ Error State::syncDirtyObjects(const Context *context, const DirtyObjects &bitset
{
case DIRTY_OBJECT_READ_FRAMEBUFFER:
ASSERT(mReadFramebuffer);
mReadFramebuffer->syncState(context);
ANGLE_TRY(mReadFramebuffer->syncState(context));
break;
case DIRTY_OBJECT_DRAW_FRAMEBUFFER:
ASSERT(mDrawFramebuffer);
mDrawFramebuffer->syncState(context);
ANGLE_TRY(mDrawFramebuffer->syncState(context));
break;
case DIRTY_OBJECT_VERTEX_ARRAY:
ASSERT(mVertexArray);
......
......@@ -80,8 +80,8 @@ class FramebufferImpl : angle::NonCopyable
virtual bool checkStatus(const gl::Context *context) const = 0;
virtual void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) = 0;
virtual gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) = 0;
virtual gl::Error getSamplePosition(size_t index, GLfloat *xy) const = 0;
......
......@@ -50,7 +50,7 @@ class MockFramebufferImpl : public rx::FramebufferImpl
MOCK_CONST_METHOD1(checkStatus, bool(const gl::Context *));
MOCK_METHOD2(syncState, void(const gl::Context *, const gl::Framebuffer::DirtyBits &));
MOCK_METHOD2(syncState, gl::Error(const gl::Context *, const gl::Framebuffer::DirtyBits &));
MOCK_METHOD0(destructor, void());
};
......
......@@ -26,9 +26,9 @@ class RenderTargetCache final : angle::NonCopyable
RenderTargetCache();
~RenderTargetCache();
void update(const gl::Context *context,
const gl::FramebufferState &state,
const gl::Framebuffer::DirtyBits &dirtyBits);
gl::Error update(const gl::Context *context,
const gl::FramebufferState &state,
const gl::Framebuffer::DirtyBits &dirtyBits);
using RenderTargetArray = gl::AttachmentArray<RenderTargetT *>;
......@@ -38,15 +38,15 @@ class RenderTargetCache final : angle::NonCopyable
RenderTargetT *getColorRead(const gl::FramebufferState &state) const;
private:
void updateCachedRenderTarget(const gl::Context *context,
const gl::FramebufferAttachment *attachment,
RenderTargetT **cachedRenderTarget);
gl::Error updateCachedRenderTarget(const gl::Context *context,
const gl::FramebufferAttachment *attachment,
RenderTargetT **cachedRenderTarget);
void updateColorRenderTarget(const gl::Context *context,
const gl::FramebufferState &state,
size_t colorIndex);
void updateDepthStencilRenderTarget(const gl::Context *context,
const gl::FramebufferState &state);
gl::Error updateColorRenderTarget(const gl::Context *context,
const gl::FramebufferState &state,
size_t colorIndex);
gl::Error updateDepthStencilRenderTarget(const gl::Context *context,
const gl::FramebufferState &state);
gl::AttachmentArray<RenderTargetT *> mColorRenderTargets;
// We only support a single Depth/Stencil RenderTarget currently.
......@@ -65,9 +65,9 @@ RenderTargetCache<RenderTargetT>::~RenderTargetCache()
}
template <typename RenderTargetT>
void RenderTargetCache<RenderTargetT>::update(const gl::Context *context,
const gl::FramebufferState &state,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error RenderTargetCache<RenderTargetT>::update(const gl::Context *context,
const gl::FramebufferState &state,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
for (auto dirtyBit : dirtyBits)
{
......@@ -75,7 +75,7 @@ void RenderTargetCache<RenderTargetT>::update(const gl::Context *context,
{
case gl::Framebuffer::DIRTY_BIT_DEPTH_ATTACHMENT:
case gl::Framebuffer::DIRTY_BIT_STENCIL_ATTACHMENT:
updateDepthStencilRenderTarget(context, state);
ANGLE_TRY(updateDepthStencilRenderTarget(context, state));
break;
case gl::Framebuffer::DIRTY_BIT_DRAW_BUFFERS:
case gl::Framebuffer::DIRTY_BIT_READ_BUFFER:
......@@ -90,11 +90,13 @@ void RenderTargetCache<RenderTargetT>::update(const gl::Context *context,
dirtyBit < gl::Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_MAX);
size_t colorIndex =
static_cast<size_t>(dirtyBit - gl::Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0);
updateColorRenderTarget(context, state, colorIndex);
ANGLE_TRY(updateColorRenderTarget(context, state, colorIndex));
break;
}
}
}
return gl::NoError();
}
template <typename RenderTargetT>
......@@ -110,25 +112,26 @@ RenderTargetT *RenderTargetCache<RenderTargetT>::getDepthStencil() const
}
template <typename RenderTargetT>
void RenderTargetCache<RenderTargetT>::updateColorRenderTarget(const gl::Context *context,
const gl::FramebufferState &state,
size_t colorIndex)
gl::Error RenderTargetCache<RenderTargetT>::updateColorRenderTarget(
const gl::Context *context,
const gl::FramebufferState &state,
size_t colorIndex)
{
updateCachedRenderTarget(context, state.getColorAttachment(colorIndex),
&mColorRenderTargets[colorIndex]);
return updateCachedRenderTarget(context, state.getColorAttachment(colorIndex),
&mColorRenderTargets[colorIndex]);
}
template <typename RenderTargetT>
void RenderTargetCache<RenderTargetT>::updateDepthStencilRenderTarget(
gl::Error RenderTargetCache<RenderTargetT>::updateDepthStencilRenderTarget(
const gl::Context *context,
const gl::FramebufferState &state)
{
updateCachedRenderTarget(context, state.getDepthOrStencilAttachment(),
&mDepthStencilRenderTarget);
return updateCachedRenderTarget(context, state.getDepthOrStencilAttachment(),
&mDepthStencilRenderTarget);
}
template <typename RenderTargetT>
void RenderTargetCache<RenderTargetT>::updateCachedRenderTarget(
gl::Error RenderTargetCache<RenderTargetT>::updateCachedRenderTarget(
const gl::Context *context,
const gl::FramebufferAttachment *attachment,
RenderTargetT **cachedRenderTarget)
......@@ -137,11 +140,10 @@ void RenderTargetCache<RenderTargetT>::updateCachedRenderTarget(
if (attachment)
{
ASSERT(attachment->isAttached());
// TODO(jmadill): Don't swallow this error.
ANGLE_SWALLOW_ERR(attachment->getRenderTarget(context, &newRenderTarget));
ANGLE_TRY(attachment->getRenderTarget(context, &newRenderTarget));
}
*cachedRenderTarget = newRenderTarget;
return gl::NoError();
}
template <typename RenderTargetT>
......
......@@ -319,12 +319,12 @@ bool FramebufferD3D::checkStatus(const gl::Context *context) const
return true;
}
void FramebufferD3D::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error FramebufferD3D::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
if (!mColorAttachmentsForRender.valid())
{
return;
return gl::NoError();
}
for (auto dirtyBit : dirtyBits)
......@@ -336,6 +336,8 @@ void FramebufferD3D::syncState(const gl::Context *context,
mColorAttachmentsForRender.reset();
}
}
return gl::NoError();
}
const gl::AttachmentList &FramebufferD3D::getColorAttachmentsForRender(const gl::Context *context)
......
......@@ -97,8 +97,8 @@ class FramebufferD3D : public FramebufferImpl
bool checkStatus(const gl::Context *context) const override;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
const gl::AttachmentList &getColorAttachmentsForRender(const gl::Context *context);
......
......@@ -357,12 +357,11 @@ GLenum Framebuffer11::getRenderTargetImplementationFormat(RenderTargetD3D *rende
return renderTarget11->getFormatSet().format().fboImplementationInternalFormat;
}
void Framebuffer11::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error Framebuffer11::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
mRenderTargetCache.update(context, mState, dirtyBits);
FramebufferD3D::syncState(context, dirtyBits);
ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits));
ANGLE_TRY(FramebufferD3D::syncState(context, dirtyBits));
// Call this last to allow the state manager to take advantage of the cached render targets.
mRenderer->getStateManager()->invalidateRenderTarget();
......@@ -372,6 +371,8 @@ void Framebuffer11::syncState(const gl::Context *context,
{
mRenderer->getStateManager()->invalidateViewport(context);
}
return gl::NoError();
}
gl::Error Framebuffer11::getSamplePosition(size_t index, GLfloat *xy) const
......
......@@ -36,8 +36,8 @@ class Framebuffer11 : public FramebufferD3D
// Invalidate the cached swizzles of all bound texture attachments.
gl::Error markAttachmentsDirty(const gl::Context *context) const;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
const gl::AttachmentArray<RenderTarget11 *> &getCachedColorRenderTargets() const
{
......
......@@ -408,10 +408,11 @@ gl::Error Framebuffer9::getSamplePosition(size_t index, GLfloat *xy) const
return gl::InternalError() << "getSamplePosition is unsupported to d3d9.";
}
void Framebuffer9::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error Framebuffer9::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
FramebufferD3D::syncState(context, dirtyBits);
mRenderTargetCache.update(context, mState, dirtyBits);
ANGLE_TRY(FramebufferD3D::syncState(context, dirtyBits));
ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits));
return gl::NoError();
}
} // namespace rx
......@@ -34,8 +34,8 @@ class Framebuffer9 : public FramebufferD3D
gl::Error getSamplePosition(size_t index, GLfloat *xy) const override;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
const gl::AttachmentArray<RenderTarget9 *> &getCachedColorRenderTargets() const
{
......
......@@ -606,12 +606,13 @@ bool FramebufferGL::checkStatus(const gl::Context *context) const
return (status == GL_FRAMEBUFFER_COMPLETE);
}
void FramebufferGL::syncState(const gl::Context *context, const Framebuffer::DirtyBits &dirtyBits)
gl::Error FramebufferGL::syncState(const gl::Context *context,
const Framebuffer::DirtyBits &dirtyBits)
{
// Don't need to sync state for the default FBO.
if (mIsDefault)
{
return;
return gl::NoError();
}
mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID);
......@@ -698,6 +699,8 @@ void FramebufferGL::syncState(const gl::Context *context, const Framebuffer::Dir
mStateManager->updateMultiviewBaseViewLayerIndexUniform(context->getGLState().getProgram(),
getState());
}
return gl::NoError();
}
GLuint FramebufferGL::getFramebufferID() const
......
......@@ -89,8 +89,8 @@ class FramebufferGL : public FramebufferImpl
bool checkStatus(const gl::Context *context) const override;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
GLuint getFramebufferID() const;
bool isDefault() const;
......
......@@ -185,9 +185,10 @@ bool FramebufferNULL::checkStatus(const gl::Context *context) const
return true;
}
void FramebufferNULL::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error FramebufferNULL::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
return gl::NoError();
}
gl::Error FramebufferNULL::getSamplePosition(size_t index, GLfloat *xy) const
......
......@@ -65,8 +65,8 @@ class FramebufferNULL : public FramebufferImpl
bool checkStatus(const gl::Context *context) const override;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error getSamplePosition(size_t index, GLfloat *xy) const override;
};
......
......@@ -319,15 +319,14 @@ bool FramebufferVk::checkStatus(const gl::Context *context) const
return true;
}
void FramebufferVk::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
gl::Error FramebufferVk::syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits)
{
ContextVk *contextVk = vk::GetImpl(context);
RendererVk *renderer = contextVk->getRenderer();
ASSERT(dirtyBits.any());
mRenderTargetCache.update(context, mState, dirtyBits);
ANGLE_TRY(mRenderTargetCache.update(context, mState, dirtyBits));
mRenderPassDesc.reset();
renderer->releaseResource(*this, &mFramebuffer);
......@@ -336,6 +335,8 @@ void FramebufferVk::syncState(const gl::Context *context,
mLastRenderNodeSerial = Serial();
contextVk->invalidateCurrentPipeline();
return gl::NoError();
}
const vk::RenderPassDesc &FramebufferVk::getRenderPassDesc(const gl::Context *context)
......
......@@ -80,8 +80,8 @@ class FramebufferVk : public FramebufferImpl, public ResourceVk
bool checkStatus(const gl::Context *context) const override;
void syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error syncState(const gl::Context *context,
const gl::Framebuffer::DirtyBits &dirtyBits) override;
gl::Error getSamplePosition(size_t index, GLfloat *xy) const 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