From 03cb8755e18cafa81acbcedb81a390a684a46021 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Tue, 24 Sep 2019 23:05:37 +1000 Subject: vo_gpu: d3d11: don't reset frame stats after pause I think I was wrong about having to reset the stats when mpv stops producing frames, eg. when it's paused. As long as the swapchain doesn't underflow, last_queue_display_time will still be accurate, because the next frame produced should still be presented one vsync after the last one in the swapchain. If the swapchain underflows (which is the common case for when mpv is paused for more than 150ms,) the next predicted frame time should be in the past. It should be fine to leave last_queue_display_time unset in this case, since vo.c will use the current time instead, which is a decent guess (though it doesn't take vsync phase into account.) last_sync_refresh_count and last_sync_qpc_time should be kept on swapchain underflow as well. Assuming the display refresh rate doesn't change while mpv is paused, they'll only provide a more accurate guess of the vsync duration when mpv starts playing again. Also, vsync_duration_qpc never needs to get reset. It will get overwritten immediately in most cases, and when it doesn't, it's still a better guess of the vsync duration than nothing. --- video/out/d3d11/context.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c index fd867c243e..f596fb09d4 100644 --- a/video/out/d3d11/context.c +++ b/video/out/d3d11/context.c @@ -203,7 +203,6 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info) if (hr == DXGI_ERROR_FRAME_STATISTICS_DISJOINT) { p->last_sync_refresh_count = 0; p->last_sync_qpc_time = 0; - p->vsync_duration_qpc = 0; } if (FAILED(hr)) return; @@ -260,15 +259,7 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info) static int d3d11_control(struct ra_ctx *ctx, int *events, int request, void *arg) { - struct priv *p = ctx->priv; - int ret = vo_w32_control(ctx->vo, events, request, arg); - if (request == VOCTRL_RESUME) { - // Reset frame statistics after pause - p->last_sync_refresh_count = 0; - p->last_sync_qpc_time = 0; - p->vsync_duration_qpc = 0; - } if (*events & VO_EVENT_RESIZE) { if (!resize(ctx)) return VO_ERROR; -- cgit v1.2.3