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_RenderPassTask_DEFINED
9#define skgpu_RenderPassTask_DEFINED
10
11#include "experimental/graphite/src/CommandBuffer.h"
12#include "experimental/graphite/src/Task.h"
13
14#include <vector>
15
16namespace skgpu {
17
18class CommandBuffer;
19class DrawPass;
20class ResourceProvider;
21
22/**
23 * RenderPassTask handles preparing and recording DrawLists into a single render pass within a
24 * command buffer. If the backend supports subpasses, and the DrawLists/surfaces are compatible, a
25 * RenderPassTask can execute multiple DrawLists across different surfaces as subpasses nested
26 * within a single render pass. If there is no such support, a RenderPassTask is one-to-one with a
27 * "render pass" to specific surface.
28 */
29class RenderPassTask final : public Task {
30public:
31    static sk_sp<RenderPassTask> Make(std::vector<std::unique_ptr<DrawPass>> passes,
32                                      const RenderPassDesc&);
33
34    ~RenderPassTask() override;
35
36    void addCommands(ResourceProvider*, CommandBuffer*) override;
37
38private:
39    RenderPassTask(std::vector<std::unique_ptr<DrawPass>> passes, const RenderPassDesc&);
40
41    std::vector<std::unique_ptr<DrawPass>> fDrawPasses;
42    RenderPassDesc fRenderPassDesc;
43};
44
45} // namespace skgpu
46
47#endif // skgpu_RenderPassTask_DEFINED
48