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_MtlComputePipeline_DEFINED 9 #define skgpu_graphite_MtlComputePipeline_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/ports/SkCFObject.h" 13 #include "src/gpu/graphite/ComputePipeline.h" 14 15 #import <Metal/Metal.h> 16 17 namespace skgpu::graphite { 18 19 class ComputePipelineDesc; 20 class ResourceProvider; 21 class MtlSharedContext; 22 23 class MtlComputePipeline final : public ComputePipeline { 24 public: 25 using MSLFunction = std::pair<id<MTLLibrary>, std::string>; 26 27 static sk_sp<MtlComputePipeline> Make(const MtlSharedContext*, 28 const std::string& label, 29 MSLFunction computeMain); 30 ~MtlComputePipeline() override = default; 31 mtlPipelineState()32 id<MTLComputePipelineState> mtlPipelineState() const { return fPipelineState.get(); } 33 34 private: MtlComputePipeline(const SharedContext * sharedContext,sk_cfp<id<MTLComputePipelineState>> pso)35 MtlComputePipeline(const SharedContext* sharedContext, sk_cfp<id<MTLComputePipelineState>> pso) 36 : ComputePipeline(sharedContext) 37 , fPipelineState(std::move(pso)) {} 38 39 void freeGpuData() override; 40 41 sk_cfp<id<MTLComputePipelineState>> fPipelineState; 42 }; 43 44 } // namespace skgpu::graphite 45 46 #endif // skgpu_graphite_MtlComputePipeline_DEFINED 47