0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00
mpv/video/out/vulkan
Sultan Alsawaf 0d44ae319d x11: remove PresentNotifyMSC from egl/glx/vulkan to fix xpresent timing
PresentNotifyMSC turns out to be not only redundant, but also harmful with
mesa-backed egl/glx/vulkan VOs because for all of them, mesa uses
PresentPixmap behind the scenes when DRI3 is available, which already
spawns a PresentCompleteNotify event when the buffer swap actually
finishes. This is important because without using the timing information
from these PresentCompleteKindPixmap events, there's no way for mpv to know
exactly when a frame becomes visible on the display.

By using PresentNotifyMSC in conjunction with DRI3-enabled mesa, two
problems are created:
1. mpv assumes that a vblank won't elapse (i.e., it assumes the current MSC
   won't change) between the time when mesa enqueues the buffer swap and
   the time when mpv calls PresentNotifyMSC to ask xorg for a notification
   at the next MSC, relative to the current MSC at the time that xorg reads
   it for the PresentNotifyMSC call. This means that mpv could get a
   notification one or more vblanks later than it expects, since the
   intention here is for mpv to get a notification at the MSC that the
   buffer swap completes.
2. mpv assumes that a buffer swap always takes one vblank to complete,
   which isn't always true. A buffer swap (i.e., a page flip) could take
   longer than that depending on hardware conditions (if the GPU is running
   slowly or needs to exit a low-power state), scheduling delays (under
   heavy system or GPU load), or unfortunate timing (if the raster scan
   line happens to be at one of the last few rows of pixels and a vblank
   elapses just before the buffer swap is enqueued).

This causes mpv to have a faulty assumption of when frames become visible.

Since mpv already receives the PresentCompleteNotify events generated by
mesa's buffer swaps under the hood, the PresentNotifyMSC usage is unneeded
and just throws a wrench in mpv's vsync timing when xpresent is enabled.

Simply removing the PresentNotifyMSC usage from the egl, glx, and vulkan
VOs fixes the xpresent vsync timing.
2023-01-25 03:13:23 +00:00
..
common.h vo_gpu_next: vulkan: libplacebo: unify log prefix 2022-10-09 21:47:35 +02:00
context_android.c wayland: use callback flag + poll for buffer swap 2019-10-10 17:41:19 +00:00
context_display.c libplacebo: update log helpers 2022-02-03 18:22:14 +01:00
context_wayland.c wayland: add wp-fractional-scale-v1 support 2023-01-24 00:04:39 +00:00
context_win.c wayland: use callback flag + poll for buffer swap 2019-10-10 17:41:19 +00:00
context_xlib.c x11: remove PresentNotifyMSC from egl/glx/vulkan to fix xpresent timing 2023-01-25 03:13:23 +00:00
context.c vulkan: remove --vulkan-disable-events 2022-10-05 16:35:14 +02:00
context.h wayland_vk: rename start_frame to check_visible 2021-11-04 15:59:56 +00:00
utils.c vulkan: fix build error for 32bit builds with clang 2023-01-08 16:09:01 +01:00
utils.h vo_gpu: vulkan: use libplacebo instead 2019-04-21 23:55:22 +03:00