Flutter Engine
The Flutter Engine
MtlSharedContext.mm
Go to the documentation of this file.
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
9
19
20namespace skgpu::graphite {
21
23 const ContextOptions& options) {
24 if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
25 // no warning needed
26 } else {
27 SKGPU_LOG_E("Skia's Graphite backend no longer supports this OS version.");
28#ifdef SK_BUILD_FOR_IOS
29 SKGPU_LOG_E("Minimum supported version is iOS/tvOS 13.0.");
30#else
31 SKGPU_LOG_E("Minimum supported version is MacOS 10.15.");
32#endif
33 return nullptr;
34 }
35
36 sk_cfp<id<MTLDevice>> device = sk_ret_cfp((id<MTLDevice>)(context.fDevice.get()));
37
38 std::unique_ptr<const MtlCaps> caps(new MtlCaps(device.get(), options));
39
40 // TODO: Add memory allocator to context once we figure out synchronization
42 if (!memoryAllocator) {
43 SkDEBUGFAIL("No supplied Metal memory allocator and unable to create one internally.");
44 return nullptr;
45 }
46
48 std::move(memoryAllocator),
49 std::move(caps)));
50}
51
52MtlSharedContext::MtlSharedContext(sk_cfp<id<MTLDevice>> device,
54 std::unique_ptr<const MtlCaps> caps)
55 : skgpu::graphite::SharedContext(std::move(caps), BackendApi::kMetal)
56 , fMemoryAllocator(std::move(memoryAllocator))
57 , fDevice(std::move(device)) {}
58
60 // need to clear out resources before the allocator (if any) is removed
62}
63
64std::unique_ptr<ResourceProvider> MtlSharedContext::makeResourceProvider(SingleOwner* singleOwner,
65 uint32_t recorderID,
66 size_t resourceBudget) {
67 return std::unique_ptr<ResourceProvider>(new MtlResourceProvider(this,
68 singleOwner,
69 recorderID,
70 resourceBudget));
71}
72
73} // namespace skgpu::graphite
const char * options
#define SKGPU_LOG_E(fmt,...)
Definition: Log.h:38
#define SkDEBUGFAIL(message)
Definition: SkAssert.h:118
static sk_sp< MtlMemoryAllocator > Make(id< MTLDevice >)
std::unique_ptr< ResourceProvider > makeResourceProvider(SingleOwner *, uint32_t recorderID, size_t resourceBudget) override
skgpu::MtlMemoryAllocator * memoryAllocator() const
static sk_sp< SharedContext > Make(const MtlBackendContext &, const ContextOptions &)
id< MTLDevice > device() const
const Caps * caps() const
Definition: SharedContext.h:39
@ kMetal
Definition: embedder.h:85
VkDevice device
Definition: main.cc:53
Definition: GpuTools.h:21
BackendApi
Definition: GpuTypes.h:22
Definition: ref_ptr.h:256