This is an alternative proposal to !5830. It fixes the same glitches in Horizon Zero Dawn, but attempts to do that by implementing the proper behavior expected from the swapchain. More precisely, it fixes a few mistakes I had made the last time I touched this code, it implements the frame latency waitable with a semaphore instead of an event (as it should be) and at last it uses the frame latency waitable to implement an appropriate wait after presentation when the client didn't request to manage the waitable directly.
This implementation is not yet complete, because the semaphore should be released when the frame is presented. Knowing when this is the case would require using `VK_KHR_present_wait`. We currently approximate that with the moment in which the frame is submitted for presentation to Vulkan, which as far as I can tell is good enough. Eventually I'll try to write the proper thing.
This MR depends on https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1343, which has been submitted in the meantime to vkd3d. The vkd3d change is included in the first commit, so this MR is already functional.
--
v3: dxgi: Wait on the frame latency semaphore when the client doesn't do it.
dxgi: Make the frame latency waitable a semaphore.
dxgi: Remove the frame latency fence.
dxgi: Directly signal the frame latency fence.
dxgi: Do not bias the frame latency fence.
dxgi: Set the frame latency even when increasing the frame latency.
dxgi: Submit Vulkan presentation as soon as possible.
https://gitlab.winehq.org/wine/wine/-/merge_requests/7152
These changes are enough to allow building the entirety of the native (ELF) side with `-flto`.
--
v3: loader: Mark thread_ldt, thread_data, wld_start "used".
ntdll: Mark call_init_thunk and abort_thread "used".
https://gitlab.winehq.org/wine/wine/-/merge_requests/7119
The key change is to never return STATUS_TIMEOUT, and to instead return the result of
NtYieldExecution() if zero timeout was passed, or STATUS_SUCCESS otherwise.
An overview of the correct values for each combination, copied from the test commit:
- Non-alertable, zero timeout: STATUS_SUCCESS or STATUS_NO_YIELD_PERFORMED
- Non-alertable, non-zero timeout: STATUS_SUCCESS
- Alertable, zero timeout: STATUS_SUCCESS, STATUS_NO_YIELD_PERFORMED, or STATUS_USER_APC
- Alertable, non-zero timeout: STATUS_SUCCESS or STATUS_USER_APC
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/7169
These changes are enough to allow building the entirety of the native (ELF) side with `-flto`.
--
v2: loader: Mark thread_ldt, thread_data, wld_start "used".
ntdll: Mark call_init_thunk "used".
https://gitlab.winehq.org/wine/wine/-/merge_requests/7119