On Wed Apr 10 10:52:59 2024 +0000, Rémi Bernon wrote:
I think something like https://gitlab.winehq.org/rbernon/wine/-/commit/1314374cf82a972e0bdf688e6b53... on top of https://gitlab.winehq.org/wine/wine/-/merge_requests/5465 should do the trick and will allow us to move vkQueuePresent WSI logic entirely out of the drivers.
Thanks for the patch. Unfortunately this approach is not able to handle all required scenarios, since it forces a flush at most once per VkSurface. For example, a game starts windowed, it presents with Vulkan (so `flushed` is now true), and then becomes fullscreen. While becoming or being fullscreen the game never draws/flushes the window_surface itself, and the proposed vulkan logic also never forces a flush of the window_surface (since `flushed` is true). Another scenario involves hiding and re-showing a VK fullscreen window (i.e., anything that doesn't involve app GDI draws, so our logic needs to kick in).
For the above to work we need to be able to force flush the window_surface in all instances when it hasn't previously flushed contents, so we need to track flushing state per-window_surface. In reality we want to track this per-wayland_surface (as the current code does, because that's what actually determines subsurface visibility), but for now the window_surface is a good enough proxy for that.
Even if we change the logic and achieve the above at the win32u level, this only handles the `wayland_surface_ensure_contents()` functionality, and we also need the additional reconfigure logic, to be able to reconfigure/ack even if no new contents are needed (e.g., changing states without a change in size). If we want to stick with the flush-after-present approach, perhaps we can achieve this by making `wayland_window_surface_flush` perform this check and operation when it would otherwise not flush anything (e.g.,not forced/bounds empty). Perhaps that's the right to do regardless, but I would need to experiment a bit, to ensure it doesn't have adverse affects under normal (non-VK) operation.
Alternatively, if we are introducing the whole flush-before-present win32u logic only for the benefit of the Wayland driver, perhaps the simplest way forward would be to provide an (optional) `vulkan_funcs.p_queue_present_done(HWND)` callback and just let each driver do what it needs to do (so NULL for most drivers).