Cleanups to FramebufferD3D.
With the new shared state structure, we can eliminate a lot of the
state tracking within the FramebufferD3D implementation.
BUG=angleproject:930
Change-Id: I0953e321bae3afe7cde7b73c55af62546665c890
Reviewed-on: https://chromium-review.googlesource.com/254101
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Framebuffer.cpp b/src/libANGLE/Framebuffer.cpp
index e7afb0a..767b024 100644
--- a/src/libANGLE/Framebuffer.cpp
+++ b/src/libANGLE/Framebuffer.cpp
@@ -54,6 +54,32 @@
SafeDelete(mStencilAttachment);
}
+FramebufferAttachment *Framebuffer::Data::getReadAttachment() const
+{
+ ASSERT(mReadBufferState == GL_BACK || (mReadBufferState >= GL_COLOR_ATTACHMENT0 && mReadBufferState <= GL_COLOR_ATTACHMENT15));
+ size_t readIndex = (mReadBufferState == GL_BACK ? 0 : static_cast<size_t>(mReadBufferState - GL_COLOR_ATTACHMENT0));
+ ASSERT(readIndex < mColorAttachments.size());
+ return mColorAttachments[readIndex];
+}
+
+FramebufferAttachment *Framebuffer::Data::getFirstColorAttachment() const
+{
+ for (FramebufferAttachment *colorAttachment : mColorAttachments)
+ {
+ if (colorAttachment != nullptr)
+ {
+ return colorAttachment;
+ }
+ }
+
+ return nullptr;
+}
+
+FramebufferAttachment *Framebuffer::Data::getDepthOrStencilAttachment() const
+{
+ return (mDepthAttachment != nullptr ? mDepthAttachment : mStencilAttachment);
+}
+
Framebuffer::Framebuffer(const Caps &caps, rx::Renderer *renderer, GLuint id)
: mData(caps),
mImpl(renderer->createFramebuffer(mData)),
@@ -111,34 +137,23 @@
FramebufferAttachment *Framebuffer::getDepthOrStencilbuffer() const
{
- return (mData.mDepthAttachment != nullptr ? mData.mDepthAttachment : mData.mStencilAttachment);
+ return mData.getDepthOrStencilAttachment();
}
FramebufferAttachment *Framebuffer::getReadColorbuffer() const
{
- size_t readIndex = (mData.mReadBufferState == GL_BACK ? 0 :
- static_cast<size_t>(mData.mReadBufferState - GL_COLOR_ATTACHMENT0));
- ASSERT(readIndex < mData.mColorAttachments.size());
- return mData.mColorAttachments[readIndex];
+ return mData.getReadAttachment();
}
GLenum Framebuffer::getReadColorbufferType() const
{
- FramebufferAttachment *readAttachment = getReadColorbuffer();
+ FramebufferAttachment *readAttachment = mData.getReadAttachment();
return (readAttachment ? readAttachment->type() : GL_NONE);
}
FramebufferAttachment *Framebuffer::getFirstColorbuffer() const
{
- for (FramebufferAttachment *colorAttachment : mData.mColorAttachments)
- {
- if (colorAttachment != nullptr)
- {
- return colorAttachment;
- }
- }
-
- return nullptr;
+ return mData.getFirstColorAttachment();
}
FramebufferAttachment *Framebuffer::getAttachment(GLenum attachment) const
@@ -529,27 +544,9 @@
mData.mDepthAttachment->id() == mData.mStencilAttachment->id());
}
-ColorbufferInfo Framebuffer::getColorbuffersForRender(const rx::Workarounds &workarounds) const
+AttachmentList Framebuffer::getColorAttachmentsForRender(const rx::Workarounds &workarounds) const
{
- ColorbufferInfo colorbuffersForRender;
-
- for (size_t attachmentIndex = 0; attachmentIndex < mData.mColorAttachments.size(); ++attachmentIndex)
- {
- GLenum drawBufferState = mData.mDrawBufferStates[attachmentIndex];
- FramebufferAttachment *colorAttachment = mData.mColorAttachments[attachmentIndex];
-
- if (colorAttachment != nullptr && drawBufferState != GL_NONE)
- {
- ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
- colorbuffersForRender.push_back(colorAttachment);
- }
- else if (!workarounds.mrtPerfWorkaround)
- {
- colorbuffersForRender.push_back(nullptr);
- }
- }
-
- return colorbuffersForRender;
+ return mImpl->getColorAttachmentsForRender(workarounds);
}
void Framebuffer::setTextureAttachment(GLenum attachment, Texture *texture, const ImageIndex &imageIndex)