[osx, surface] Query list of available metal devices, and select a discrete GPU if available. This way we avoid calling MTLCreateSystemDefaultDevice() which messes with Discord's screen sharing, while also being able to take GPU frame captures in XCode (which was broken by 9bfae2c4e8
)
This commit is contained in:
parent
7573c40c56
commit
a65b0cc1bb
|
@ -177,10 +177,30 @@ mg_surface_data* mg_mtl_surface_create_for_window(mp_window window)
|
||||||
This works for now and allows screen sharing while using orca, but we'll have to revisit this when we want
|
This works for now and allows screen sharing while using orca, but we'll have to revisit this when we want
|
||||||
more control over what GPU gets used.
|
more control over what GPU gets used.
|
||||||
*/
|
*/
|
||||||
|
surface->device = nil;
|
||||||
|
|
||||||
|
//Select a discrete GPU, if possible
|
||||||
|
NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices();
|
||||||
|
for(id<MTLDevice> device in devices)
|
||||||
|
{
|
||||||
|
if(!device.isRemovable && !device.isLowPower)
|
||||||
|
{
|
||||||
|
surface->device = device;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(surface->device == nil)
|
||||||
|
{
|
||||||
|
log_warning("Couldn't select a discrete GPU, using first available device\n");
|
||||||
|
surface->device = devices[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
//surface->device = MTLCreateSystemDefaultDevice();
|
||||||
|
|
||||||
surface->mtlLayer = [CAMetalLayer layer];
|
surface->mtlLayer = [CAMetalLayer layer];
|
||||||
[surface->mtlLayer retain];
|
[surface->mtlLayer retain];
|
||||||
surface->mtlLayer.device = surface->mtlLayer.preferredDevice;
|
surface->mtlLayer.device = surface->device;
|
||||||
surface->device = surface->mtlLayer.device;
|
|
||||||
|
|
||||||
[surface->mtlLayer setOpaque:NO];
|
[surface->mtlLayer setOpaque:NO];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue