Commit d525da59 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Pass gdi_gpu structure members as add_gpu parameters.

parent 0300016a
...@@ -1183,16 +1183,17 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p ...@@ -1183,16 +1183,17 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p
return TRUE; return TRUE;
} }
static void add_gpu( const struct gdi_gpu *gpu, void *param ) static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid,
ULONGLONG memory_size, void *param )
{ {
const struct pci_id *pci_id = &gpu->pci_id;
struct device_manager_ctx *ctx = param; struct device_manager_ctx *ctx = param;
char buffer[4096]; char buffer[4096];
KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer;
unsigned int i; unsigned int i;
HKEY hkey, subkey; HKEY hkey, subkey;
DWORD len;
TRACE( "%s %04X %04X %08X %02X\n", debugstr_w( gpu->name ), pci_id->vendor, pci_id->device, TRACE( "%s %04X %04X %08X %02X\n", debugstr_a( name ), pci_id->vendor, pci_id->device,
pci_id->subsystem, pci_id->revision ); pci_id->subsystem, pci_id->revision );
if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ))) if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL )))
...@@ -1207,8 +1208,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) ...@@ -1207,8 +1208,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
memset( &ctx->gpu, 0, sizeof(ctx->gpu) ); memset( &ctx->gpu, 0, sizeof(ctx->gpu) );
ctx->gpu.index = ctx->gpu_count; ctx->gpu.index = ctx->gpu_count;
lstrcpyW( ctx->gpu.name, gpu->name ); if (vulkan_uuid) ctx->gpu.vulkan_uuid = *vulkan_uuid;
ctx->gpu.vulkan_uuid = gpu->vulkan_uuid; if (name) RtlUTF8ToUnicodeN( ctx->gpu.name, sizeof(ctx->gpu.name) - sizeof(WCHAR), &len, name, strlen( name ) );
snprintf( ctx->gpu.path, sizeof(ctx->gpu.path), "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X", snprintf( ctx->gpu.path, sizeof(ctx->gpu.path), "PCI\\VEN_%04X&DEV_%04X&SUBSYS_%08X&REV_%02X\\%08X",
pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision, ctx->gpu.index ); pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision, ctx->gpu.index );
...@@ -1251,7 +1252,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param ) ...@@ -1251,7 +1252,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
NtClose( hkey ); NtClose( hkey );
if (!write_gpu_to_registry( &ctx->gpu, pci_id, gpu->memory_size )) if (!write_gpu_to_registry( &ctx->gpu, pci_id, memory_size ))
WARN( "Failed to write gpu to registry\n" ); WARN( "Failed to write gpu to registry\n" );
else else
ctx->gpu_count++; ctx->gpu_count++;
...@@ -1731,13 +1732,13 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct ...@@ -1731,13 +1732,13 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct
.dmBitsPerPel = 16, .dmPelsWidth = 1024, .dmPelsHeight = 768, .dmDisplayFrequency = 60, }, .dmBitsPerPel = 16, .dmPelsWidth = 1024, .dmPelsHeight = 768, .dmDisplayFrequency = 60, },
}; };
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
static const struct gdi_gpu gpu; struct pci_id pci_id = {0};
struct gdi_monitor monitor = {0}; struct gdi_monitor monitor = {0};
DEVMODEW mode = {{0}}; DEVMODEW mode = {{0}};
if (!force) return TRUE; if (!force) return TRUE;
add_gpu( &gpu, ctx ); add_gpu( "Default GPU", &pci_id, NULL, 0, ctx );
add_source( "Default", source_flags, ctx ); add_source( "Default", source_flags, ctx );
if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &mode )) if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &mode ))
......
...@@ -274,7 +274,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag ...@@ -274,7 +274,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
if (force || force_display_devices_refresh) if (force || force_display_devices_refresh)
{ {
static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE;
static const struct gdi_gpu gpu; struct pci_id pci_id = {0};
struct gdi_monitor gdi_monitor = struct gdi_monitor gdi_monitor =
{ {
.rc_monitor = virtual_screen_rect, .rc_monitor = virtual_screen_rect,
...@@ -288,7 +288,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag ...@@ -288,7 +288,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag
}; };
DEVMODEW current = mode; DEVMODEW current = mode;
device_manager->add_gpu( &gpu, param ); device_manager->add_gpu( "Android GPU", &pci_id, NULL, 0, param );
device_manager->add_source( "Default", source_flags, param ); device_manager->add_source( "Default", source_flags, param );
device_manager->add_monitor( &gdi_monitor, param ); device_manager->add_monitor( &gdi_monitor, param );
......
...@@ -1139,18 +1139,14 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -1139,18 +1139,14 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = gpus; gpu < gpus + gpu_count; gpu++) for (gpu = gpus; gpu < gpus + gpu_count; gpu++)
{ {
struct gdi_gpu gdi_gpu = struct pci_id pci_id =
{
.pci_id =
{ {
.vendor = gpu->vendor_id, .vendor = gpu->vendor_id,
.device = gpu->device_id, .device = gpu->device_id,
.subsystem = gpu->subsys_id, .subsystem = gpu->subsys_id,
.revision = gpu->revision_id, .revision = gpu->revision_id,
},
}; };
RtlUTF8ToUnicodeN(gdi_gpu.name, sizeof(gdi_gpu.name), &len, gpu->name, strlen(gpu->name)); device_manager->add_gpu(gpu->name, &pci_id, NULL, 0, param);
device_manager->add_gpu(&gdi_gpu, param);
/* Initialize adapters */ /* Initialize adapters */
if (macdrv_get_adapters(gpu->id, &adapters, &adapter_count)) break; if (macdrv_get_adapters(gpu->id, &adapters, &adapter_count)) break;
......
...@@ -200,13 +200,11 @@ static void output_info_array_arrange_physical_coords(struct wl_array *output_in ...@@ -200,13 +200,11 @@ static void output_info_array_arrange_physical_coords(struct wl_array *output_in
static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager, static void wayland_add_device_gpu(const struct gdi_device_manager *device_manager,
void *param) void *param)
{ {
static const WCHAR wayland_gpuW[] = {'W','a','y','l','a','n','d','G','P','U',0}; struct pci_id pci_id = {0};
struct gdi_gpu gpu = {0};
lstrcpyW(gpu.name, wayland_gpuW);
TRACE("name=%s\n", wine_dbgstr_w(gpu.name)); TRACE("\n");
device_manager->add_gpu(&gpu, param); device_manager->add_gpu("Wayland GPU", &pci_id, NULL, 0, param);
} }
static void wayland_add_device_source(const struct gdi_device_manager *device_manager, static void wayland_add_device_source(const struct gdi_device_manager *device_manager,
......
...@@ -406,7 +406,7 @@ RECT get_host_primary_monitor_rect(void) ...@@ -406,7 +406,7 @@ RECT get_host_primary_monitor_rect(void)
host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count) host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count)
rect = monitors[0].rc_monitor; rect = monitors[0].rc_monitor;
if (gpus) host_handler.free_gpus(gpus); if (gpus) host_handler.free_gpus( gpus, gpu_count );
if (adapters) host_handler.free_adapters(adapters); if (adapters) host_handler.free_adapters(adapters);
if (monitors) host_handler.free_monitors(monitors, monitor_count); if (monitors) host_handler.free_monitors(monitors, monitor_count);
return rect; return rect;
...@@ -514,18 +514,12 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -514,18 +514,12 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = 0; gpu < gpu_count; gpu++) for (gpu = 0; gpu < gpu_count; gpu++)
{ {
struct gdi_gpu gdi_gpu = device_manager->add_gpu( gpus[gpu].name, &gpus[gpu].pci_id, &gpus[gpu].vulkan_uuid,
{ gpus[gpu].memory_size, param );
.pci_id = gpus[gpu].pci_id,
.vulkan_uuid = gpus[gpu].vulkan_uuid,
.memory_size = gpus[gpu].memory_size,
};
memcpy( gdi_gpu.name, gpus[gpu].name, sizeof(gdi_gpu.name) );
device_manager->add_gpu( &gdi_gpu, param );
/* Initialize adapters */ /* Initialize adapters */
if (!host_handler.get_adapters( gpus[gpu].id, &adapters, &adapter_count )) break; if (!host_handler.get_adapters( gpus[gpu].id, &adapters, &adapter_count )) break;
TRACE("GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, wine_dbgstr_w(gpus[gpu].name), adapter_count); TRACE( "GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, debugstr_a( gpus[gpu].name ), adapter_count );
for (adapter = 0; adapter < adapter_count; adapter++) for (adapter = 0; adapter < adapter_count; adapter++)
{ {
...@@ -563,7 +557,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage ...@@ -563,7 +557,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
host_handler.free_adapters( adapters ); host_handler.free_adapters( adapters );
} }
host_handler.free_gpus( gpus ); host_handler.free_gpus( gpus, gpu_count );
return TRUE; return TRUE;
} }
......
...@@ -767,7 +767,7 @@ void init_user_driver(void); ...@@ -767,7 +767,7 @@ void init_user_driver(void);
struct x11drv_gpu struct x11drv_gpu
{ {
ULONG_PTR id; ULONG_PTR id;
WCHAR name[128]; char *name;
struct pci_id pci_id; struct pci_id pci_id;
GUID vulkan_uuid; GUID vulkan_uuid;
ULONGLONG memory_size; ULONGLONG memory_size;
...@@ -806,7 +806,7 @@ struct x11drv_display_device_handler ...@@ -806,7 +806,7 @@ struct x11drv_display_device_handler
BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count); BOOL (*get_monitors)(ULONG_PTR adapter_id, struct gdi_monitor **monitors, int *count);
/* free_gpus will be called to free a GPU list from get_gpus */ /* free_gpus will be called to free a GPU list from get_gpus */
void (*free_gpus)(struct x11drv_gpu *gpus); void (*free_gpus)(struct x11drv_gpu *gpus, int count);
/* free_adapters will be called to free an adapter list from get_adapters */ /* free_adapters will be called to free an adapter list from get_adapters */
void (*free_adapters)(struct x11drv_adapter *adapters); void (*free_adapters)(struct x11drv_adapter *adapters);
......
...@@ -192,7 +192,6 @@ done: ...@@ -192,7 +192,6 @@ done:
static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties )
{ {
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
struct x11drv_gpu *gpus; struct x11drv_gpu *gpus;
/* Xinerama has no support for GPU, faking one */ /* Xinerama has no support for GPU, faking one */
...@@ -200,16 +199,16 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge ...@@ -200,16 +199,16 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge
if (!gpus) if (!gpus)
return FALSE; return FALSE;
lstrcpyW( gpus[0].name, wine_adapterW ); gpus[0].name = strdup( "Xinerama GPU" );
*new_gpus = gpus; *new_gpus = gpus;
*count = 1; *count = 1;
return TRUE; return TRUE;
} }
static void xinerama_free_gpus( struct x11drv_gpu *gpus ) static void xinerama_free_gpus( struct x11drv_gpu *gpus, int count )
{ {
while (count--) free( gpus[count].name );
free( gpus ); free( gpus );
} }
......
...@@ -653,7 +653,6 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro ...@@ -653,7 +653,6 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
VkPhysicalDeviceIDProperties id; VkPhysicalDeviceIDProperties id;
VkInstance vk_instance = NULL; VkInstance vk_instance = NULL;
VkDisplayKHR vk_display; VkDisplayKHR vk_display;
DWORD len;
BOOL ret = FALSE; BOOL ret = FALSE;
VkResult vr; VkResult vr;
...@@ -740,8 +739,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro ...@@ -740,8 +739,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro
gpu->pci_id.vendor = properties2.properties.vendorID; gpu->pci_id.vendor = properties2.properties.vendorID;
gpu->pci_id.device = properties2.properties.deviceID; gpu->pci_id.device = properties2.properties.deviceID;
} }
RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, gpu->name = strdup( properties2.properties.deviceName );
strlen( properties2.properties.deviceName ) + 1 );
pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &mem_properties ); pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &mem_properties );
for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount; heap_idx++) for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount; heap_idx++)
...@@ -770,7 +768,6 @@ done: ...@@ -770,7 +768,6 @@ done:
* not needed to avoid unnecessary querying */ * not needed to avoid unnecessary querying */
static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties ) static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL get_properties )
{ {
static const WCHAR wine_adapterW[] = {'W','i','n','e',' ','A','d','a','p','t','e','r',0};
struct x11drv_gpu *gpus = NULL; struct x11drv_gpu *gpus = NULL;
XRRScreenResources *screen_resources = NULL; XRRScreenResources *screen_resources = NULL;
XRRProviderResources *provider_resources = NULL; XRRProviderResources *provider_resources = NULL;
...@@ -779,7 +776,6 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge ...@@ -779,7 +776,6 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge
INT primary_provider = -1; INT primary_provider = -1;
RECT primary_rect; RECT primary_rect;
BOOL ret = FALSE; BOOL ret = FALSE;
DWORD len;
INT i, j; INT i, j;
screen_resources = xrandr_get_screen_resources(); screen_resources = xrandr_get_screen_resources();
...@@ -799,7 +795,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge ...@@ -799,7 +795,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge
if (!provider_resources->nproviders) if (!provider_resources->nproviders)
{ {
WARN("XRandR implementation doesn't report any providers, faking one.\n"); WARN("XRandR implementation doesn't report any providers, faking one.\n");
lstrcpyW( gpus[0].name, wine_adapterW ); gpus[0].name = strdup( "Xrandr GPU" );
*new_gpus = gpus; *new_gpus = gpus;
*count = 1; *count = 1;
ret = TRUE; ret = TRUE;
...@@ -834,8 +830,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge ...@@ -834,8 +830,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge
if (get_properties) if (get_properties)
{ {
if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info, gpus, i )) if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info, gpus, i ))
RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len, provider_info->name, gpus[i].name = strdup( provider_info->name );
strlen( provider_info->name ) + 1 );
/* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */ /* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */
} }
pXRRFreeProviderInfo( provider_info ); pXRRFreeProviderInfo( provider_info );
...@@ -865,8 +860,9 @@ done: ...@@ -865,8 +860,9 @@ done:
return ret; return ret;
} }
static void xrandr14_free_gpus( struct x11drv_gpu *gpus ) static void xrandr14_free_gpus( struct x11drv_gpu *gpus, int count )
{ {
while (count--) free( gpus[count].name );
free( gpus ); free( gpus );
} }
...@@ -1294,7 +1290,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s ...@@ -1294,7 +1290,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s
new_current_mode_count += adapter_count; new_current_mode_count += adapter_count;
xrandr14_free_adapters( adapters ); xrandr14_free_adapters( adapters );
} }
xrandr14_free_gpus( gpus ); xrandr14_free_gpus( gpus, gpu_count );
if (new_current_modes) if (new_current_modes)
{ {
......
...@@ -245,14 +245,6 @@ struct pci_id ...@@ -245,14 +245,6 @@ struct pci_id
UINT16 revision; UINT16 revision;
}; };
struct gdi_gpu
{
WCHAR name[128];
struct pci_id pci_id;
GUID vulkan_uuid; /* Vulkan device UUID */
ULONGLONG memory_size;
};
struct gdi_monitor struct gdi_monitor
{ {
RECT rc_monitor; /* RcMonitor in MONITORINFO struct */ RECT rc_monitor; /* RcMonitor in MONITORINFO struct */
...@@ -263,7 +255,7 @@ struct gdi_monitor ...@@ -263,7 +255,7 @@ struct gdi_monitor
struct gdi_device_manager struct gdi_device_manager
{ {
void (*add_gpu)( const struct gdi_gpu *gpu, void *param ); void (*add_gpu)( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid, ULONGLONG memory_size, void *param );
void (*add_source)( const char *name, UINT state_flags, void *param ); void (*add_source)( const char *name, UINT state_flags, void *param );
void (*add_monitor)( const struct gdi_monitor *monitor, void *param ); void (*add_monitor)( const struct gdi_monitor *monitor, void *param );
void (*add_modes)( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes, void *param ); void (*add_modes)( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes, void *param );
......
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