Hash :
44ce5887
Author :
Date :
2024-04-11T16:37:27
Allow the backend to do resource init for framebuffers. The frontend framebuffer would loop through attachments which needed to be initialized and call initializeContents on them individually. For the GL backend this is inefficient because each of these resources is bound to a scratch framebuffer and cleared when the entire original framebuffer could have been cleared at once. The frontend now accumulates a set of attachments that need to be cleared and sends it to the FramebufferImpl. The default FramebufferImpl does the old logic of calling initializeContents on each attachment. FramebufferGL has an optimized path to clear the whole framebuffer if possible. Bug: angleproject:8642 Change-Id: I574cd03307794a6c7b2666976784e4d4dca1d08c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5448552 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FramebufferImpl.cpp: Implements the class methods for FramebufferImpl.
#include "libANGLE/renderer/FramebufferImpl.h"
namespace rx
{
namespace
{
angle::Result InitAttachment(const gl::Context *context,
const gl::FramebufferAttachment *attachment)
{
ASSERT(attachment->isAttached());
if (attachment->initState() == gl::InitState::MayNeedInit)
{
ANGLE_TRY(attachment->initializeContents(context));
}
return angle::Result::Continue;
}
} // namespace
angle::Result FramebufferImpl::onLabelUpdate(const gl::Context *context)
{
return angle::Result::Continue;
}
angle::Result FramebufferImpl::ensureAttachmentsInitialized(
const gl::Context *context,
const gl::DrawBufferMask &colorAttachments,
bool depth,
bool stencil)
{
// Default implementation iterates over the attachments and individually initializes them
for (auto colorIndex : colorAttachments)
{
ANGLE_TRY(InitAttachment(context, mState.getColorAttachment(colorIndex)));
}
if (depth)
{
ANGLE_TRY(InitAttachment(context, mState.getDepthAttachment()));
}
if (stencil)
{
ANGLE_TRY(InitAttachment(context, mState.getStencilAttachment()));
}
return angle::Result::Continue;
}
} // namespace rx