• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     std::unique_ptr<skgpu::ResourceProvider> makeResourceProvider(
33             sk_sp<GlobalCache>, SingleOwner*) const override;
34 
35 private:
36     Gpu(sk_cfp<id<MTLDevice>>, sk_cfp<id<MTLCommandQueue>>, sk_sp<const Caps>);
37 
38     bool onSubmit(sk_sp<skgpu::CommandBuffer>) override;
39 
40     BackendTexture onCreateBackendTexture(SkISize dimensions, const skgpu::TextureInfo&) override;
41     void onDeleteBackendTexture(BackendTexture&) override;
42 
43 #if GRAPHITE_TEST_UTILS
44     void testingOnly_startCapture() override;
45     void testingOnly_endCapture() override;
46 #endif
47 
48     sk_cfp<id<MTLDevice>> fDevice;
49     sk_cfp<id<MTLCommandQueue>> fQueue;
50 };
51 
52 } // namespace skgpu::mtl
53 
54 #endif // skgpu_MtlGpu_DEFINED
55