Commit 29260f77 authored by Brendan Shanks's avatar Brendan Shanks Committed by Alexandre Julliard

winemac.drv: Simplify control flow where possible after the removal of NSAutoreleasePool.

parent c937e991
...@@ -60,8 +60,6 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count) ...@@ -60,8 +60,6 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count)
{ {
@autoreleasepool @autoreleasepool
{ {
int ret = -1;
NSArray* screens = [NSScreen screens]; NSArray* screens = [NSScreen screens];
if (screens) if (screens)
{ {
...@@ -92,11 +90,11 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count) ...@@ -92,11 +90,11 @@ int macdrv_get_displays(struct macdrv_display** displays, int* count)
*displays = disps; *displays = disps;
*count = num_screens; *count = num_screens;
ret = 0; return 0;
} }
} }
return ret; return -1;
} }
} }
...@@ -307,25 +305,24 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) ...@@ -307,25 +305,24 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
BOOL hide_integrated = FALSE; BOOL hide_integrated = FALSE;
int primary_index = 0, i; int primary_index = 0, i;
int gpu_count = 0; int gpu_count = 0;
int ret = -1;
/* Test if Metal is available */ /* Test if Metal is available */
if (&MTLCopyAllDevices == NULL) if (&MTLCopyAllDevices == NULL)
goto done; return -1;
NSArray<id<MTLDevice>>* devices = [MTLCopyAllDevices() autorelease]; NSArray<id<MTLDevice>>* devices = [MTLCopyAllDevices() autorelease];
if (!devices.count || ![devices[0] respondsToSelector:@selector(registryID)]) if (!devices.count || ![devices[0] respondsToSelector:@selector(registryID)])
goto done; return -1;
gpus = calloc(devices.count, sizeof(*gpus)); gpus = calloc(devices.count, sizeof(*gpus));
if (!gpus) if (!gpus)
goto done; return -1;
/* Use MTLCreateSystemDefaultDevice instead of CGDirectDisplayCopyCurrentMetalDevice(CGMainDisplayID()) to get /* Use MTLCreateSystemDefaultDevice instead of CGDirectDisplayCopyCurrentMetalDevice(CGMainDisplayID()) to get
* the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps * the primary GPU because we need to hide the integrated GPU for an automatic graphic switching pair to avoid apps
* using the integrated GPU. This is the behavior of Windows on a Mac. */ * using the integrated GPU. This is the behavior of Windows on a Mac. */
primary_device = [MTLCreateSystemDefaultDevice() autorelease]; primary_device = [MTLCreateSystemDefaultDevice() autorelease];
if (macdrv_get_gpu_info_from_mtldevice(&primary_gpu, primary_device)) if (macdrv_get_gpu_info_from_mtldevice(&primary_gpu, primary_device))
goto done; goto fail;
/* Hide the integrated GPU if the system default device is a dedicated GPU */ /* Hide the integrated GPU if the system default device is a dedicated GPU */
if (!primary_device.isLowPower) if (!primary_device.isLowPower)
...@@ -337,7 +334,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) ...@@ -337,7 +334,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
for (i = 0; i < devices.count; i++) for (i = 0; i < devices.count; i++)
{ {
if (macdrv_get_gpu_info_from_mtldevice(&gpus[gpu_count], devices[i])) if (macdrv_get_gpu_info_from_mtldevice(&gpus[gpu_count], devices[i]))
goto done; goto fail;
if (hide_integrated && devices[i].isLowPower) if (hide_integrated && devices[i].isLowPower)
{ {
...@@ -362,11 +359,10 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count) ...@@ -362,11 +359,10 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
*new_gpus = gpus; *new_gpus = gpus;
*count = gpu_count; *count = gpu_count;
ret = 0; return 0;
done: fail:
if (ret)
macdrv_free_gpus(gpus); macdrv_free_gpus(gpus);
return ret; return -1;
} }
} }
...@@ -382,18 +378,16 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp ...@@ -382,18 +378,16 @@ static int macdrv_get_gpu_info_from_display_id_using_metal(struct macdrv_gpu* gp
@autoreleasepool @autoreleasepool
{ {
id<MTLDevice> device; id<MTLDevice> device;
int ret = -1;
/* Test if Metal is available */ /* Test if Metal is available */
if (&CGDirectDisplayCopyCurrentMetalDevice == NULL) if (&CGDirectDisplayCopyCurrentMetalDevice == NULL)
goto done; return -1;
device = [CGDirectDisplayCopyCurrentMetalDevice(display_id) autorelease]; device = [CGDirectDisplayCopyCurrentMetalDevice(display_id) autorelease];
if (device && [device respondsToSelector:@selector(registryID)]) if (device && [device respondsToSelector:@selector(registryID)])
ret = macdrv_get_gpu_info_from_registry_id(gpu, device.registryID); return macdrv_get_gpu_info_from_registry_id(gpu, device.registryID);
else
done: return -1;
return ret;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment