[PATCH 0/2] MR9916: win32u: Fixup Vulkan deviceName to match win32u GPU name.
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/vulkan.c | 8 ++++++++ dlls/winevulkan/make_vulkan | 1 + dlls/winevulkan/vulkan_thunks.c | 4 ++-- include/wine/vulkan_driver.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 2b25e44eace..69721c2161b 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -1711,6 +1711,13 @@ static void fill_luid_property( VkPhysicalDeviceProperties2 *properties2 ) properties2->properties.deviceName, device_luid_valid, luid.HighPart, luid.LowPart ); } +static void win32u_vkGetPhysicalDeviceProperties( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties *properties ) +{ + struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); + + physical_device->instance->p_vkGetPhysicalDeviceProperties( physical_device->host.physical_device, properties ); +} + static void win32u_vkGetPhysicalDeviceProperties2( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties2 *properties2 ) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); @@ -2876,6 +2883,7 @@ static struct vulkan_funcs vulkan_funcs = .p_vkGetPhysicalDeviceImageFormatProperties2 = win32u_vkGetPhysicalDeviceImageFormatProperties2, .p_vkGetPhysicalDeviceImageFormatProperties2KHR = win32u_vkGetPhysicalDeviceImageFormatProperties2KHR, .p_vkGetPhysicalDevicePresentRectanglesKHR = win32u_vkGetPhysicalDevicePresentRectanglesKHR, + .p_vkGetPhysicalDeviceProperties = win32u_vkGetPhysicalDeviceProperties, .p_vkGetPhysicalDeviceProperties2 = win32u_vkGetPhysicalDeviceProperties2, .p_vkGetPhysicalDeviceProperties2KHR = win32u_vkGetPhysicalDeviceProperties2KHR, .p_vkGetPhysicalDeviceSurfaceCapabilities2KHR = win32u_vkGetPhysicalDeviceSurfaceCapabilities2KHR, diff --git a/dlls/winevulkan/make_vulkan b/dlls/winevulkan/make_vulkan index 792f1d955e2..7426b6835dc 100755 --- a/dlls/winevulkan/make_vulkan +++ b/dlls/winevulkan/make_vulkan @@ -221,6 +221,7 @@ USER_DRIVER_FUNCS = { "vkGetPhysicalDeviceImageFormatProperties2", "vkGetPhysicalDeviceImageFormatProperties2KHR", "vkGetPhysicalDevicePresentRectanglesKHR", + "vkGetPhysicalDeviceProperties", "vkGetPhysicalDeviceProperties2", "vkGetPhysicalDeviceProperties2KHR", "vkGetPhysicalDeviceSurfaceCapabilities2KHR", diff --git a/dlls/winevulkan/vulkan_thunks.c b/dlls/winevulkan/vulkan_thunks.c index dc22cf5ebe5..d265b8a0767 100644 --- a/dlls/winevulkan/vulkan_thunks.c +++ b/dlls/winevulkan/vulkan_thunks.c @@ -58035,7 +58035,7 @@ static NTSTATUS thunk64_vkGetPhysicalDeviceProperties(void *args) TRACE("%p, %p\n", params->physicalDevice, params->pProperties); - vulkan_physical_device_from_handle(params->physicalDevice)->instance->p_vkGetPhysicalDeviceProperties(vulkan_physical_device_from_handle(params->physicalDevice)->host.physical_device, params->pProperties); + vk_funcs->p_vkGetPhysicalDeviceProperties(params->physicalDevice, params->pProperties); return STATUS_SUCCESS; } #endif /* _WIN64 */ @@ -58051,7 +58051,7 @@ static NTSTATUS thunk32_vkGetPhysicalDeviceProperties(void *args) TRACE("%#x, %#x\n", params->physicalDevice, params->pProperties); - vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->instance->p_vkGetPhysicalDeviceProperties(vulkan_physical_device_from_handle((VkPhysicalDevice)UlongToPtr(params->physicalDevice))->host.physical_device, &pProperties_host); + vk_funcs->p_vkGetPhysicalDeviceProperties((VkPhysicalDevice)UlongToPtr(params->physicalDevice), &pProperties_host); convert_VkPhysicalDeviceProperties_host_to_win32(&pProperties_host, (VkPhysicalDeviceProperties32 *)UlongToPtr(params->pProperties)); return STATUS_SUCCESS; } diff --git a/include/wine/vulkan_driver.h b/include/wine/vulkan_driver.h index d2e2db3e360..9c18f6d20db 100644 --- a/include/wine/vulkan_driver.h +++ b/include/wine/vulkan_driver.h @@ -333,6 +333,7 @@ struct vulkan_funcs PFN_vkGetPhysicalDeviceImageFormatProperties2 p_vkGetPhysicalDeviceImageFormatProperties2; PFN_vkGetPhysicalDeviceImageFormatProperties2KHR p_vkGetPhysicalDeviceImageFormatProperties2KHR; PFN_vkGetPhysicalDevicePresentRectanglesKHR p_vkGetPhysicalDevicePresentRectanglesKHR; + PFN_vkGetPhysicalDeviceProperties p_vkGetPhysicalDeviceProperties; PFN_vkGetPhysicalDeviceProperties2 p_vkGetPhysicalDeviceProperties2; PFN_vkGetPhysicalDeviceProperties2KHR p_vkGetPhysicalDeviceProperties2KHR; PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR p_vkGetPhysicalDeviceSurfaceCapabilities2KHR; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9916
From: Paul Gofman <pgofman@codeweavers.com> --- dlls/win32u/opengl.c | 4 ++-- dlls/win32u/sysparams.c | 3 ++- dlls/win32u/vulkan.c | 44 ++++++++++++++++++++++++++---------- dlls/win32u/win32u_private.h | 9 +++++++- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index ad4390486d7..70851f0139a 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -2402,9 +2402,9 @@ static BOOL win32u_query_renderer( UINT attribute, void *value ) switch (attribute) { case GL_DEVICE_LUID_EXT: - return get_gpu_luid_from_uuid( &egl->device_uuid, (LUID *)value, &mask ); + return get_gpu_info_from_uuid( &egl->device_uuid, (LUID *)value, &mask, NULL ); case GL_DEVICE_NODE_MASK_EXT: - return get_gpu_luid_from_uuid( &egl->device_uuid, &luid, value ); + return get_gpu_info_from_uuid( &egl->device_uuid, &luid, value, NULL ); default: FIXME( "Unsupported attribute %#x\n", attribute ); set_gl_error( GL_INVALID_ENUM ); diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 6081b35cf23..945b03c0b15 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -8064,7 +8064,7 @@ BOOL get_gpu_uuid_from_luid( const LUID *luid, GUID *uuid ) } /* Find the GPU LUID corresponding to a device UUID */ -BOOL get_gpu_luid_from_uuid( const GUID *uuid, LUID *luid, UINT32 *node_mask ) +BOOL get_gpu_info_from_uuid( const GUID *uuid, LUID *luid, UINT32 *node_mask, char *name ) { BOOL found = FALSE; struct gpu *gpu; @@ -8076,6 +8076,7 @@ BOOL get_gpu_luid_from_uuid( const GUID *uuid, LUID *luid, UINT32 *node_mask ) if (!IsEqualGUID( uuid, &gpu->uuid )) continue; *luid = gpu->luid; *node_mask = 1; + if (name) unicodez_to_ascii( name, gpu->name ); found = TRUE; break; } diff --git a/dlls/win32u/vulkan.c b/dlls/win32u/vulkan.c index 69721c2161b..91c29ced209 100644 --- a/dlls/win32u/vulkan.c +++ b/dlls/win32u/vulkan.c @@ -448,11 +448,10 @@ static VkResult convert_instance_create_info( struct mempool *pool, VkInstanceCr if (instance->obj.extensions.has_VK_KHR_win32_surface && vulkan_funcs.host_extensions.has_VK_EXT_surface_maintenance1) instance->obj.extensions.has_VK_EXT_surface_maintenance1 = 1; - if (use_external_memory()) - { + if (vulkan_funcs.host_extensions.has_VK_KHR_get_physical_device_properties2) instance->obj.extensions.has_VK_KHR_get_physical_device_properties2 = 1; + if (use_external_memory()) instance->obj.extensions.has_VK_KHR_external_memory_capabilities = 1; - } /* VK_KHR_win32_keyed_mutex only requires external memory extensions, but we will use * external semaphore fds to implement it, so we enable the instance extensions too */ @@ -1676,8 +1675,11 @@ static void *find_vk_struct( void *s, VkStructureType t ) return NULL; } -static void fill_luid_property( VkPhysicalDeviceProperties2 *properties2 ) +static void get_fixed_up_physical_device_properties2( struct vulkan_physical_device *physical_device, VkPhysicalDeviceProperties2 *properties2, + PFN_vkGetPhysicalDeviceProperties2 p_vkGetPhysicalDeviceProperties2 ) { + VkPhysicalDeviceIDProperties id_host = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES }; + VkPhysicalDeviceProperties2 properties2_host; VkPhysicalDeviceVulkan11Properties *vk11; VkPhysicalDeviceIDProperties *id; VkBool32 device_luid_valid; @@ -1688,9 +1690,21 @@ static void fill_luid_property( VkPhysicalDeviceProperties2 *properties2 ) vk11 = find_vk_struct( properties2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES ); id = find_vk_struct( properties2, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES ); - if (!vk11 && !id) return; - uuid = (const GUID *)(id ? id->deviceUUID : vk11->deviceUUID); - device_luid_valid = get_gpu_luid_from_uuid( uuid, &luid, &node_mask ); + if (!vk11 && !id) + { + properties2_host = *properties2; + id_host.pNext = properties2->pNext; + properties2_host.pNext = &id_host; + p_vkGetPhysicalDeviceProperties2( physical_device->host.physical_device, &properties2_host ); + properties2->properties = properties2_host.properties; + } + else p_vkGetPhysicalDeviceProperties2( physical_device->host.physical_device, properties2 ); + + if (id) uuid = (const GUID *)id->deviceUUID; + else if (vk11) uuid = (const GUID *)vk11->deviceUUID; + else uuid = (const GUID *)id_host.deviceUUID; + + device_luid_valid = get_gpu_info_from_uuid( uuid, &luid, &node_mask, properties2->properties.deviceName ); if (!device_luid_valid) WARN( "luid for %s not found\n", debugstr_guid(uuid) ); if (id) @@ -1714,24 +1728,30 @@ static void fill_luid_property( VkPhysicalDeviceProperties2 *properties2 ) static void win32u_vkGetPhysicalDeviceProperties( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties *properties ) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); + VkPhysicalDeviceProperties2 properties2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 }; - physical_device->instance->p_vkGetPhysicalDeviceProperties( physical_device->host.physical_device, properties ); + if (!physical_device->instance->extensions.has_VK_KHR_get_physical_device_properties2) + { + physical_device->instance->p_vkGetPhysicalDeviceProperties( physical_device->host.physical_device, properties ); + return; + } + get_fixed_up_physical_device_properties2( physical_device, &properties2, + physical_device->instance->p_vkGetPhysicalDeviceProperties2KHR ); + *properties = properties2.properties; } static void win32u_vkGetPhysicalDeviceProperties2( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties2 *properties2 ) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); - physical_device->instance->p_vkGetPhysicalDeviceProperties2( physical_device->host.physical_device, properties2 ); - fill_luid_property( properties2 ); + get_fixed_up_physical_device_properties2( physical_device, properties2, physical_device->instance->p_vkGetPhysicalDeviceProperties2 ); } static void win32u_vkGetPhysicalDeviceProperties2KHR( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties2 *properties2 ) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); - physical_device->instance->p_vkGetPhysicalDeviceProperties2KHR( physical_device->host.physical_device, properties2 ); - fill_luid_property( properties2 ); + get_fixed_up_physical_device_properties2( physical_device, properties2, physical_device->instance->p_vkGetPhysicalDeviceProperties2KHR ); } static VkResult win32u_vkGetPhysicalDeviceSurfaceFormatsKHR( VkPhysicalDevice client_physical_device, VkSurfaceKHR client_surface, diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 0f9d17644b5..f3c15f1be79 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -190,7 +190,7 @@ extern void user_lock(void); extern void user_unlock(void); extern void user_check_not_lock(void); extern BOOL get_gpu_uuid_from_luid( const LUID *luid, GUID *uuid ); -extern BOOL get_gpu_luid_from_uuid( const GUID *uuid, LUID *luid, UINT32 *node_mask ); +extern BOOL get_gpu_info_from_uuid( const GUID *uuid, LUID *luid, UINT32 *node_mask, char *name ); /* d3dkmtc. */ @@ -402,6 +402,13 @@ static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src ) return (p - dst) * sizeof(WCHAR); } +static inline UINT unicodez_to_ascii( char *dst, const WCHAR *src ) +{ + char *p = dst; + while ((*p++ = *src++)); + return p - dst; +} + static inline BOOL is_win9x(void) { return NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32s; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9916
After commit d9c22ffafaf3 Vulkan deviceName doesn't match win32u device name which was the case before. That matches on Windows and always matched in Wine and I think we should keep that in sync, apps may depend on that. It is of course possible to do now a bit simplier, using gpu_device_name() from vulkan.c and replicating the logic which will use the hardcoded name if recognizes GPU ID. But I think it would be very inconvenient going forward. Thing is, gpu_device_name() is far from perfect now, that yields wrong GPU names. E. g., I have 0x1002, 0x73df here which is RX 6800M, while that is getting named as RX 6700 XT. device ids may correspond to multiple different GPU models, it should probably be using revision id to disambiguate that. But revision id is not available from Vulkan, so it wouldn't be possible to use that way once we decide to improve GPU detection. In any case, duplicating the logic of detecting GPU name for Vulkan seems wrong, it is most straightforward to get what we have for this GPU set already. However, the only sure way to do it is to use device UUID or LUID which is not available with vkGetPhysicalDeviceProperties, thus I am routing that through vkGetPhysicalDeviceProperties2 (whenever extension is supported, which should be pretty much always the case; Wine also already depends on that for wow64 mappings). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9916#note_127207
Rémi Bernon (@rbernon) commented about dlls/win32u/vulkan.c:
static void win32u_vkGetPhysicalDeviceProperties( VkPhysicalDevice client_physical_device, VkPhysicalDeviceProperties *properties ) { struct vulkan_physical_device *physical_device = vulkan_physical_device_from_handle( client_physical_device ); + VkPhysicalDeviceProperties2 properties2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 };
+ if (!physical_device->instance->extensions.has_VK_KHR_get_physical_device_properties2) + { physical_device->instance->p_vkGetPhysicalDeviceProperties( physical_device->host.physical_device, properties ); We should be able to at least guess the GPU from its vendor/device and update its name here too, no?
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9916#note_127299
Rémi Bernon (@rbernon) commented about dlls/win32u/vulkan.c:
return NULL; }
-static void fill_luid_property( VkPhysicalDeviceProperties2 *properties2 ) +static void get_fixed_up_physical_device_properties2( struct vulkan_physical_device *physical_device, VkPhysicalDeviceProperties2 *properties2,
I would simply name this `get_physical_device_properties2`, that it needs to fix things up is just part of the proper implementation. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9916#note_127300
On Mon Jan 19 10:49:32 2026 +0000, Rémi Bernon wrote:
We should be able to at least guess the GPU from its vendor/device and update its name here too, no? I think if we hit this case that means get_vulkan_gpus() doesn't work and we already have basic match between Vulkan device uuid / luid to win32u gpus broken and IMO in such a case we have already effectively given up on Vulkan device matching. So I'd think it is not too much useful to fixup in this case, and using gpu_device_name() will only complicate potential future changes for getting GPU name in sysparams without clear benefit. But it is not like I am strictly opposed to doing that now, if you see some reason for it I will change it.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/9916#note_127337
participants (3)
-
Paul Gofman -
Paul Gofman (@gofman) -
Rémi Bernon (@rbernon)