• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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_AttachmentTypes_DEFINED
9 #define skgpu_graphite_AttachmentTypes_DEFINED
10 
11 #include "include/gpu/graphite/GraphiteTypes.h"
12 #include "include/gpu/graphite/TextureInfo.h"
13 #include "src/gpu/graphite/ResourceTypes.h"
14 
15 #include <array>
16 
17 namespace skgpu::graphite {
18 
19 class Caps;
20 
21 /**
22  * This enum is used to specify the load operation to be used when a RenderPass begins execution
23  */
24 enum class LoadOp : uint8_t {
25     kLoad,
26     kClear,
27     kDiscard,
28 
29     kLast = kDiscard
30 };
31 inline static constexpr int kLoadOpCount = (int)(LoadOp::kLast) + 1;
32 
33 /**
34  * This enum is used to specify the store operation to be used when a RenderPass ends execution.
35  */
36 enum class StoreOp : uint8_t {
37     kStore,
38     kDiscard,
39 
40     kLast = kDiscard
41 };
42 inline static constexpr int kStoreOpCount = (int)(StoreOp::kLast) + 1;
43 
44 struct AttachmentDesc {
45     TextureInfo fTextureInfo;
46     LoadOp fLoadOp;
47     StoreOp fStoreOp;
48 };
49 
50 struct RenderPassDesc {
51     static RenderPassDesc Make(const Caps* caps,
52                                const TextureInfo& targetInfo,
53                                LoadOp loadOp,
54                                StoreOp storeOp,
55                                SkEnumBitMask<DepthStencilFlags> depthStencilFlags,
56                                const std::array<float, 4>& clearColor,
57                                bool requiresMSAA);
58 
59     AttachmentDesc fColorAttachment;
60     std::array<float, 4> fClearColor;
61     AttachmentDesc fColorResolveAttachment;
62 
63     AttachmentDesc fDepthStencilAttachment;
64     float fClearDepth;
65     uint32_t fClearStencil;
66 
67     // TODO:
68     // * bounds (TBD whether exact bounds vs. granular)
69     // * input attachments
70 };
71 
72 };  // namespace skgpu::graphite
73 
74 #endif // skgpu_graphite_AttachmentTypes_DEFINED
75