summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authordudemanguy <random342@airmail.cc>2019-10-14 12:16:42 -0500
committerDudemanguy <random342@airmail.cc>2019-10-20 15:34:57 +0000
commit027ca4fb855f3dff4cba1c907c92c509b82e6fe8 (patch)
tree7dc4946579de357aa5fe14f1ec46e735905db33a /video/out
parentbedca07a021863d264e7c4c471cc30102899500f (diff)
downloadmpv-027ca4fb855f3dff4cba1c907c92c509b82e6fe8.tar.bz2
mpv-027ca4fb855f3dff4cba1c907c92c509b82e6fe8.tar.xz
wayland: add various render-related options
The newest wayland changes have some new logic that make sense to expose to users as configurable options.
Diffstat (limited to 'video/out')
-rw-r--r--video/out/opengl/context_wayland.c3
-rw-r--r--video/out/vulkan/context_wayland.c3
-rw-r--r--video/out/wayland_common.c20
-rw-r--r--video/out/wayland_common.h8
4 files changed, 29 insertions, 5 deletions
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index 5e9150eb0d..917db8553c 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -139,7 +139,8 @@ static void wayland_egl_swap_buffers(struct ra_ctx *ctx)
}
eglSwapBuffers(p->egl_display, p->egl_surface);
- vo_wayland_wait_frame(wl);
+ if (!wl->opts->disable_vsync)
+ vo_wayland_wait_frame(wl, wl->opts->frame_offset);
if (wl->presentation)
wayland_sync_swap(wl);
diff --git a/video/out/vulkan/context_wayland.c b/video/out/vulkan/context_wayland.c
index d3da628137..6abec91aaf 100644
--- a/video/out/vulkan/context_wayland.c
+++ b/video/out/vulkan/context_wayland.c
@@ -110,7 +110,8 @@ static void wayland_vk_swap_buffers(struct ra_ctx *ctx)
queue_new_sync(wl);
}
- vo_wayland_wait_frame(wl);
+ if (!wl->opts->disable_vsync)
+ vo_wayland_wait_frame(wl, wl->opts->frame_offset);
if (wl->presentation)
wayland_sync_swap(wl);
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index f66753018b..0b749a526d 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -22,6 +22,7 @@
#include <linux/input.h>
#include <time.h>
#include "common/msg.h"
+#include "options/m_config.h"
#include "input/input.h"
#include "input/keycodes.h"
#include "osdep/io.h"
@@ -41,6 +42,20 @@
// Generated from presentation-time.xml
#include "video/out/wayland/presentation-time.h"
+#define OPT_BASE_STRUCT struct wayland_opts
+const struct m_sub_options wayland_conf = {
+ .opts = (const struct m_option[]) {
+ OPT_INTRANGE("wayland-frame-wait-offset", frame_offset, 0, -500, 3000),
+ OPT_FLAG("wayland-disable-vsync", disable_vsync, 0),
+ {0},
+ },
+ .size = sizeof(struct wayland_opts),
+ .defaults = &(struct wayland_opts) {
+ .frame_offset = 1000,
+ .disable_vsync = false,
+ },
+};
+
static void xdg_wm_base_ping(void *data, struct xdg_wm_base *wm_base, uint32_t serial)
{
xdg_wm_base_pong(wm_base, serial);
@@ -1100,6 +1115,7 @@ int vo_wayland_init(struct vo *vo)
MP_VERBOSE(wl, "Compositor doesn't support the %s protocol!\n",
zwp_idle_inhibit_manager_v1_interface.name);
+ wl->opts = mp_get_config_group(wl, wl->vo->global, &wayland_conf);
wl->display_fd = wl_display_get_fd(wl->display);
mp_make_wakeup_pipe(wl->wakeup_pipe);
@@ -1511,14 +1527,14 @@ void vo_wayland_wakeup(struct vo *vo)
(void)write(wl->wakeup_pipe[1], &(char){0}, 1);
}
-void vo_wayland_wait_frame(struct vo_wayland_state *wl)
+void vo_wayland_wait_frame(struct vo_wayland_state *wl, int frame_offset)
{
struct pollfd fds[1] = {
{.fd = wl->display_fd, .events = POLLIN },
};
double vblank_time = 1e6 / wl->current_output->refresh_rate;
- int64_t finish_time = mp_time_us() + vblank_time + 1000;
+ int64_t finish_time = mp_time_us() + vblank_time + (int64_t)frame_offset;
while (wl->frame_wait && finish_time > mp_time_us()) {
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index 606d9ed218..0e9705cce8 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -25,6 +25,11 @@
#include "vo.h"
#include "input/event.h"
+struct wayland_opts {
+ int frame_offset;
+ int disable_vsync;
+};
+
struct vo_wayland_sync {
int64_t ust;
int64_t msc;
@@ -56,6 +61,7 @@ struct vo_wayland_state {
struct wl_shm *shm;
struct wl_compositor *compositor;
struct wl_registry *registry;
+ struct wayland_opts *opts;
/* State */
struct mp_rect geometry;
@@ -136,7 +142,7 @@ void vo_wayland_check_events(struct vo *vo);
void vo_wayland_uninit(struct vo *vo);
void vo_wayland_wakeup(struct vo *vo);
void vo_wayland_wait_events(struct vo *vo, int64_t until_time_us);
-void vo_wayland_wait_frame(struct vo_wayland_state *wl);
+void vo_wayland_wait_frame(struct vo_wayland_state *wl, int frame_offset);
void wayland_sync_swap(struct vo_wayland_state *wl);
void vo_wayland_sync_shift(struct vo_wayland_state *wl);
void queue_new_sync(struct vo_wayland_state *wl);