void FramebufferGL::syncState(const Framebuffer::DirtyBits &dirtyBits) { // Don't need to sync state for the default FBO. if (mIsDefault) { return; } mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); for (auto dirtyBit : angle::IterateBitSet(dirtyBits)) { switch (dirtyBit) { case Framebuffer::DIRTY_BIT_DEPTH_ATTACHMENT: BindFramebufferAttachment(mFunctions, GL_DEPTH_ATTACHMENT, mState.getDepthAttachment()); break; case Framebuffer::DIRTY_BIT_STENCIL_ATTACHMENT: BindFramebufferAttachment(mFunctions, GL_STENCIL_ATTACHMENT, mState.getStencilAttachment()); break; case Framebuffer::DIRTY_BIT_DRAW_BUFFERS: { const auto &drawBuffers = mState.getDrawBufferStates(); mFunctions->drawBuffers(static_cast<GLsizei>(drawBuffers.size()), drawBuffers.data()); break; } case Framebuffer::DIRTY_BIT_READ_BUFFER: mFunctions->readBuffer(mState.getReadBufferState()); break; default: { ASSERT(Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0 == 0 && dirtyBit < Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_MAX); size_t index = static_cast<size_t>(dirtyBit - Framebuffer::DIRTY_BIT_COLOR_ATTACHMENT_0); BindFramebufferAttachment(mFunctions, static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + index), mState.getColorAttachment(index)); break; } } } }
void FramebufferGL::onUpdateColorAttachment(size_t index) { if (!mIsDefault) { mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); BindFramebufferAttachment(mFunctions, GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index), mData.getColorAttachment(static_cast<unsigned int>(index))); } }
void FramebufferGL::onUpdateDepthStencilAttachment() { if (!mIsDefault) { mStateManager->bindFramebuffer(GL_FRAMEBUFFER, mFramebufferID); BindFramebufferAttachment(mFunctions, GL_DEPTH_STENCIL_ATTACHMENT, mData.getDepthStencilAttachment()); } }