mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
vo_gpu: x11egl: support Mesa OML sync extension
Mesa supports the EGL_CHROMIUM_sync_control extension, and it's available out of the box with AMD drivers. In practice, this is exactly the same as GLX_OML_sync_control, but for EGL. The extension specification is separate from the GLX one though, and buried somewhere in the Chromium code. This appears to work, although I don't know if it really works. In theory, this could be useful for other EGL targets. Support code for it could have been added to egl_helpers.c to avoid some minor duplicated glue code if another EGL target were to provide this extension. I didn't bother with that. ANGLE on Windows can't support it, because the extension spec. explicitly requires POSIX timers. ANGLE on Linux/OSX is actively harmful for mpv and hopefully won't ever use it. Wayland uses EGL, but has its own fancy presentation feedback stuff (and besides, I don't think basic video player functionality works on Wayland at all). context_drm_egl maybe? But I think DRM has its own stuff.
This commit is contained in:
parent
8d7960f6ef
commit
10a1b98082
@ -30,12 +30,18 @@
|
|||||||
#include "video/out/x11_common.h"
|
#include "video/out/x11_common.h"
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "egl_helpers.h"
|
#include "egl_helpers.h"
|
||||||
|
#include "oml_sync.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
struct priv {
|
struct priv {
|
||||||
GL gl;
|
GL gl;
|
||||||
EGLDisplay egl_display;
|
EGLDisplay egl_display;
|
||||||
EGLContext egl_context;
|
EGLContext egl_context;
|
||||||
EGLSurface egl_surface;
|
EGLSurface egl_surface;
|
||||||
|
|
||||||
|
EGLBoolean (*GetSyncValues)(EGLDisplay, EGLSurface,
|
||||||
|
int64_t*, int64_t*, int64_t*);
|
||||||
|
struct oml_sync sync;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void mpegl_uninit(struct ra_ctx *ctx)
|
static void mpegl_uninit(struct ra_ctx *ctx)
|
||||||
@ -79,6 +85,19 @@ static void mpegl_swap_buffers(struct ra_ctx *ctx)
|
|||||||
{
|
{
|
||||||
struct priv *p = ctx->priv;
|
struct priv *p = ctx->priv;
|
||||||
eglSwapBuffers(p->egl_display, p->egl_surface);
|
eglSwapBuffers(p->egl_display, p->egl_surface);
|
||||||
|
|
||||||
|
int64_t ust, msc, sbc;
|
||||||
|
if (!p->GetSyncValues || !p->GetSyncValues(p->egl_display, p->egl_surface,
|
||||||
|
&ust, &msc, &sbc))
|
||||||
|
ust = msc = sbc = -1;
|
||||||
|
|
||||||
|
oml_sync_swap(&p->sync, ust, msc, sbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mpegl_get_vsync(struct ra_ctx *ctx, struct vo_vsync_info *info)
|
||||||
|
{
|
||||||
|
struct priv *p = ctx->priv;
|
||||||
|
oml_sync_get_info(&p->sync, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool mpegl_init(struct ra_ctx *ctx)
|
static bool mpegl_init(struct ra_ctx *ctx)
|
||||||
@ -142,11 +161,16 @@ static bool mpegl_init(struct ra_ctx *ctx)
|
|||||||
|
|
||||||
struct ra_gl_ctx_params params = {
|
struct ra_gl_ctx_params params = {
|
||||||
.swap_buffers = mpegl_swap_buffers,
|
.swap_buffers = mpegl_swap_buffers,
|
||||||
|
.get_vsync = mpegl_get_vsync,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!ra_gl_ctx_init(ctx, &p->gl, params))
|
if (!ra_gl_ctx_init(ctx, &p->gl, params))
|
||||||
goto uninit;
|
goto uninit;
|
||||||
|
|
||||||
|
const char *exts = eglQueryString(eglGetCurrentDisplay(), EGL_EXTENSIONS);
|
||||||
|
if (gl_check_extension(exts, "EGL_CHROMIUM_sync_control"))
|
||||||
|
p->GetSyncValues = (void *)eglGetProcAddress("eglGetSyncValuesCHROMIUM");
|
||||||
|
|
||||||
ra_add_native_resource(ctx->ra, "x11", vo->x11->display);
|
ra_add_native_resource(ctx->ra, "x11", vo->x11->display);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -480,7 +480,7 @@ def build(ctx):
|
|||||||
( "video/out/opengl/hwdec_rpi.c", "rpi" ),
|
( "video/out/opengl/hwdec_rpi.c", "rpi" ),
|
||||||
( "video/out/opengl/hwdec_vdpau.c", "vdpau-gl-x11" ),
|
( "video/out/opengl/hwdec_vdpau.c", "vdpau-gl-x11" ),
|
||||||
( "video/out/opengl/libmpv_gl.c", "gl" ),
|
( "video/out/opengl/libmpv_gl.c", "gl" ),
|
||||||
( "video/out/opengl/oml_sync.c", "gl-x11" ),
|
( "video/out/opengl/oml_sync.c", "egl-x11 || gl-x11" ),
|
||||||
( "video/out/opengl/ra_gl.c", "gl" ),
|
( "video/out/opengl/ra_gl.c", "gl" ),
|
||||||
( "video/out/opengl/utils.c", "gl" ),
|
( "video/out/opengl/utils.c", "gl" ),
|
||||||
( "video/out/vo.c" ),
|
( "video/out/vo.c" ),
|
||||||
|
Loading…
Reference in New Issue
Block a user