Debian Codegraph @

src/gpu/graphite/vk/VulkanFramebuffer.h

raw
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_VulkanFramebuffer_DEFINED
9 #define skgpu_graphite_VulkanFramebuffer_DEFINED
10
11 #include "include/gpu/vk/VulkanTypes.h"
12 #include "src/gpu/graphite/Resource.h"
13
14 namespace skgpu::graphite {
15
16 class VulkanSharedContext;
17 class VulkanTexture;
18 struct RenderPassDesc;
19
20 /**
21 * Resource wrapper for VkFramebuffer
22 */
23 class VulkanFramebuffer : public Resource {
24 public:
25 static sk_sp<VulkanFramebuffer> Make(const VulkanSharedContext*,
26 const VkFramebufferCreateInfo&,
27 const RenderPassDesc& renderPassDesc,
28 sk_sp<VulkanTexture> msaaTexture,
29 sk_sp<VulkanTexture> depthStencilTexture);
30
31 VkFramebuffer framebuffer() {
32 return fFramebuffer;
33 }
34
35 // We only check compatibility with the msaa and depthStencil textures. We assume the caller
36 // has already made sure that the single sample color or resolve attachments match the
37 // framebuffer. We currently also assume that we will always use the same attachment view of
38 // the textures each time.
39 bool compatible(const RenderPassDesc& renderPassDesc,
40 const VulkanTexture* msaaTexture,
41 const VulkanTexture* depthStencilTexture);
42
43 const char* getResourceType() const override { return "Vulkan Framebuffer"; }
44
45 private:
46 VulkanFramebuffer(const VulkanSharedContext*,
47 VkFramebuffer,
48 sk_sp<VulkanTexture> msaaTexture,
49 sk_sp<VulkanTexture> depthStencilTexture,
50 bool loadMSAAFromResolve);
51 void freeGpuData() override;
52
53 const VulkanSharedContext* fSharedContext;
54 VkFramebuffer fFramebuffer;
55
56 sk_sp<VulkanTexture> fMsaaTexture;
57 sk_sp<VulkanTexture> fDepthStencilTexture;
58 bool fLoadMSAAFromResolve;
59 };
60 } // namespace skgpu::graphite
61
62 #endif // skgpu_graphite_VulkanFramebuffer_DEFINED