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