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 #include "src/gpu/graphite/ComputePassTask.h"
9
10 #include "src/gpu/graphite/Buffer.h"
11 #include "src/gpu/graphite/CommandBuffer.h"
12 #include "src/gpu/graphite/ResourceProvider.h"
13
14 namespace skgpu::graphite {
15
Make(std::vector<ResourceBinding> bindings,const ComputePipelineDesc & pipelineDesc,const ComputePassDesc & desc)16 sk_sp<ComputePassTask> ComputePassTask::Make(std::vector<ResourceBinding> bindings,
17 const ComputePipelineDesc& pipelineDesc,
18 const ComputePassDesc& desc) {
19 return sk_sp<ComputePassTask>(new ComputePassTask(std::move(bindings), pipelineDesc, desc));
20 }
21
ComputePassTask(std::vector<ResourceBinding> bindings,const ComputePipelineDesc & pipelineDesc,const ComputePassDesc & desc)22 ComputePassTask::ComputePassTask(std::vector<ResourceBinding> bindings,
23 const ComputePipelineDesc& pipelineDesc,
24 const ComputePassDesc& desc)
25 : fPipelineDesc(pipelineDesc)
26 , fComputePassDesc(desc)
27 , fBindings(std::move(bindings)) {}
28
prepareResources(ResourceProvider * provider,const RuntimeEffectDictionary *)29 bool ComputePassTask::prepareResources(ResourceProvider* provider,
30 const RuntimeEffectDictionary*) {
31 fPipeline = provider->findOrCreateComputePipeline(fPipelineDesc);
32 return fPipeline != nullptr;
33 }
34
addCommands(Context *,CommandBuffer * commandBuffer,ReplayTargetData)35 bool ComputePassTask::addCommands(Context*, CommandBuffer* commandBuffer, ReplayTargetData) {
36 SkASSERT(fPipeline);
37 return commandBuffer->addComputePass(fComputePassDesc, fPipeline, fBindings);
38 }
39
40 } // namespace skgpu::graphite
41