From 2ba2062e5b0b53d2b14fc81c377d0b0b3d6f4a99 Mon Sep 17 00:00:00 2001 From: quilloss Date: Fri, 16 Jun 2017 17:51:12 +0800 Subject: context_dxinterop: lock rendertarget after present when swapping buffers Moves the DXLockObjectsNV call to after PresentEx. This fixes an issue where the presented image is a single frame late. This may be due to DXLockObjectsNV locking the render target before StretchRect is done. The spec indicates that the lock call should provide synchronization for the resource, so this may be due to a driver bug. --- video/out/opengl/context_dxinterop.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/video/out/opengl/context_dxinterop.c b/video/out/opengl/context_dxinterop.c index a23318a6a4..507c150d15 100644 --- a/video/out/opengl/context_dxinterop.c +++ b/video/out/opengl/context_dxinterop.c @@ -565,12 +565,6 @@ static void dxinterop_swap_buffers(MPGLContext *ctx) return; } - if (!gl->DXLockObjectsNV(p->device_h, 1, &p->rtarget_h)) { - MP_ERR(ctx->vo, "Couldn't lock rendertarget after stretchrect: %s\n", - mp_LastError_to_str()); - return; - } - hr = IDirect3DDevice9Ex_PresentEx(p->device, NULL, NULL, NULL, NULL, 0); switch (hr) { case D3DERR_DEVICELOST: @@ -578,11 +572,16 @@ static void dxinterop_swap_buffers(MPGLContext *ctx) MP_VERBOSE(ctx->vo, "Direct3D device lost! Resetting.\n"); p->lost_device = true; dxinterop_reset(ctx); - break; + return; default: if (FAILED(hr)) MP_ERR(ctx->vo, "Failed to present: %s\n", mp_HRESULT_to_str(hr)); } + + if (!gl->DXLockObjectsNV(p->device_h, 1, &p->rtarget_h)) { + MP_ERR(ctx->vo, "Couldn't lock rendertarget after present: %s\n", + mp_LastError_to_str()); + } } static int dxinterop_control(MPGLContext *ctx, int *events, int request, -- cgit v1.2.3