On Thu Mar 21 14:44:12 2024 +0000, Jacek Caban wrote:
IMO it's not great to have the library handle being part of the interface. Perhaps we could just load the vulkan loader in win32u and pass a struct containing common functions to drivers? That wouldn't work for platform-specific functions like `vkCreateXlibSurfaceKHR`. One way to solve that would be to query it using `vkGetInstanceProcAddr` inside `X11DRV_vkCreateWin32SurfaceKHR` where we have the instance handle. (This would also bring us a step closer to supporting Vulkan in the null driver).
My plan was to gradually move the current vulkan_driver interface to exist only between win32u and winevulkan, and define a different and very reduced one between win32u and the user drivers.
Something along those lines:
```C
/* interface between winevulkan and win32u */ struct vulkan_funcs { VkResult (*p_vkCreateWin32SurfaceKHR)(VkInstance, const VkWin32SurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *); void (*p_vkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *); void * (*p_vkGetDeviceProcAddr)(VkDevice, const char *); void * (*p_vkGetInstanceProcAddr)(VkInstance, const char *); VkBool32 (*p_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice, uint32_t);
/* winevulkan specific functions */ const char *(*p_get_host_surface_extension)(void); VkSurfaceKHR (*p_wine_get_host_surface)(VkSurfaceKHR); };
/* interface between win32u and the user drivers */ struct vulkan_driver_funcs { VkBool32 (*p_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice, uint32_t); const char *(*p_get_host_surface_extension)(void);
void *(*p_vulkan_surface_create)(VkInstance, HWND, VkSurfaceKHR *); void (*p_vulkan_surface_destroy)(VkInstance, HWND, VkSurfaceKHR, void *); void (*p_vulkan_surface_attach)(HWND, VkSurfaceKHR, void *, const RECT *); void (*p_vulkan_surface_detach)(HWND, VkSurfaceKHR, void *, HDC *); }; ```
I'm fine loading the vulkan library in win32u, but there's the mac driver which has specific needs and needs to load SONAME_LIBMOLTENVK instead of SONAME_VULKAN. This is the reason I chose to make the drivers return the vulkan handle.