From 6a3da439cda7c9075fbca2fcffeb8a28f5149f5d Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Mon, 4 Jul 2016 21:38:36 +1000 Subject: vo_opengl: angle: update the swapchain on resize This uses eglPostSubBufferNV to trigger ANGLE to check the window size and update the size of the swapchain to match, which is recommended here: https://groups.google.com/d/msg/angleproject/RvyVkjRCQGU/gfKfT64IAgAJ With the D3D11 backend, using eglPostSubBufferNV with a 0-sized update region will even skip the Present() call, meaning it won't block for a vsync period. Hopefully ANGLE will have a less hacky way of doing this in future. See the relevant ANGLE issue: http://anglebug.com/1438 Fixes #3301 --- video/out/opengl/context_angle.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'video') diff --git a/video/out/opengl/context_angle.c b/video/out/opengl/context_angle.c index cc14fc32c6..28515f431f 100644 --- a/video/out/opengl/context_angle.c +++ b/video/out/opengl/context_angle.c @@ -38,6 +38,7 @@ struct priv { EGLContext egl_context; EGLSurface egl_surface; bool use_es2; + PFNEGLPOSTSUBBUFFERNVPROC eglPostSubBufferNV; }; static void angle_uninit(MPGLContext *ctx) @@ -288,6 +289,11 @@ static int angle_init(struct MPGLContext *ctx, int flags) // Configure the underlying Direct3D device d3d_init(ctx); + if (strstr(exts, "EGL_NV_post_sub_buffer")) { + p->eglPostSubBufferNV = + (PFNEGLPOSTSUBBUFFERNVPROC)eglGetProcAddress("eglPostSubBufferNV"); + } + mpgl_load_functions(ctx->gl, get_proc_address, NULL, vo->log); return 0; @@ -315,7 +321,16 @@ static int angle_reconfig(struct MPGLContext *ctx) static int angle_control(MPGLContext *ctx, int *events, int request, void *arg) { - return vo_w32_control(ctx->vo, events, request, arg); + struct priv *p = ctx->priv; + int r = vo_w32_control(ctx->vo, events, request, arg); + + // Calling eglPostSubBufferNV with a 0-sized region doesn't present a frame + // or block, but it does update the swapchain to match the window size + // See: https://groups.google.com/d/msg/angleproject/RvyVkjRCQGU/gfKfT64IAgAJ + if ((*events & VO_EVENT_RESIZE) && p->eglPostSubBufferNV) + p->eglPostSubBufferNV(p->egl_display, p->egl_surface, 0, 0, 0, 0); + + return r; } static void angle_swap_buffers(MPGLContext *ctx) -- cgit v1.2.3