https://bugs.winehq.org/show_bug.cgi?id=53870
Bug ID: 53870 Summary: vkGetPhysicalDeviceSurfaceCapabilities2KHR passes invalid VkSurfaceKHR handle to driver Product: Wine Version: 7.20 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winevulkan Assignee: wine-bugs@winehq.org Reporter: alexandros.frantzis@collabora.com Distribution: ---
Created attachment 73397 --> https://bugs.winehq.org/attachment.cgi?id=73397 Relevant log entries of Chrome failing to initialize Vulkan
Hi!
With:
commit 000a7bbb5a10ca9144b7ab7a23c4716edf1a83b0 Author: Jacek Caban jacek@codeweavers.com Date: Fri Sep 23 21:37:45 2022 +0200
winevulkan: Use host Vulkan structures for private thunks arguments.
calling vkGetPhysicalDeviceSurfaceCapabilities2KHR (on 32-bit builds at least) ends up passing the wrong VkSurfaceKHR handle to the driver. This can be reproduced with "chrome.exe --use-angle=vulkan --in-process-gpu". I have attached the relevant parts from a debug trace of a broken run, annotated with few comments (and some extra trace points for clarity).
The issue seems to be in this generated thunk:
static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceCapabilities2KHR(void *args) { ... convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_host(params->pSurfaceInfo, &pSurfaceInfo_host); params->result = wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR(params->physicalDevice, &pSurfaceInfo_host, params->pSurfaceCapabilities); ... }
The conversion function populates pSurfaceInfo_host.surface with the driver_surface handle, which is not what wine_vkGetPhysicalDeviceSurfaceCapabilities2KHR expects.
Note that the conversion works fine when we have a direct call to the driver function, for example in the vkGetPhysicalDeviceSurfaceFormats2KHR thunk:
static NTSTATUS thunk32_vkGetPhysicalDeviceSurfaceFormats2KHR(void *args) { ... convert_VkPhysicalDeviceSurfaceInfo2KHR_win32_to_host(params->pSurfaceInfo, &pSurfaceInfo_host); params->result = wine_phys_dev_from_handle(params->physicalDevice)->instance->funcs.p_vkGetPhysicalDeviceSurfaceFormats2KHR(wine_phys_dev_from_handle(params->physicalDevice)->phys_dev, &pSurfaceInfo_host, params->pSurfaceFormatCount, params->pSurfaceFormats); ... }
For verification I hacked thunk32_vkGetPhysicalDeviceSurfaceCapabilities2KHR to to use the original surface in pSurfaceInfo_host and this fixed the issue for me.
Thanks!