/src/skia/src/gpu/graphite/vk/VulkanRenderPass.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2023 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_VulkanRenderPass_DEFINED |
9 | | #define skgpu_graphite_VulkanRenderPass_DEFINED |
10 | | |
11 | | #include "src/gpu/graphite/Resource.h" |
12 | | |
13 | | #include "include/private/base/SkTArray.h" |
14 | | #include "src/gpu/graphite/vk/VulkanCommandBuffer.h" |
15 | | |
16 | | namespace skgpu::graphite { |
17 | | |
18 | | struct AttachmentDesc; |
19 | | struct RenderPassDesc; |
20 | | class VulkanCommandBuffer; |
21 | | class VulkanSharedContext; |
22 | | |
23 | | const static VkAttachmentStoreOp vkStoreOp[] { |
24 | | VK_ATTACHMENT_STORE_OP_STORE, |
25 | | VK_ATTACHMENT_STORE_OP_DONT_CARE |
26 | | }; |
27 | | const static VkAttachmentLoadOp vkLoadOp[] { |
28 | | VK_ATTACHMENT_LOAD_OP_LOAD, |
29 | | VK_ATTACHMENT_LOAD_OP_CLEAR, |
30 | | VK_ATTACHMENT_LOAD_OP_DONT_CARE |
31 | | }; |
32 | | |
33 | | /** |
34 | | * Wrapper around VkRenderPass. |
35 | | */ |
36 | | class VulkanRenderPass : public Resource { |
37 | | public: |
38 | | // Statically assign attachment indices until such information can be fetched from |
39 | | // graphite-level structures (likely RenderPassDesc) |
40 | | static constexpr int kColorAttachmentIdx = 0; |
41 | | static constexpr int kColorResolveAttachmentIdx = 1; |
42 | | static constexpr int kDepthStencilAttachmentIdx = 2; |
43 | | |
44 | | static constexpr int kMaxExpectedAttachmentCount = kDepthStencilAttachmentIdx + 1; |
45 | | |
46 | | // Methods to create compatible (needed when creating a framebuffer and graphics pipeline) or |
47 | | // full (needed when beginning a render pass from the command buffer) render passes and keys. |
48 | | static GraphiteResourceKey MakeRenderPassKey(const RenderPassDesc&, bool compatibleOnly); |
49 | | |
50 | | static sk_sp<VulkanRenderPass> MakeRenderPass(const VulkanSharedContext*, |
51 | | const RenderPassDesc&, |
52 | | bool compatibleOnly); |
53 | | |
54 | 0 | VkRenderPass renderPass() const { |
55 | 0 | SkASSERT(fRenderPass != VK_NULL_HANDLE); |
56 | 0 | return fRenderPass; |
57 | 0 | } Unexecuted instantiation: skgpu::graphite::VulkanRenderPass::renderPass() const Unexecuted instantiation: skgpu::graphite::VulkanRenderPass::renderPass() const |
58 | | |
59 | 0 | VkExtent2D granularity() { return fGranularity; } |
60 | | |
61 | 0 | const char* getResourceType() const override { return "Vulkan RenderPass"; } |
62 | | |
63 | | // Struct to store Vulkan information surrounding a RenderPassDesc |
64 | | struct VulkanRenderPassMetaData { |
65 | | VulkanRenderPassMetaData(const RenderPassDesc& renderPassDesc); |
66 | | |
67 | | bool fLoadMSAAFromResolve; |
68 | | bool fHasColorAttachment; |
69 | | bool fHasColorResolveAttachment; |
70 | | bool fHasDepthStencilAttachment; |
71 | | |
72 | | int fNumColorAttachments; |
73 | | int fNumResolveAttachments; |
74 | | int fNumDepthStencilAttachments; |
75 | | int fSubpassCount; |
76 | | int fSubpassDependencyCount; |
77 | | int fUint32DataCnt; |
78 | | |
79 | | // Accumulate attachments into a container to mimic future structure in RenderPassDesc |
80 | | skia_private::TArray<const AttachmentDesc*> fAttachments; |
81 | | }; |
82 | | |
83 | | static void AddRenderPassInfoToKey(VulkanRenderPassMetaData& rpMetaData, |
84 | | ResourceKey::Builder& builder, |
85 | | int& builderIdx, |
86 | | bool compatibleOnly); |
87 | | |
88 | | private: |
89 | | void freeGpuData() override; |
90 | | |
91 | | VulkanRenderPass(const VulkanSharedContext*, VkRenderPass, VkExtent2D granularity); |
92 | | |
93 | | const VulkanSharedContext* fSharedContext; |
94 | | VkRenderPass fRenderPass; |
95 | | VkExtent2D fGranularity; |
96 | | }; |
97 | | } // namespace skgpu::graphite |
98 | | |
99 | | #endif // skgpu_graphite_VulkanRenderPass_DEFINED |