• 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_ComputePassTask_DEFINED
9 #define skgpu_graphite_ComputePassTask_DEFINED
10 
11 #include "src/gpu/graphite/ComputePipeline.h"
12 #include "src/gpu/graphite/ComputePipelineDesc.h"
13 #include "src/gpu/graphite/ComputeTypes.h"
14 #include "src/gpu/graphite/Task.h"
15 
16 #include <vector>
17 
18 namespace skgpu::graphite {
19 
20 class Buffer;
21 class ComputePipeline;
22 
23 /**
24  * ComputePassTask records a compute kernel and its associated resources into a single compute pass
25  * within a command buffer. The creation of bound resources and their binding layout is left up to
26  * the caller and must be compatible with the provided the compute pipeline layout.
27  */
28 // TODO(b/240604614): This class could facilitate some of this and also enforce layout validation
29 // depending on how we decide to define and combine compute shader code.
30 // TODO(b/240625222): This class could consume multiple ComputePass objects and encode them
31 // together. The individual passes could execute in parallel depending on the desired data-flow.
32 class ComputePassTask final : public Task {
33 public:
34     static sk_sp<ComputePassTask> Make(std::vector<ResourceBinding> bindings,
35                                        const ComputePipelineDesc&,
36                                        const ComputePassDesc&);
37 
38     ~ComputePassTask() override = default;
39 
40     bool prepareResources(ResourceProvider*, const RuntimeEffectDictionary*) override;
41     bool addCommands(Context*, CommandBuffer*, ReplayTargetData) override;
42 
43 private:
44     ComputePassTask(std::vector<ResourceBinding> bindings,
45                     const ComputePipelineDesc&,
46                     const ComputePassDesc&);
47 
48     const ComputePipelineDesc fPipelineDesc;
49     const ComputePassDesc fComputePassDesc;
50     const std::vector<ResourceBinding> fBindings;
51 
52     sk_sp<ComputePipeline> fPipeline;
53 };
54 
55 }  // namespace skgpu::graphite
56 
57 #endif  // skgpu_graphite_ComputePassTask_DEFINED
58