summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-10-08 18:30:51 +0200
committerDudemanguy <random342@airmail.cc>2023-10-23 00:10:49 +0000
commitf27767f59e2dd459b909b00187b27f3c6fb72a20 (patch)
tree3412341007e66adaa4d34cd7bcbcf585af99cbc7 /video
parentb26d2ab01c8de2404ed6c05db877db0e9fb84e12 (diff)
downloadmpv-f27767f59e2dd459b909b00187b27f3c6fb72a20.tar.bz2
mpv-f27767f59e2dd459b909b00187b27f3c6fb72a20.tar.xz
d3d11: calc vsync interval on real stats, not just last interval
Diffstat (limited to 'video')
-rw-r--r--video/out/d3d11/context.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/video/out/d3d11/context.c b/video/out/d3d11/context.c
index 3f2565338f..05f04fdb6b 100644
--- a/video/out/d3d11/context.c
+++ b/video/out/d3d11/context.c
@@ -103,8 +103,8 @@ struct priv {
struct mp_colorspace swapchain_csp;
int64_t perf_freq;
- unsigned last_sync_refresh_count;
- int64_t last_sync_qpc_time;
+ unsigned sync_refresh_count;
+ int64_t sync_qpc_time;
int64_t vsync_duration_qpc;
int64_t last_submit_qpc;
};
@@ -303,28 +303,33 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info)
DXGI_FRAME_STATISTICS stats;
hr = IDXGISwapChain_GetFrameStatistics(p->swapchain, &stats);
if (hr == DXGI_ERROR_FRAME_STATISTICS_DISJOINT) {
- p->last_sync_refresh_count = 0;
- p->last_sync_qpc_time = 0;
+ p->sync_refresh_count = 0;
+ p->sync_qpc_time = 0;
}
if (FAILED(hr))
return;
+ info->last_queue_display_time = 0;
+ info->vsync_duration = 0;
// Detecting skipped vsyncs is possible but not supported yet
- info->skipped_vsyncs = 0;
+ info->skipped_vsyncs = -1;
- // Get the number of physical vsyncs that have passed since the last call.
+ // Get the number of physical vsyncs that have passed since the start of the
+ // playback or disjoint event.
// Check for 0 here, since sometimes GetFrameStatistics returns S_OK but
// with 0s in some (all?) members of DXGI_FRAME_STATISTICS.
unsigned src_passed = 0;
- if (stats.SyncRefreshCount && p->last_sync_refresh_count)
- src_passed = stats.SyncRefreshCount - p->last_sync_refresh_count;
- p->last_sync_refresh_count = stats.SyncRefreshCount;
+ if (stats.SyncRefreshCount && p->sync_refresh_count)
+ src_passed = stats.SyncRefreshCount - p->sync_refresh_count;
+ if (p->sync_refresh_count == 0)
+ p->sync_refresh_count = stats.SyncRefreshCount;
// Get the elapsed time passed between the above vsyncs
unsigned sqt_passed = 0;
- if (stats.SyncQPCTime.QuadPart && p->last_sync_qpc_time)
- sqt_passed = stats.SyncQPCTime.QuadPart - p->last_sync_qpc_time;
- p->last_sync_qpc_time = stats.SyncQPCTime.QuadPart;
+ if (stats.SyncQPCTime.QuadPart && p->sync_qpc_time)
+ sqt_passed = stats.SyncQPCTime.QuadPart - p->sync_qpc_time;
+ if (p->sync_qpc_time == 0)
+ p->sync_qpc_time = stats.SyncQPCTime.QuadPart;
// If any vsyncs have passed, estimate the physical frame rate
if (src_passed && sqt_passed)