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

Revert "d3d11: calc vsync interval on real stats, not just last interval"

The values provided since last disjoint event may include significant
error in case there are periods of slower presentation. We should look
at more localized/current values of presentation.

For more accurate approximation of vsync rate I plan to add better
algorithm to calculate it.

Revert this commit alone as it is not neccessary and gives as separation
from other changes for better regression testing.

This reverts commit f27767f59e.
This commit is contained in:
Kacper Michajłow 2024-04-21 22:57:23 +02:00
parent e95af5b607
commit d3b251bb99

View File

@ -99,8 +99,8 @@ struct priv {
struct pl_color_space swapchain_csp; struct pl_color_space swapchain_csp;
int64_t perf_freq; int64_t perf_freq;
unsigned sync_refresh_count; unsigned last_sync_refresh_count;
int64_t sync_qpc_time; int64_t last_sync_qpc_time;
int64_t vsync_duration_qpc; int64_t vsync_duration_qpc;
int64_t last_submit_qpc; int64_t last_submit_qpc;
}; };
@ -273,33 +273,28 @@ static void d3d11_get_vsync(struct ra_swapchain *sw, struct vo_vsync_info *info)
DXGI_FRAME_STATISTICS stats; DXGI_FRAME_STATISTICS stats;
hr = IDXGISwapChain_GetFrameStatistics(p->swapchain, &stats); hr = IDXGISwapChain_GetFrameStatistics(p->swapchain, &stats);
if (hr == DXGI_ERROR_FRAME_STATISTICS_DISJOINT) { if (hr == DXGI_ERROR_FRAME_STATISTICS_DISJOINT) {
p->sync_refresh_count = 0; p->last_sync_refresh_count = 0;
p->sync_qpc_time = 0; p->last_sync_qpc_time = 0;
} }
if (FAILED(hr)) if (FAILED(hr))
return; return;
info->last_queue_display_time = 0;
info->vsync_duration = 0;
// Detecting skipped vsyncs is possible but not supported yet // Detecting skipped vsyncs is possible but not supported yet
info->skipped_vsyncs = -1; info->skipped_vsyncs = -1;
// Get the number of physical vsyncs that have passed since the start of the // Get the number of physical vsyncs that have passed since the last call.
// playback or disjoint event.
// Check for 0 here, since sometimes GetFrameStatistics returns S_OK but // Check for 0 here, since sometimes GetFrameStatistics returns S_OK but
// with 0s in some (all?) members of DXGI_FRAME_STATISTICS. // with 0s in some (all?) members of DXGI_FRAME_STATISTICS.
unsigned src_passed = 0; unsigned src_passed = 0;
if (stats.SyncRefreshCount && p->sync_refresh_count) if (stats.SyncRefreshCount && p->last_sync_refresh_count)
src_passed = stats.SyncRefreshCount - p->sync_refresh_count; src_passed = stats.SyncRefreshCount - p->last_sync_refresh_count;
if (p->sync_refresh_count == 0) p->last_sync_refresh_count = stats.SyncRefreshCount;
p->sync_refresh_count = stats.SyncRefreshCount;
// Get the elapsed time passed between the above vsyncs // Get the elapsed time passed between the above vsyncs
unsigned sqt_passed = 0; unsigned sqt_passed = 0;
if (stats.SyncQPCTime.QuadPart && p->sync_qpc_time) if (stats.SyncQPCTime.QuadPart && p->last_sync_qpc_time)
sqt_passed = stats.SyncQPCTime.QuadPart - p->sync_qpc_time; sqt_passed = stats.SyncQPCTime.QuadPart - p->last_sync_qpc_time;
if (p->sync_qpc_time == 0) p->last_sync_qpc_time = stats.SyncQPCTime.QuadPart;
p->sync_qpc_time = stats.SyncQPCTime.QuadPart;
// If any vsyncs have passed, estimate the physical frame rate // If any vsyncs have passed, estimate the physical frame rate
if (src_passed && sqt_passed) if (src_passed && sqt_passed)