Debian Codegraph @

src/gpu/graphite/task/RenderPassTask.h

raw
1 /*
2 * Copyright 2021 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_task_RenderPassTask_DEFINED
9 #define skgpu_graphite_task_RenderPassTask_DEFINED
10
11 #include "include/core/SkRect.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/private/base/SkTArray.h"
14 #include "src/gpu/graphite/DrawPass.h"
15 #include "src/gpu/graphite/RenderPassDesc.h"
16 #include "src/gpu/graphite/task/Task.h"
17
18 #include <functional>
19 #include <memory>
20
21 namespace skgpu::graphite {
22
23 class TextureProxy;
24 class CommandBuffer;
25 class Context;
26 class GraphicsPipeline;
27 class ResourceProvider;
28 class RuntimeEffectDictionary;
29 class ScratchResourceManager;
30
31 /**
32 * RenderPassTask handles preparing and recording DrawLists into a single render pass within a
33 * command buffer. If the backend supports subpasses, and the DrawLists/surfaces are compatible, a
34 * RenderPassTask can execute multiple DrawLists across different surfaces as subpasses nested
35 * within a single render pass. If there is no such support, a RenderPassTask is one-to-one with a
36 * "render pass" to specific surface.
37 */
38 class RenderPassTask final : public Task {
39 public:
40 using DrawPassList = skia_private::STArray<1, std::unique_ptr<DrawPass>>;
41
42 // dstCopy should only be provided if the draw passes require a texture copy
43 // for dst reads and must cover the union of all `DrawPass::dstReadBounds()` values in the
44 // render pass. It is assumed that the copy's (0,0) texel matches the top-left corner of the
45 // pass's dst copy bounds. The copy can be larger than the required bounds.
46 static sk_sp<RenderPassTask> Make(DrawPassList,
47 const RenderPassDesc&,
48 sk_sp<TextureProxy> target,
49 sk_sp<TextureProxy> dstCopy,
50 SkIRect dstReadBounds);
51
52 ~RenderPassTask() override;
53
54 Status prepareResources(ResourceProvider*,
55 ScratchResourceManager*,
56 sk_sp<const RuntimeEffectDictionary>) override;
57
58 Status addCommands(Context*, CommandBuffer*, ReplayTargetData) override;
59
60 bool visitPipelines(const std::function<bool(const GraphicsPipeline*)>& visitor) override;
61
62 bool visitProxies(const std::function<bool(const TextureProxy*)>& visitor,
63 bool readsOnly) override;
64
65 SK_DUMP_TASKS_CODE(const char* getTaskName() const override { return "RenderPass Task"; })
66
67 private:
68 RenderPassTask(DrawPassList,
69 const RenderPassDesc&,
70 sk_sp<TextureProxy> target,
71 sk_sp<TextureProxy> dstCopy,
72 SkIRect dstReadBounds);
73
74 DrawPassList fDrawPasses;
75 RenderPassDesc fRenderPassDesc;
76 sk_sp<TextureProxy> fTarget;
77
78 sk_sp<TextureProxy> fDstCopy;
79 SkIRect fDstReadBounds;
80 };
81
82 } // namespace skgpu::graphite
83
84 #endif // skgpu_graphite_task_RenderPassTask_DEFINED