From: Rémi Bernon <rbernon(a)codeweavers.com>
---
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, 37 insertions(+), 61 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c
index 0becee77a1d..00bc7e0a6e1 100644
--- a/dlls/win32u/sysparams.c
+++ b/dlls/win32u/sysparams.c
@@ -1177,16 +1177,17 @@ static BOOL write_gpu_to_registry( const struct gpu *gpu, const
struct pci_id *p
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;
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_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 );
if (!enum_key && !(enum_key = reg_create_ascii_key( NULL, enum_keyA, 0, NULL
)))
@@ -1201,8 +1202,8 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
memset( &ctx->gpu, 0, sizeof(ctx->gpu) );
ctx->gpu.index = ctx->gpu_count;
- lstrcpyW( ctx->gpu.name, gpu->name );
- ctx->gpu.vulkan_uuid = gpu->vulkan_uuid;
+ 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 ) );
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 );
@@ -1245,7 +1246,7 @@ static void add_gpu( const struct gdi_gpu *gpu, void *param )
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" );
else
ctx->gpu_count++;
@@ -1728,13 +1729,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;
- static const struct gdi_gpu gpu;
+ struct pci_id pci_id = {0};
struct gdi_monitor monitor = {0};
DEVMODEW mode = {{0}};
if (!force) return TRUE;
- add_gpu( &gpu, ctx );
+ add_gpu( "Default GPU", &pci_id, NULL, 0, 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 d1894535bfb..264bd6a7908 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;
- static const struct gdi_gpu gpu;
+ struct pci_id pci_id = {0};
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( &gpu, param );
+ device_manager->add_gpu( "Android GPU", &pci_id, NULL, 0, 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 fc2e680ca88..78019d43de9 100644
--- a/dlls/winemac.drv/display.c
+++ b/dlls/winemac.drv/display.c
@@ -1139,18 +1139,14 @@ BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager
*device_manage
for (gpu = gpus; gpu < gpus + gpu_count; gpu++)
{
- struct gdi_gpu gdi_gpu =
+ struct pci_id pci_id =
{
- .pci_id =
- {
- .vendor = gpu->vendor_id,
- .device = gpu->device_id,
- .subsystem = gpu->subsys_id,
- .revision = gpu->revision_id,
- },
+ .vendor = gpu->vendor_id,
+ .device = gpu->device_id,
+ .subsystem = gpu->subsys_id,
+ .revision = gpu->revision_id,
};
- RtlUTF8ToUnicodeN(gdi_gpu.name, sizeof(gdi_gpu.name), &len, gpu->name,
strlen(gpu->name));
- device_manager->add_gpu(&gdi_gpu, param);
+ device_manager->add_gpu(gpu->name, &pci_id, NULL, 0, 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 efe5683d4eb..ffe46117191 100644
--- a/dlls/winewayland.drv/display.c
+++ b/dlls/winewayland.drv/display.c
@@ -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,
void *param)
{
- 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);
+ struct pci_id pci_id = {0};
- TRACE("name=%s\n", wine_dbgstr_w(gpu.name));
+ TRACE("\n");
- device_manager->add_gpu(&gpu, param);
+ device_manager->add_gpu("WaylandGPU", &pci_id, NULL, 0, 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 798381a07fd..bfee95b6642 100644
--- a/dlls/winex11.drv/display.c
+++ b/dlls/winex11.drv/display.c
@@ -407,7 +407,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);
+ if (gpus) host_handler.free_gpus( gpus, gpu_count );
if (adapters) host_handler.free_adapters(adapters);
if (monitors) host_handler.free_monitors(monitors, monitor_count);
return rect;
@@ -515,18 +515,12 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager
*device_manage
for (gpu = 0; gpu < gpu_count; gpu++)
{
- 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 );
+ device_manager->add_gpu( gpus[gpu].name, &gpus[gpu].pci_id,
&gpus[gpu].vulkan_uuid,
+ gpus[gpu].memory_size, 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,
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++)
{
@@ -564,7 +558,7 @@ BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager
*device_manage
host_handler.free_adapters( adapters );
}
- host_handler.free_gpus( gpus );
+ host_handler.free_gpus( gpus, gpu_count );
return TRUE;
}
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 5f92857e1d8..d8d5622abfd 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -764,7 +764,7 @@ void init_user_driver(void);
struct x11drv_gpu
{
ULONG_PTR id;
- WCHAR name[128];
+ char *name;
struct pci_id pci_id;
GUID vulkan_uuid;
ULONGLONG memory_size;
@@ -803,7 +803,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);
+ void (*free_gpus)(struct x11drv_gpu *gpus, int count);
/* 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 5f489feb59d..798e24c47c5 100644
--- a/dlls/winex11.drv/xinerama.c
+++ b/dlls/winex11.drv/xinerama.c
@@ -192,7 +192,6 @@ 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 */
@@ -200,16 +199,16 @@ static BOOL xinerama_get_gpus( struct x11drv_gpu **new_gpus, int
*count, BOOL ge
if (!gpus)
return FALSE;
- lstrcpyW( gpus[0].name, wine_adapterW );
-
+ gpus[0].name = strdup( "Wine Adapter" );
*new_gpus = gpus;
*count = 1;
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 );
}
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c
index debc6af58cb..c5a0e5856a0 100644
--- a/dlls/winex11.drv/xrandr.c
+++ b/dlls/winex11.drv/xrandr.c
@@ -653,7 +653,6 @@ 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;
@@ -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.device = properties2.properties.deviceID;
}
- RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len,
properties2.properties.deviceName,
- strlen( properties2.properties.deviceName ) + 1 );
+ gpu->name = strdup( properties2.properties.deviceName );
pvkGetPhysicalDeviceMemoryProperties( vk_physical_devices[device_idx],
&mem_properties );
for (heap_idx = 0; heap_idx < mem_properties.memoryHeapCount;
heap_idx++)
@@ -770,7 +768,6 @@ 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;
@@ -779,7 +776,6 @@ 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();
@@ -799,7 +795,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");
- lstrcpyW( gpus[0].name, wine_adapterW );
+ gpus[0].name = strdup( "Wine Adapter" );
*new_gpus = gpus;
*count = 1;
ret = TRUE;
@@ -834,8 +830,7 @@ 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
))
- RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len,
provider_info->name,
- strlen( provider_info->name ) + 1 );
+ gpus[i].name = strdup( provider_info->name );
/* FIXME: Add an alternate method of getting PCI IDs, for systems that
don't support Vulkan */
}
pXRRFreeProviderInfo( provider_info );
@@ -865,8 +860,9 @@ done:
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 );
}
@@ -1266,7 +1262,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 );
+ xrandr14_free_gpus( gpus, gpu_count );
if (new_current_modes)
{
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index 714db83e89c..a8680e2d758 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -245,14 +245,6 @@ 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 */
@@ -263,7 +255,7 @@ struct gdi_monitor
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_monitor)( const struct gdi_monitor *monitor, void *param );
void (*add_modes)( const DEVMODEW *current, UINT modes_count, const DEVMODEW *modes,
void *param );
--
GitLab
https://gitlab.winehq.org/wine/wine/-/merge_requests/5570