1 /* 2 * Copyright 2021 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_MtlGpu_DEFINED 9 #define skgpu_MtlGpu_DEFINED 10 11 #include "experimental/graphite/src/Gpu.h" 12 13 #include "include/ports/SkCFObject.h" 14 15 #include "experimental/graphite/include/mtl/MtlBackendContext.h" 16 #include "experimental/graphite/src/mtl/MtlCaps.h" 17 18 #import <Metal/Metal.h> 19 20 namespace skgpu::mtl { 21 22 class Gpu final : public skgpu::Gpu { 23 public: 24 static sk_sp<skgpu::Gpu> Make(const BackendContext&); 25 ~Gpu() override; 26 device()27 id<MTLDevice> device() const { return fDevice.get(); } queue()28 id<MTLCommandQueue> queue() const { return fQueue.get(); } 29 mtlCaps()30 const Caps& mtlCaps() const { return static_cast<const Caps&>(*this->caps()); } 31 32 private: 33 Gpu(sk_cfp<id<MTLDevice>>, sk_cfp<id<MTLCommandQueue>>, sk_sp<const Caps>); 34 35 bool onSubmit(sk_sp<skgpu::CommandBuffer>) override; 36 37 #if GRAPHITE_TEST_UTILS 38 void testingOnly_startCapture() override; 39 void testingOnly_endCapture() override; 40 #endif 41 42 sk_cfp<id<MTLDevice>> fDevice; 43 sk_cfp<id<MTLCommandQueue>> fQueue; 44 }; 45 46 } // namespace skgpu::mtl 47 48 #endif // skgpu_MtlGpu_DEFINED 49