From 1d5894a56b3fe303ac5e5b183197aca649bacf21 Mon Sep 17 00:00:00 2001 From: Aric Cyr Date: Mon, 8 Nov 2021 16:43:22 -0500 Subject: [PATCH] Fix fallback to CPU timer - Bump version to 0.962 - Use CPU timer if present duration doesn't match requested exactly Change-Id: I24f56bd828d523b261dc7dab4a6522e14e575e44 --- Game.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/Game.cpp b/Game.cpp index b2aa0c3..80f0cfd 100644 --- a/Game.cpp +++ b/Game.cpp @@ -9,7 +9,7 @@ // //********************************************************* -#define versionString L"v0.961" +#define versionString L"v0.962" #include "pch.h" @@ -800,17 +800,8 @@ void Game::Tick() static_cast(m_mediaPresentDuration), &closestSmallerDuration, &closestLargerDuration); // Check that one of the neighboring Durations matches our goal - if (hr == S_OK && (closestLargerDuration != 0 || closestSmallerDuration != 0)) + if (hr == S_OK && (m_mediaPresentDuration == closestLargerDuration || m_mediaPresentDuration == closestSmallerDuration)) { - if ((m_mediaPresentDuration - closestSmallerDuration) < (closestLargerDuration - m_mediaPresentDuration)) - { - m_mediaPresentDuration = closestSmallerDuration; - } - else - { - m_mediaPresentDuration = closestLargerDuration; - } - // then the rate is valid and we can set it hr = scMedia->SetPresentDuration(static_cast(m_mediaPresentDuration)); if (hr != S_OK) @@ -818,17 +809,17 @@ void Game::Tick() m_mediaPresentDuration = 0; } } + else + { + // PresentDuration is not to be used + m_mediaPresentDuration = 0; + } } } else { // PresentDuration is not to be used m_mediaPresentDuration = 0; - - if (m_vTotalFixedApproved) - { - scMedia->SetPresentDuration(0); - } } hr = scMedia->GetFrameStatisticsMedia(&mediaStats); @@ -843,6 +834,11 @@ void Game::Tick() // if we didnt get PresentDuration mode, maybe we got an MPO: m_MPO = false; + if (m_vTotalFixedSupported && m_vTotalFixedApproved) + { + scMedia->SetPresentDuration(0); + } + if (mediaStats.CompositionMode == DXGI_FRAME_PRESENTATION_MODE_OVERLAY) { m_MPO = true;