Are we really only returning SUBOPTIMAL and are the games really recreating VkSurfaceKHR when seeing that result? Wouldn't that only require to recreate the swapchain?
Yes the games are broken in this way. Unfortunately, almost every single vulkan app written for windows does this for some reason and I just don't get it. (DXVK, vkd3d-proton and gravity mark don't just to name a few)
I'm really not sure about this. It's possible to have multiple D3D swapchains at the same time for the same window, or D3D _and_ Vulkan, and the last one to present being the one visible. All this will end up with multiple VkSurfaceKHR created for the same window and I believe we need to use multiple wl_surface?
According to the Vulkan spec, it is not legal to create multiple swapchains on the same underlying native surface and this would result in validation error.
Fwiw, if Wayland really returns SUBOPTIMAL right after a swapchain creation when it is first used, and if applications are known to recreate surfaces entirely, it seems to me that this whole issue is a severe problem with Wayland Vulkan WSI implementation, and that it needs to be fixed there, not in Wine. And swapchains being SUBOPTIMAL right on creation seems like a bad choice in the first place.
It cannot be fixed there for the foreseeable future (It would require a redesign of the dmabuf protocol, which has become stable fwiw. And even if it was redesigned, I'm not sure if it will fix this problem anyways, even xwayland is suboptimal to begin with but it just doesn't have this problem for whatever reason). I'll just rework the approach in this MR to allow multiple swapchains per HWND -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11342#note_145142