Commit 731f06d9 authored by Evan Tang's avatar Evan Tang Committed by Alexandre Julliard

winemac.drv: Give Apple GPUs device IDs.

parent aec014fe
......@@ -257,6 +257,37 @@ static int macdrv_get_gpu_info_from_registry_id(struct macdrv_gpu* gpu, uint64_t
}
/***********************************************************************
* macdrv_get_gpu_info_from_mtldevice
*
* Get GPU information from a Metal device that responds to the registryID selector.
*
* Returns non-zero value on failure.
*/
static int macdrv_get_gpu_info_from_mtldevice(struct macdrv_gpu* gpu, id<MTLDevice> device)
{
int ret;
if ((ret = macdrv_get_gpu_info_from_registry_id(gpu, [device registryID])))
return ret;
/* Apple GPUs aren't PCI devices and therefore have no device ID
* Use the Metal GPUFamily as the device ID */
if (!gpu->device_id && [device respondsToSelector:@selector(supportsFamily:)] && [device supportsFamily:MTLGPUFamilyApple1])
{
MTLGPUFamily highest = MTLGPUFamilyApple1;
while (1)
{
/* Apple2, etc are all in order */
MTLGPUFamily next = highest + 1;
if ([device supportsFamily:next])
highest = next;
else
break;
}
gpu->device_id = highest;
}
return 0;
}
/***********************************************************************
* macdrv_get_gpus_from_metal
*
* Get a list of GPUs from Metal.
......@@ -289,7 +320,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
* 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. */
primary_device = [MTLCreateSystemDefaultDevice() autorelease];
if (macdrv_get_gpu_info_from_registry_id(&primary_gpu, primary_device.registryID))
if (macdrv_get_gpu_info_from_mtldevice(&primary_gpu, primary_device))
goto done;
/* Hide the integrated GPU if the system default device is a dedicated GPU */
......@@ -301,7 +332,7 @@ static int macdrv_get_gpus_from_metal(struct macdrv_gpu** new_gpus, int* count)
for (i = 0; i < devices.count; i++)
{
if (macdrv_get_gpu_info_from_registry_id(&gpus[gpu_count], devices[i].registryID))
if (macdrv_get_gpu_info_from_mtldevice(&gpus[gpu_count], devices[i]))
goto done;
if (hide_integrated && devices[i].isLowPower)
......
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