From 326c55a5713b9aa54317873554c1d11e4dfffe9f Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Tue, 5 May 2020 23:25:22 +1000 Subject: vo_gpu: d3d11: only use presentation feedback with flip model The current implementation of presentation feedback was designed to be used with flip model presentation. With the bitblt model, GetFrameStatistics returns totally different values and it's not clear if we can use them at all. Previously, this wasn't a problem because with the bitblt model, GetFrameStatistics only worked in exclusive fullscreen. Now that mpv supports exclusive fullscreen, we should explicitly check for a flip model swapchain before using presentation feedback. --- video/out/d3d11/context.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index 881962f3be..b77e328b70 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -258,6 +258,15 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info) if (p->opts->sync_interval != 1) return; + // They're also only valid for flip model swapchains + DXGI_SWAP_CHAIN_DESC desc; + hr = IDXGISwapChain_GetDesc(p->swapchain, &desc); + if (FAILED(hr) || (desc.SwapEffect != DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL && + desc.SwapEffect != DXGI_SWAP_EFFECT_FLIP_DISCARD)) + { + return; + } + // GetLastPresentCount returns a sequential ID for the frame submitted by // the last call to IDXGISwapChain::Present() UINT submit_count; @@ -308,10 +317,9 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info) stats.PresentRefreshCount && stats.SyncRefreshCount && stats.SyncQPCTime.QuadPart) { - // PresentRefreshCount and SyncRefreshCount might refer to different - // frames (this can definitely occur in bitblt-mode.) Assuming mpv - // presents on every frame, guess the present count that relates to - // SyncRefreshCount. + // It's not clear if PresentRefreshCount and SyncRefreshCount can refer + // to different frames, but in case they can, assuming mpv presents on + // every frame, guess the present count that relates to SyncRefreshCount. unsigned expected_sync_pc = stats.PresentCount + (stats.SyncRefreshCount - stats.PresentRefreshCount); -- cgit v1.2.3