[osx, metal] Set metal layer's device to layer.preferredDevice instead of calling MTLCreateDefaultSystemDevice(). This fixes issue 15 so we can use Discord's screen sharing while using Orca. This will need to be revisited when we want to actually use a different metal device.
This commit is contained in:
parent
806f00417e
commit
9bfae2c4e8
|
@ -153,7 +153,7 @@ mg_surface mg_surface_create_for_window(mp_window window, mg_surface_api api)
|
||||||
|
|
||||||
mg_surface mg_surface_create_remote(u32 width, u32 height, mg_surface_api api)
|
mg_surface mg_surface_create_remote(u32 width, u32 height, mg_surface_api api)
|
||||||
{
|
{
|
||||||
if(__mgData.init)
|
if(!__mgData.init)
|
||||||
{
|
{
|
||||||
mg_init();
|
mg_init();
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ mg_surface mg_surface_create_remote(u32 width, u32 height, mg_surface_api api)
|
||||||
|
|
||||||
mg_surface mg_surface_create_host(mp_window window)
|
mg_surface mg_surface_create_host(mp_window window)
|
||||||
{
|
{
|
||||||
if(__mgData.init)
|
if(!__mgData.init)
|
||||||
{
|
{
|
||||||
mg_init();
|
mg_init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,12 +170,18 @@ mg_surface_data* mg_mtl_surface_create_for_window(mp_window window)
|
||||||
//NOTE(martin): create a mtl device and a mtl layer and
|
//NOTE(martin): create a mtl device and a mtl layer and
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
|
|
||||||
surface->device = MTLCreateSystemDefaultDevice();
|
/*WARN(martin):
|
||||||
[surface->device retain];
|
Calling MTLCreateDefaultSystemDevice(), as advised by the doc, hangs Discord's screen sharing...
|
||||||
|
The workaround I found, which doesn't make sense, is to set the mtlLayer.device to mtlLayer.preferredDevice,
|
||||||
|
even if mtlLayer.preferredDevice is the same value as returned by MTLCreateDefaultSystemDevice().
|
||||||
|
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.
|
||||||
|
*/
|
||||||
surface->mtlLayer = [CAMetalLayer layer];
|
surface->mtlLayer = [CAMetalLayer layer];
|
||||||
[surface->mtlLayer retain];
|
[surface->mtlLayer retain];
|
||||||
|
surface->mtlLayer.device = surface->mtlLayer.preferredDevice;
|
||||||
|
surface->device = surface->mtlLayer.device;
|
||||||
|
|
||||||
surface->mtlLayer.device = surface->device;
|
|
||||||
[surface->mtlLayer setOpaque:NO];
|
[surface->mtlLayer setOpaque:NO];
|
||||||
|
|
||||||
[surface->interface.layer.caLayer addSublayer: (CALayer*)surface->mtlLayer];
|
[surface->interface.layer.caLayer addSublayer: (CALayer*)surface->mtlLayer];
|
||||||
|
|
Loading…
Reference in New Issue