Debian Codegraph @

src/gpu/graphite/task/SynchronizeToCpuTask.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_SynchronizeToCpuTask_DEFINED
9 #define skgpu_graphite_task_SynchronizeToCpuTask_DEFINED
10
11 #include "include/core/SkRefCnt.h"
12 #include "src/gpu/graphite/task/Task.h"
13 #include <utility>
14
15 namespace skgpu::graphite {
16
17 class Buffer;
18 class CommandBuffer;
19 class Context;
20 class ResourceProvider;
21 class RuntimeEffectDictionary;
22 class ScratchResourceManager;
23
24 /**
25 * Task that synchronizes the contents of a buffer from the GPU to the CPU. This task ensures that
26 * all modifications to the buffer made the GPU are visible from the CPU. This task may not result
27 * in any work if the underlying buffer does not require synchronization (e.g. a shared memory
28 * buffer).
29 */
30 class SynchronizeToCpuTask final : public Task {
31 public:
32 static sk_sp<SynchronizeToCpuTask> Make(sk_sp<Buffer>);
33 ~SynchronizeToCpuTask() override;
34
35 Status prepareResources(ResourceProvider*,
36 ScratchResourceManager*,
37 sk_sp<const RuntimeEffectDictionary>) override {
38 return Status::kSuccess;
39 }
40
41 Status addCommands(Context*, CommandBuffer*, ReplayTargetData) override;
42
43 SK_DUMP_TASKS_CODE(const char* getTaskName() const override { return "Sync to CPU Task"; })
44
45 private:
46 explicit SynchronizeToCpuTask(sk_sp<Buffer> buffer) : fBuffer(std::move(buffer)) {}
47
48 sk_sp<Buffer> fBuffer;
49 };
50
51 } // namespace skgpu::graphite
52
53 #endif // skgpu_graphite_SynchronizeToCpuTask_DEFINED