From d3ee46f3762b3b87a145fb543e46d420a9851275 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 6 Aug 2026 17:24:44 +1000 Subject: [PATCH] [idd] scheduler: prioritize deadline publication --- idd/LGIdd/CFrameScheduler.cpp | 39 +++++++++++++++++-------------- idd/LGIdd/CSwapChainProcessor.cpp | 7 +++++- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/idd/LGIdd/CFrameScheduler.cpp b/idd/LGIdd/CFrameScheduler.cpp index 805f2fcc..4eefa867 100644 --- a/idd/LGIdd/CFrameScheduler.cpp +++ b/idd/LGIdd/CFrameScheduler.cpp @@ -979,29 +979,34 @@ void CFrameScheduler::LogStatistics(uint64_t now) return; } - const uint64_t elapsed = now - m_lastLog; - const uint64_t acquired = m_acquiredFrames - m_lastLogAcquired; - const uint64_t skipped = m_skippedFrames - m_lastLogSkipped; - const uint64_t published = m_publishedFrames - m_lastLogPublished; - const double acquiredRate = - static_cast(acquired) * 1000000000.0 / elapsed; - DEBUG_TRACE("Frame schedule owner %u: %.3f Hz client, %.3f Hz acquired, " - "%.3f ms work, %.3f ms phase; %llu acquired, %llu skipped, " - "%llu published", - m_schedule.clientID, - 1000000000.0 / m_schedule.period, - acquiredRate, - m_workEstimate / 1000000.0, - m_lastPhaseError / 1000000.0, - static_cast(acquired), - static_cast(skipped), - static_cast(published)); + const uint32_t clientID = m_schedule.clientID; + const uint64_t period = m_schedule.period; + const uint64_t workEstimate = m_workEstimate; + const int64_t phaseError = m_lastPhaseError; + const uint64_t elapsed = now - m_lastLog; + const uint64_t acquired = m_acquiredFrames - m_lastLogAcquired; + const uint64_t skipped = m_skippedFrames - m_lastLogSkipped; + const uint64_t published = m_publishedFrames - m_lastLogPublished; m_lastLog = now; m_lastLogAcquired = m_acquiredFrames; m_lastLogSkipped = m_skippedFrames; m_lastLogPublished = m_publishedFrames; ReleaseSRWLockExclusive(&m_lock); + + const double acquiredRate = + static_cast(acquired) * 1000000000.0 / elapsed; + DEBUG_TRACE("Frame schedule owner %u: %.3f Hz client, %.3f Hz acquired, " + "%.3f ms work, %.3f ms phase; %llu acquired, %llu skipped, " + "%llu published", + clientID, + 1000000000.0 / period, + acquiredRate, + workEstimate / 1000000.0, + phaseError / 1000000.0, + static_cast(acquired), + static_cast(skipped), + static_cast(published)); } void CFrameScheduler::TryRecordFrameTiming(uint64_t duration) diff --git a/idd/LGIdd/CSwapChainProcessor.cpp b/idd/LGIdd/CSwapChainProcessor.cpp index dc3a9d5f..a8187943 100644 --- a/idd/LGIdd/CSwapChainProcessor.cpp +++ b/idd/LGIdd/CSwapChainProcessor.cpp @@ -280,6 +280,10 @@ void CSwapChainProcessor::PublisherThread() { DWORD avTask = 0; HANDLE avTaskHandle = AvSetMmThreadCharacteristicsW(L"Distribution", &avTask); + if (avTaskHandle && + !AvSetMmThreadPriority(avTaskHandle, AVRT_PRIORITY_HIGH)) + DEBUG_WARN("Failed to raise publisher MMCSS priority: %lu", + GetLastError()); const HANDLE scheduleEvent = m_devContext->GetFrameScheduleEvent(); HANDLE idleHandles[] = @@ -490,7 +494,8 @@ void CSwapChainProcessor::PublisherThread() } } - AvRevertMmThreadCharacteristics(avTaskHandle); + if (avTaskHandle) + AvRevertMmThreadCharacteristics(avTaskHandle); } void CSwapChainProcessor::SwapChainThread()