From: Paul Gofman pgofman@codeweavers.com
This reverts commit d525da59075fc4baba95e19125ad23f0d96e6157. --- dlls/win32u/sysparams.c | 17 ++++++++--------- dlls/wineandroid.drv/init.c | 4 ++-- dlls/winemac.drv/display.c | 16 ++++++++++------ dlls/winewayland.drv/display.c | 8 +++++--- dlls/winex11.drv/display.c | 16 +++++++++++----- dlls/winex11.drv/x11drv.h | 4 ++-- dlls/winex11.drv/xinerama.c | 7 ++++--- dlls/winex11.drv/xrandr.c | 16 ++++++++++------ include/wine/gdi_driver.h | 10 +++++++++- 9 files changed, 61 insertions(+), 37 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index ff8cc0edb73..8bda17f2892 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -1183,17 +1183,16 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const struct pci_id *p return TRUE; }
-static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid, - ULONGLONG memory_size, void *param ) +static void add_gpu( const struct gdi_gpu *gpu, void *param ) { + const struct pci_id *pci_id = &gpu->pci_id; struct device_manager_ctx *ctx = param; char buffer[4096]; KEY_VALUE_PARTIAL_INFORMATION *value = (void *)buffer; unsigned int i; HKEY hkey, subkey; - DWORD len;
- TRACE( "%s %04X %04X %08X %02X\n", debugstr_a( name ), pci_id->vendor, pci_id->device, + TRACE( "%s %04X %04X %08X %02X\n", debugstr_w( gpu->name ), pci_id->vendor, pci_id->device, pci_id->subsystem, pci_id->revision );
if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL ))) @@ -1208,8 +1207,8 @@ static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *
memset( &ctx->gpu, 0, sizeof(ctx->gpu) ); ctx->gpu.index = ctx->gpu_count; - if (vulkan_uuid) ctx->gpu.vulkan_uuid = *vulkan_uuid; - if (name) RtlUTF8ToUnicodeN( ctx->gpu.name, sizeof(ctx->gpu.name) - sizeof(WCHAR), &len, name, strlen( name ) ); + lstrcpyW( ctx->gpu.name, gpu->name ); + ctx->gpu.vulkan_uuid = gpu->vulkan_uuid;
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 ); @@ -1252,7 +1251,7 @@ static void add_gpu( const char *name, const struct pci_id *pci_id, const GUID *
NtClose( hkey );
- if (!write_gpu_to_registry( &ctx->gpu, pci_id, memory_size )) + if (!write_gpu_to_registry( &ctx->gpu, pci_id, gpu->memory_size )) WARN( "Failed to write gpu to registry\n" ); else ctx->gpu_count++; @@ -1732,13 +1731,13 @@ static BOOL default_update_display_devices( BOOL force, struct device_manager_ct .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; - struct pci_id pci_id = {0}; + static const struct gdi_gpu gpu; struct gdi_monitor monitor = {0}; DEVMODEW mode = {{0}};
if (!force) return TRUE;
- add_gpu( "Default GPU", &pci_id, NULL, 0, ctx ); + add_gpu( &gpu, ctx ); add_source( "Default", source_flags, ctx );
if (!read_source_mode( ctx->source_key, ENUM_CURRENT_SETTINGS, &mode )) diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 264bd6a7908..d1894535bfb 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -274,7 +274,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag if (force || force_display_devices_refresh) { static const DWORD source_flags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE | DISPLAY_DEVICE_VGA_COMPATIBLE; - struct pci_id pci_id = {0}; + static const struct gdi_gpu gpu; struct gdi_monitor gdi_monitor = { .rc_monitor = virtual_screen_rect, @@ -288,7 +288,7 @@ BOOL ANDROID_UpdateDisplayDevices( const struct gdi_device_manager *device_manag }; DEVMODEW current = mode;
- device_manager->add_gpu( "Android GPU", &pci_id, NULL, 0, param ); + device_manager->add_gpu( &gpu, param ); device_manager->add_source( "Default", source_flags, param ); device_manager->add_monitor( &gdi_monitor, param );
diff --git a/dlls/winemac.drv/display.c b/dlls/winemac.drv/display.c index 78019d43de9..fc2e680ca88 100644 --- a/dlls/winemac.drv/display.c +++ b/dlls/winemac.drv/display.c @@ -1139,14 +1139,18 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = gpus; gpu < gpus + gpu_count; gpu++) { - struct pci_id pci_id = + struct gdi_gpu gdi_gpu = { - .vendor = gpu->vendor_id, - .device = gpu->device_id, - .subsystem = gpu->subsys_id, - .revision = gpu->revision_id, + .pci_id = + { + .vendor = gpu->vendor_id, + .device = gpu->device_id, + .subsystem = gpu->subsys_id, + .revision = gpu->revision_id, + }, }; - device_manager->add_gpu(gpu->name, &pci_id, NULL, 0, param); + RtlUTF8ToUnicodeN(gdi_gpu.name, sizeof(gdi_gpu.name), &len, gpu->name, strlen(gpu->name)); + device_manager->add_gpu(&gdi_gpu, param);
/* Initialize adapters */ if (macdrv_get_adapters(gpu->id, &adapters, &adapter_count)) break; diff --git a/dlls/winewayland.drv/display.c b/dlls/winewayland.drv/display.c index 3b961476797..efe5683d4eb 100644 --- a/dlls/winewayland.drv/display.c +++ b/dlls/winewayland.drv/display.c @@ -200,11 +200,13 @@ 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, void *param) { - struct pci_id pci_id = {0}; + static const WCHAR wayland_gpuW[] = {'W','a','y','l','a','n','d','G','P','U',0}; + struct gdi_gpu gpu = {0}; + lstrcpyW(gpu.name, wayland_gpuW);
- TRACE("\n"); + TRACE("name=%s\n", wine_dbgstr_w(gpu.name));
- device_manager->add_gpu("Wayland GPU", &pci_id, NULL, 0, param); + device_manager->add_gpu(&gpu, param); }
static void wayland_add_device_source(const struct gdi_device_manager *device_manager, diff --git a/dlls/winex11.drv/display.c b/dlls/winex11.drv/display.c index 15e7d65c7d1..d64f6bb92d6 100644 --- a/dlls/winex11.drv/display.c +++ b/dlls/winex11.drv/display.c @@ -406,7 +406,7 @@ RECT get_host_primary_monitor_rect(void) host_handler.get_monitors(adapters[0].id, &monitors, &monitor_count) && monitor_count) rect = monitors[0].rc_monitor;
- if (gpus) host_handler.free_gpus( gpus, gpu_count ); + if (gpus) host_handler.free_gpus(gpus); if (adapters) host_handler.free_adapters(adapters); if (monitors) host_handler.free_monitors(monitors, monitor_count); return rect; @@ -514,12 +514,18 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage
for (gpu = 0; gpu < gpu_count; gpu++) { - device_manager->add_gpu( gpus[gpu].name, &gpus[gpu].pci_id, &gpus[gpu].vulkan_uuid, - gpus[gpu].memory_size, param ); + struct gdi_gpu gdi_gpu = + { + .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 */ if (!host_handler.get_adapters( gpus[gpu].id, &adapters, &adapter_count )) break; - TRACE( "GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, debugstr_a( gpus[gpu].name ), adapter_count ); + TRACE("GPU: %#lx %s, adapter count: %d\n", gpus[gpu].id, wine_dbgstr_w(gpus[gpu].name), adapter_count);
for (adapter = 0; adapter < adapter_count; adapter++) { @@ -557,7 +563,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manage host_handler.free_adapters( adapters ); }
- host_handler.free_gpus( gpus, gpu_count ); + host_handler.free_gpus( gpus ); return TRUE; }
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 628a0e0f720..b4e63f1fbce 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -767,7 +767,7 @@ void init_user_driver(void); struct x11drv_gpu { ULONG_PTR id; - char *name; + WCHAR name[128]; struct pci_id pci_id; GUID vulkan_uuid; ULONGLONG memory_size; @@ -806,7 +806,7 @@ struct x11drv_display_device_handler 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 */ - void (*free_gpus)(struct x11drv_gpu *gpus, int count); + void (*free_gpus)(struct x11drv_gpu *gpus);
/* free_adapters will be called to free an adapter list from get_adapters */ void (*free_adapters)(struct x11drv_adapter *adapters); diff --git a/dlls/winex11.drv/xinerama.c b/dlls/winex11.drv/xinerama.c index c394c8a49b4..5f489feb59d 100644 --- a/dlls/winex11.drv/xinerama.c +++ b/dlls/winex11.drv/xinerama.c @@ -192,6 +192,7 @@ done:
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;
/* Xinerama has no support for GPU, faking one */ @@ -199,16 +200,16 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (!gpus) return FALSE;
- gpus[0].name = strdup( "Xinerama GPU" ); + lstrcpyW( gpus[0].name, wine_adapterW ); + *new_gpus = gpus; *count = 1;
return TRUE; }
-static void xinerama_free_gpus( struct x11drv_gpu *gpus, int count ) +static void xinerama_free_gpus( struct x11drv_gpu *gpus ) { - while (count--) free( gpus[count].name ); free( gpus ); }
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c index 885c23a09a0..51b316e71bd 100644 --- a/dlls/winex11.drv/xrandr.c +++ b/dlls/winex11.drv/xrandr.c @@ -653,6 +653,7 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro VkPhysicalDeviceIDProperties id; VkInstance vk_instance = NULL; VkDisplayKHR vk_display; + DWORD len; BOOL ret = FALSE; VkResult vr;
@@ -739,7 +740,8 @@ static BOOL get_gpu_properties_from_vulkan( struct x11drv_gpu *gpu, const XRRPro gpu->pci_id.vendor = properties2.properties.vendorID; gpu->pci_id.device = properties2.properties.deviceID; } - gpu->name = strdup( properties2.properties.deviceName ); + RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName, + strlen( properties2.properties.deviceName ) + 1 );
pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx], &mem_properties ); for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount; heap_idx++) @@ -768,6 +770,7 @@ done: * not needed to avoid unnecessary querying */ 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; XRRScreenResources *screen_resources = NULL; XRRProviderResources *provider_resources = NULL; @@ -776,6 +779,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge INT primary_provider = -1; RECT primary_rect; BOOL ret = FALSE; + DWORD len; INT i, j;
screen_resources = xrandr_get_screen_resources(); @@ -795,7 +799,7 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (!provider_resources->nproviders) { WARN("XRandR implementation doesn't report any providers, faking one.\n"); - gpus[0].name = strdup( "Xrandr GPU" ); + lstrcpyW( gpus[0].name, wine_adapterW ); *new_gpus = gpus; *count = 1; ret = TRUE; @@ -830,7 +834,8 @@ static BOOL xrandr14_get_gpus( struct x11drv_gpu **new_gpus, int *count, BOOL ge if (get_properties) { if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info, gpus, i )) - gpus[i].name = strdup( provider_info->name ); + RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len, provider_info->name, + strlen( provider_info->name ) + 1 ); /* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */ } pXRRFreeProviderInfo( provider_info ); @@ -860,9 +865,8 @@ done: return ret; }
-static void xrandr14_free_gpus( struct x11drv_gpu *gpus, int count ) +static void xrandr14_free_gpus( struct x11drv_gpu *gpus ) { - while (count--) free( gpus[count].name ); free( gpus ); }
@@ -1290,7 +1294,7 @@ static BOOL xrandr14_get_id( const WCHAR *device_name, BOOL is_primary, x11drv_s new_current_mode_count += adapter_count; xrandr14_free_adapters( adapters ); } - xrandr14_free_gpus( gpus, gpu_count ); + xrandr14_free_gpus( gpus );
if (new_current_modes) { diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index a8680e2d758..714db83e89c 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -245,6 +245,14 @@ struct pci_id 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 { RECT rc_monitor; /* RcMonitor in MONITORINFO struct */ @@ -255,7 +263,7 @@ struct gdi_monitor
struct gdi_device_manager { - void (*add_gpu)( const char *name, const struct pci_id *pci_id, const GUID *vulkan_uuid, ULONGLONG memory_size, void *param ); + void (*add_gpu)( const struct gdi_gpu *gpu, 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_modes)( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes, void *param );