Debian Codegraph @

src/gpu/graphite/task/ComputeTask.h

raw
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_task_ComputeTask_DEFINED
9 #define skgpu_graphite_task_ComputeTask_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/private/base/SkTArray.h"
13 #include "src/gpu/graphite/compute/DispatchGroup.h"
14 #include "src/gpu/graphite/task/Task.h"
15
16 #include <memory>
17
18 namespace skgpu::graphite {
19
20 class CommandBuffer;
21 class Context;
22 class ResourceProvider;
23 class RuntimeEffectDictionary;
24 class ScratchResourceManager;
25
26 /**
27 * ComputeTask handles preparing and recording DispatchGroups into a series of compute dispatches
28 * within a command buffer. It is guaranteed that dispatches within a DispatchGroup will be executed
29 * sequentially.
30 */
31 class ComputeTask final : public Task {
32 public:
33 using DispatchGroupList = skia_private::STArray<1, std::unique_ptr<DispatchGroup>>;
34
35 static sk_sp<ComputeTask> Make(DispatchGroupList dispatchGroups);
36
37 ~ComputeTask() override;
38
39 Status prepareResources(ResourceProvider*,
40 ScratchResourceManager*,
41 sk_sp<const RuntimeEffectDictionary>) override;
42 Status addCommands(Context*, CommandBuffer*, ReplayTargetData) override;
43
44 // TODO: Traverse child tasks too!
45 SK_DUMP_TASKS_CODE(const char* getTaskName() const override { return "Compute Task"; })
46
47 private:
48 explicit ComputeTask(DispatchGroupList dispatchGroups);
49
50 DispatchGroupList fDispatchGroups;
51
52 // Every element of this list is a task that must execute before the DispatchGroup stored at the
53 // same array index. Child tasks are allowed to be a nullptr to represent NOP (i.e. the
54 // corresponding DispatchGroup doesn't have any pre-tasks).
55 skia_private::TArray<sk_sp<Task>> fChildTasks;
56 };
57
58 } // namespace skgpu::graphite
59
60 #endif // skgpu_graphite_task_ComputeTask_DEFINED