Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
metal_context_helper.h File Reference
#include "include/gpu/ganesh/mtl/GrMtlBackendContext.h"

Go to the source code of this file.

Functions

GrMtlBackendContext GetMetalContext ()
 

Function Documentation

◆ GetMetalContext()

GrMtlBackendContext GetMetalContext ( )

Definition at line 15 of file metal_context_helper.mm.

15 {
16 GrMtlBackendContext backendContext = {};
17 sk_cfp<id<MTLDevice>> device;
18#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
19 device.reset(MTLCreateSystemDefaultDevice());
20#else
21 sk_cfp<NSArray<id <MTLDevice>>*> availableDevices(MTLCopyAllDevices());
22 // Choose the non-integrated CPU if available
23 for (id<MTLDevice> dev in availableDevices.get()) {
24 if (!dev.isLowPower) {
25 device.retain(dev);
26 break;
27 }
28 if (dev.isRemovable) {
29 device.retain(dev);
30 break;
31 }
32 }
33 if (!device) {
34 device.reset(MTLCreateSystemDefaultDevice());
35 }
36#endif
37
38 backendContext.fDevice.retain((GrMTLHandle)device.get());
39 sk_cfp<id<MTLCommandQueue>> queue([*device newCommandQueue]);
40 backendContext.fQueue.retain((GrMTLHandle)queue.get());
41 return backendContext;
42}
const void * GrMTLHandle
Definition GrMtlTypes.h:20
VkDevice device
Definition main.cc:53
VkQueue queue
Definition main.cc:55
sk_cfp< GrMTLHandle > fDevice
sk_cfp< GrMTLHandle > fQueue