Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 // TODO: This was taken from GrMtlGpu.mm's Make, does graphite deserve a higher version?
25 if (@available(macOS 10.14, iOS 11.0, tvOS 11.0, *)) {
26 // no warning needed
27 } else {
28 SKGPU_LOG_E("Skia's Graphite backend no longer supports this OS version.");
29#ifdef SK_BUILD_FOR_IOS
30 SKGPU_LOG_E("Minimum supported version is iOS 11.0.");
31#else
32 SKGPU_LOG_E("Minimum supported version is MacOS 10.14.");
33#endif
34 return nullptr;
35 }
36
37 sk_cfp<id<MTLDevice>> device = sk_ret_cfp((id<MTLDevice>)(context.fDevice.get()));
38
39 std::unique_ptr<const MtlCaps> caps(new MtlCaps(device.get(), options));
40
41 // TODO: Add memory allocator to context once we figure out synchronization
43 if (!memoryAllocator) {
44 SkDEBUGFAIL("No supplied Metal memory allocator and unable to create one internally.");
45 return nullptr;
46 }
47
49 std::move(memoryAllocator),
50 std::move(caps)));
51}
52
53MtlSharedContext::MtlSharedContext(sk_cfp<id<MTLDevice>> device,
55 std::unique_ptr<const MtlCaps> caps)
56 : skgpu::graphite::SharedContext(std::move(caps), BackendApi::kMetal)
57 , fMemoryAllocator(std::move(memoryAllocator))
58 , fDevice(std::move(device)) {}
59
61 // need to clear out resources before the allocator (if any) is removed
63}
64
65std::unique_ptr<ResourceProvider> MtlSharedContext::makeResourceProvider(SingleOwner* singleOwner,
66 uint32_t recorderID,
67 size_t resourceBudget) {
68 return std::unique_ptr<ResourceProvider>(new MtlResourceProvider(this,
69 singleOwner,
70 recorderID,
71 resourceBudget));
72}
73
74} // 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 &)
const Caps * caps() const
VkDevice device
Definition main.cc:53
BackendApi
Definition GpuTypes.h:22
Definition ref_ptr.h:256