summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorJames Ross-Gowan <rossymiles@gmail.com>2016-05-29 01:21:29 +1000
committerJames Ross-Gowan <rossymiles@gmail.com>2016-05-29 01:55:10 +1000
commit9eccedf4471621dcb82219a657141bf5960b77dd (patch)
tree22f83fff495ad7ed17142530f7bbaaa1341c36bd /video
parent9f42760538f02699945803f4a98b4dd8c4202774 (diff)
downloadmpv-9eccedf4471621dcb82219a657141bf5960b77dd.tar.bz2
mpv-9eccedf4471621dcb82219a657141bf5960b77dd.tar.xz
vo_opengl: angle: enable DirectComposition
This avoids a copy of the video image and lowers vsync jitter. Since there are now two options to add to the window_attribs list, it has been made dynamic.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/context_angle.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c
index aeb3e672fc..cc8617cbf1 100644
--- a/video/out/opengl/context_angle.c
+++ b/video/out/opengl/context_angle.c
@@ -158,6 +158,10 @@ static int angle_init(struct MPGLContext *ctx, int flags)
goto fail;
}
+ const char *exts = eglQueryString(p->egl_display, EGL_EXTENSIONS);
+ if (exts)
+ MP_DBG(ctx->vo, "EGL extensions: %s\n", exts);
+
eglBindAPI(EGL_OPENGL_ES_API);
if (eglGetError() != EGL_SUCCESS) {
MP_FATAL(vo, "Couldn't bind GLES API\n");
@@ -168,24 +172,37 @@ static int angle_init(struct MPGLContext *ctx, int flags)
if (!config)
goto fail;
+ int window_attribs_len = 0;
EGLint *window_attribs = NULL;
- EGLint window_attribs_flip[] = {
- EGL_SURFACE_ORIENTATION_ANGLE, EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE,
- EGL_NONE
- };
+
EGLint flip_val;
if (eglGetConfigAttrib(p->egl_display, config,
EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE, &flip_val))
{
if (flip_val == EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE) {
- window_attribs = window_attribs_flip;
+ MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len,
+ EGL_SURFACE_ORIENTATION_ANGLE);
+ MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len,
+ EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE);
ctx->flip_v = true;
MP_VERBOSE(vo, "Rendering flipped.\n");
}
}
+ // EGL_DIRECT_COMPOSITION_ANGLE enables the use of flip-mode present, which
+ // avoids a copy of the video image and lowers vsync jitter, though the
+ // extension is only present on Windows 8 and up.
+ if (strstr(exts, "EGL_ANGLE_direct_composition")) {
+ MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len,
+ EGL_DIRECT_COMPOSITION_ANGLE);
+ MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len, EGL_TRUE);
+ MP_VERBOSE(vo, "Using DirectComposition.\n");
+ }
+
+ MP_TARRAY_APPEND(NULL, window_attribs, window_attribs_len, EGL_NONE);
p->egl_surface = eglCreateWindowSurface(p->egl_display, config,
vo_w32_hwnd(vo), window_attribs);
+ talloc_free(window_attribs);
if (p->egl_surface == EGL_NO_SURFACE) {
MP_FATAL(ctx->vo, "Could not create EGL surface!\n");
goto fail;
@@ -199,11 +216,6 @@ static int angle_init(struct MPGLContext *ctx, int flags)
}
mpgl_load_functions(ctx->gl, get_proc_address, NULL, vo->log);
-
- const char *exts = eglQueryString(p->egl_display, EGL_EXTENSIONS);
- if (exts)
- MP_DBG(ctx->vo, "EGL extensions: %s\n", exts);
-
return 0;
fail: