Store value types for FBO attachments.
*re-land with fix for Mac*
This prevents us from re-allocating FBO attachments every set.
This change requires quite a bit of refactoring.
BUG=angleproject:963
Change-Id: Ia1f83e3c427d446ddbe16c6703db136942149e91
Reviewed-on: https://chromium-review.googlesource.com/266691
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/FramebufferD3D.cpp b/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
index 5dbc102..0006ba5 100644
--- a/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
+++ b/src/libANGLE/renderer/d3d/FramebufferD3D.cpp
@@ -324,15 +324,15 @@
const auto &colorAttachments = mData.getColorAttachments();
for (size_t colorAttachment = 0; colorAttachment < colorAttachments.size(); colorAttachment++)
{
- const gl::FramebufferAttachment *attachment = colorAttachments[colorAttachment];
- if (attachment != nullptr)
+ const gl::FramebufferAttachment &attachment = colorAttachments[colorAttachment];
+ if (attachment.isAttached())
{
for (size_t prevColorAttachment = 0; prevColorAttachment < colorAttachment; prevColorAttachment++)
{
- const gl::FramebufferAttachment *prevAttachment = colorAttachments[prevColorAttachment];
- if (prevAttachment != nullptr &&
- (attachment->id() == prevAttachment->id() &&
- attachment->type() == prevAttachment->type()))
+ const gl::FramebufferAttachment &prevAttachment = colorAttachments[prevColorAttachment];
+ if (prevAttachment.isAttached() &&
+ (attachment.id() == prevAttachment.id() &&
+ attachment.type() == prevAttachment.type()))
{
return GL_FRAMEBUFFER_UNSUPPORTED;
}
@@ -355,15 +355,16 @@
const auto &colorAttachments = mData.getColorAttachments();
const auto &drawBufferStates = mData.getDrawBufferStates();
+
for (size_t attachmentIndex = 0; attachmentIndex < colorAttachments.size(); ++attachmentIndex)
{
GLenum drawBufferState = drawBufferStates[attachmentIndex];
- const gl::FramebufferAttachment *colorAttachment = colorAttachments[attachmentIndex];
+ const gl::FramebufferAttachment &colorAttachment = colorAttachments[attachmentIndex];
- if (colorAttachment != nullptr && drawBufferState != GL_NONE)
+ if (colorAttachment.isAttached() && drawBufferState != GL_NONE)
{
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + attachmentIndex));
- mColorAttachmentsForRender.push_back(colorAttachment);
+ mColorAttachmentsForRender.push_back(&colorAttachment);
}
else if (!workarounds.mrtPerfWorkaround)
{