xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/FramebufferImpl.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2022 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // FramebufferImpl.cpp: Implements the class methods for FramebufferImpl.
7 
8 #include "libANGLE/renderer/FramebufferImpl.h"
9 
10 namespace rx
11 {
12 
13 namespace
14 {
InitAttachment(const gl::Context * context,const gl::FramebufferAttachment * attachment)15 angle::Result InitAttachment(const gl::Context *context,
16                              const gl::FramebufferAttachment *attachment)
17 {
18     ASSERT(attachment->isAttached());
19     if (attachment->initState() == gl::InitState::MayNeedInit)
20     {
21         ANGLE_TRY(attachment->initializeContents(context));
22     }
23     return angle::Result::Continue;
24 }
25 }  // namespace
26 
onLabelUpdate(const gl::Context * context)27 angle::Result FramebufferImpl::onLabelUpdate(const gl::Context *context)
28 {
29     return angle::Result::Continue;
30 }
31 
ensureAttachmentsInitialized(const gl::Context * context,const gl::DrawBufferMask & colorAttachments,bool depth,bool stencil)32 angle::Result FramebufferImpl::ensureAttachmentsInitialized(
33     const gl::Context *context,
34     const gl::DrawBufferMask &colorAttachments,
35     bool depth,
36     bool stencil)
37 {
38     // Default implementation iterates over the attachments and individually initializes them
39 
40     for (auto colorIndex : colorAttachments)
41     {
42         ANGLE_TRY(InitAttachment(context, mState.getColorAttachment(colorIndex)));
43     }
44 
45     if (depth)
46     {
47         ANGLE_TRY(InitAttachment(context, mState.getDepthAttachment()));
48     }
49 
50     if (stencil)
51     {
52         ANGLE_TRY(InitAttachment(context, mState.getStencilAttachment()));
53     }
54 
55     return angle::Result::Continue;
56 }
57 
58 }  // namespace rx
59