From 7a75e7c00216471fff64406e76a1d9654d3439b5 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 5 May 2016 18:44:41 +0200 Subject: vo_opengl: angle: avoid fullscreen FBO copy for flipping In order to honor the differences between OpenGL and Direct3D coordinate systems, ANGLE uses a full FBO copy merely to flip the final frame vertically. This can be avoided with the EGL_ANGLE_surface_orientation extension. --- video/out/opengl/context_angle.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c index cb48343d6f..f75dc34f91 100644 --- a/video/out/opengl/context_angle.c +++ b/video/out/opengl/context_angle.c @@ -23,6 +23,12 @@ #include "video/out/w32_common.h" #include "context.h" +#ifndef EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE +#define EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE 0x33A7 +#define EGL_SURFACE_ORIENTATION_ANGLE 0x33A8 +#define EGL_SURFACE_ORIENTATION_INVERT_Y_ANGLE 0x0002 +#endif + struct priv { EGLDisplay egl_display; EGLContext egl_context; @@ -154,8 +160,24 @@ static int angle_init(struct MPGLContext *ctx, int flags) if (!config) goto fail; + 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; + ctx->flip_v = true; + MP_VERBOSE(vo, "Rendering flipped.\n"); + } + } + p->egl_surface = eglCreateWindowSurface(p->egl_display, config, - vo_w32_hwnd(vo), NULL); + vo_w32_hwnd(vo), window_attribs); if (p->egl_surface == EGL_NO_SURFACE) { MP_FATAL(ctx->vo, "Could not create EGL surface!\n"); goto fail; -- cgit v1.2.3