Commit b8430dd7 by Geoff Lang Committed by Commit Bot

Use FixedVector for storing textures referenced by a framebuffer.

This improves the performance of Framebuffer::hasTextureAttachment 3X. BUG=angleproject:2188 Change-Id: I6acc7f4440fe0232438182274d7bba6075530f38 Reviewed-on: https://chromium-review.googlesource.com/1159171Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent d69a5f12
......@@ -2344,31 +2344,32 @@ bool Framebuffer::hasTextureAttachment(const Texture *texture) const
{
if (!mAttachedTextures.valid())
{
std::set<const FramebufferAttachmentObject *> attachedTextures;
FramebufferTextureAttachmentVector attachedTextures;
for (const auto &colorAttachment : mState.mColorAttachments)
{
if (colorAttachment.isAttached() && colorAttachment.type() == GL_TEXTURE)
{
attachedTextures.insert(colorAttachment.getResource());
attachedTextures.push_back(colorAttachment.getResource());
}
}
if (mState.mDepthAttachment.isAttached() && mState.mDepthAttachment.type() == GL_TEXTURE)
{
attachedTextures.insert(mState.mDepthAttachment.getResource());
attachedTextures.push_back(mState.mDepthAttachment.getResource());
}
if (mState.mStencilAttachment.isAttached() &&
mState.mStencilAttachment.type() == GL_TEXTURE)
{
attachedTextures.insert(mState.mStencilAttachment.getResource());
attachedTextures.push_back(mState.mStencilAttachment.getResource());
}
mAttachedTextures = std::move(attachedTextures);
}
return (mAttachedTextures.value().count(texture) > 0);
return std::find(mAttachedTextures.value().begin(), mAttachedTextures.value().end(), texture) !=
mAttachedTextures.value().end();
}
} // namespace gl
......@@ -12,6 +12,7 @@
#include <vector>
#include "common/FixedVector.h"
#include "common/Optional.h"
#include "common/angleutils.h"
#include "libANGLE/Constants.h"
......@@ -422,7 +423,10 @@ class Framebuffer final : public angle::ObserverInterface,
Optional<DirtyBits> mDirtyBitsGuard;
// A cache of attached textures for quick validation of feedback loops.
mutable Optional<std::set<const FramebufferAttachmentObject *>> mAttachedTextures;
using FramebufferTextureAttachmentVector =
angle::FixedVector<const FramebufferAttachmentObject *,
IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS>;
mutable Optional<FramebufferTextureAttachmentVector> mAttachedTextures;
};
} // namespace gl
......
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