xref: /aosp_15_r20/external/skia/src/gpu/graphite/RenderPassDesc.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 /*
2  * Copyright 2024 Google LLC
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef skgpu_graphite_RenderPassDesc_DEFINED
9 #define skgpu_graphite_RenderPassDesc_DEFINED
10 
11 #include "include/core/SkString.h"
12 #include "include/gpu/graphite/TextureInfo.h"
13 #include "src/gpu/graphite/ResourceTypes.h"
14 
15 #include "src/gpu/Swizzle.h"
16 
17 #include <array>
18 
19 namespace skgpu::graphite {
20 
21 class Caps;
22 
23 struct AttachmentDesc {
24     TextureInfo fTextureInfo;
25     LoadOp fLoadOp;
26     StoreOp fStoreOp;
27 
28     SkString toString() const;
29 };
30 
31 struct RenderPassDesc {
32     static RenderPassDesc Make(const Caps* caps,
33                                const TextureInfo& targetInfo,
34                                LoadOp loadOp,
35                                StoreOp storeOp,
36                                SkEnumBitMask<DepthStencilFlags> depthStencilFlags,
37                                const std::array<float, 4>& clearColor,
38                                bool requiresMSAA,
39                                Swizzle writeSwizzle);
40 
41     AttachmentDesc fColorAttachment;
42     std::array<float, 4> fClearColor;
43     AttachmentDesc fColorResolveAttachment;
44 
45     AttachmentDesc fDepthStencilAttachment;
46     float fClearDepth;
47     uint32_t fClearStencil;
48 
49     Swizzle fWriteSwizzle;
50 
51     // This samples count usually matches fColorAttachment & fDepthStencilAttachment's samples
52     // count. The only exceptional case is when multisampled render to single sampled is used. In
53     // that case, the fColorAttachment's samples count will be 1 and fSampleCount will be > 1.
54     uint32_t fSampleCount;
55 
56     SkString toString() const;
57     // Only includes fixed state relevant to pipeline creation
58     SkString toPipelineLabel() const;
59 
60     // TODO:
61     // * bounds (TBD whether exact bounds vs. granular)
62     // * input attachments
63     // * subpass makeup information
64 };
65 
66 } // namespace skgpu::graphite
67 
68 #endif // skgpu_graphite_RenderPassDesc_DEFINED
69