1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-26 10:14:33 +00:00

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.
This commit is contained in:
James Ross-Gowan 2019-09-24 23:05:37 +10:00 committed by Jan Ekström
parent 9d4f16b10d
commit 03cb8755e1

View File

@ -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;