summaryrefslogtreecommitdiffstats
path: root/video/out/vulkan/context.h
diff options
context:
space:
mode:
authordudemanguy <random342@airmail.cc>2019-10-07 15:58:36 -0500
committerDudemanguy911 <random342@airmail.cc>2019-10-10 17:41:19 +0000
commitea4685b233090bb155cfa4ec6bf87f421a553168 (patch)
tree35e1f69c4fa348401a6bbab877a2fb096910ba6b /video/out/vulkan/context.h
parente0895e097bcf15cdabc93f340dae24a88b0dc89c (diff)
downloadmpv-ea4685b233090bb155cfa4ec6bf87f421a553168.tar.bz2
mpv-ea4685b233090bb155cfa4ec6bf87f421a553168.tar.xz
wayland: use callback flag + poll for buffer swap
The old way of using wayland in mpv relied on an external renderloop for semi-accurate timings. This had multiple issues though. Display sync would break whenever the window was hidden (since the frame callback stopped being executed) which was really annoying. Also the entire external renderloop logic was kind of fragile and didn't play well with mpv's internal structure (i.e. using presentation time in that old paradigm breaks stats.lua). Basically the problem is that swap buffers blocks on wayland which is crap whenever you hide the mpv window since it looks up the entire player. So you have to make swap buffers not block, but this has a different problem. Timings will be terrible if you use the unblocked swap buffers call. Based on some discussion in #wayland, the trick here is relatively simple and works well enough for our purposes. Instead we basically build a way to block with a timeout in the wayland buffer swap functions. A bool is set in the frame callback function that indicates whether or not mpv is waiting for a frame to be displayed. In the actual buffer swap function, we enter into a while loop waiting for this flag to be set. At the same time, the wl_display is polled to block the thread and wakeup if it receives any events from the compositor. This loop only breaks if enough time has passed or if the frame callback bool is received. In the near future, it is better to set whether or not frame a frame has been displayed in the presentation feedback. However as a first pass, doing it in the frame callback is more than good enough. The "downside" is that we render frames that aren't actually shown on screen when the player is hidden (it seems like wayland people don't like that). But who cares. Accurate timings are way more important. It's probably not too hard to add that behavior back in the player though.
Diffstat (limited to 'video/out/vulkan/context.h')
-rw-r--r--video/out/vulkan/context.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/video/out/vulkan/context.h b/video/out/vulkan/context.h
index 30c97cfb4f..90d7f8b8b2 100644
--- a/video/out/vulkan/context.h
+++ b/video/out/vulkan/context.h
@@ -3,9 +3,15 @@
#include "video/out/gpu/context.h"
#include "common.h"
+struct ra_vk_ctx_params {
+ // In case something special needs to be done on the buffer swap.
+ void (*swap_buffers)(struct ra_ctx *ctx);
+};
+
// Helpers for ra_ctx based on ra_vk. These initialize ctx->ra and ctx->swchain.
void ra_vk_ctx_uninit(struct ra_ctx *ctx);
bool ra_vk_ctx_init(struct ra_ctx *ctx, struct mpvk_ctx *vk,
+ struct ra_vk_ctx_params params,
VkPresentModeKHR preferred_mode);
// Handles a resize request, and updates ctx->vo->dwidth/dheight