Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b8430dd

Browse files
vontureCommit Bot
authored and
Commit Bot
committed
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/1159171 Reviewed-by: Jamie Madill <[email protected]> Commit-Queue: Jamie Madill <[email protected]>
1 parent d69a5f1 commit b8430dd

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/libANGLE/Framebuffer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,31 +2344,32 @@ bool Framebuffer::hasTextureAttachment(const Texture *texture) const
23442344
{
23452345
if (!mAttachedTextures.valid())
23462346
{
2347-
std::set<const FramebufferAttachmentObject *> attachedTextures;
2347+
FramebufferTextureAttachmentVector attachedTextures;
23482348

23492349
for (const auto &colorAttachment : mState.mColorAttachments)
23502350
{
23512351
if (colorAttachment.isAttached() && colorAttachment.type() == GL_TEXTURE)
23522352
{
2353-
attachedTextures.insert(colorAttachment.getResource());
2353+
attachedTextures.push_back(colorAttachment.getResource());
23542354
}
23552355
}
23562356

23572357
if (mState.mDepthAttachment.isAttached() && mState.mDepthAttachment.type() == GL_TEXTURE)
23582358
{
2359-
attachedTextures.insert(mState.mDepthAttachment.getResource());
2359+
attachedTextures.push_back(mState.mDepthAttachment.getResource());
23602360
}
23612361

23622362
if (mState.mStencilAttachment.isAttached() &&
23632363
mState.mStencilAttachment.type() == GL_TEXTURE)
23642364
{
2365-
attachedTextures.insert(mState.mStencilAttachment.getResource());
2365+
attachedTextures.push_back(mState.mStencilAttachment.getResource());
23662366
}
23672367

23682368
mAttachedTextures = std::move(attachedTextures);
23692369
}
23702370

2371-
return (mAttachedTextures.value().count(texture) > 0);
2371+
return std::find(mAttachedTextures.value().begin(), mAttachedTextures.value().end(), texture) !=
2372+
mAttachedTextures.value().end();
23722373
}
23732374

23742375
} // namespace gl

src/libANGLE/Framebuffer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <vector>
1414

15+
#include "common/FixedVector.h"
1516
#include "common/Optional.h"
1617
#include "common/angleutils.h"
1718
#include "libANGLE/Constants.h"
@@ -422,7 +423,10 @@ class Framebuffer final : public angle::ObserverInterface,
422423
Optional<DirtyBits> mDirtyBitsGuard;
423424

424425
// A cache of attached textures for quick validation of feedback loops.
425-
mutable Optional<std::set<const FramebufferAttachmentObject *>> mAttachedTextures;
426+
using FramebufferTextureAttachmentVector =
427+
angle::FixedVector<const FramebufferAttachmentObject *,
428+
IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS>;
429+
mutable Optional<FramebufferTextureAttachmentVector> mAttachedTextures;
426430
};
427431

428432
} // namespace gl

0 commit comments

Comments
 (0)