diff options
author | CrystalP <crystalp@kodi.tv> | 2023-09-05 23:36:40 -0400 |
---|---|---|
committer | CrystalP <crystalp@kodi.tv> | 2023-10-15 02:50:43 -0400 |
commit | d9bf5c7699badbf3dd9c71cf3224bf62edf5e630 (patch) | |
tree | aeb768126d8fd2e6a41505344528db65b97d7ccb | |
parent | d8401a7d41fe79d7336942039402341d41e25613 (diff) | |
download | xbmc-d9bf5c7699badbf3dd9c71cf3224bf62edf5e630.tar.xz |
[Windows] videosync: retrieve refresh rate only on display config change.
The previous condition was true for every frame and retrieved the current refresh rate too often.
IsCurrent() also reacts to display changes other than refresh rate but display changes are rare.
IsCurrent() takes about 1/10th of the time of refresh rate retrieval and mostly saves time
-rw-r--r-- | xbmc/windowing/windows/VideoSyncD3D.cpp | 8 | ||||
-rw-r--r-- | xbmc/windowing/windows/VideoSyncD3D.h | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/xbmc/windowing/windows/VideoSyncD3D.cpp b/xbmc/windowing/windows/VideoSyncD3D.cpp index aad10fe707..99da3d42c1 100644 --- a/xbmc/windowing/windows/VideoSyncD3D.cpp +++ b/xbmc/windowing/windows/VideoSyncD3D.cpp @@ -58,6 +58,8 @@ bool CVideoSyncD3D::Setup() if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) CLog::Log(LOGDEBUG, "CVideoSyncD3D: SetThreadPriority failed"); + CreateDXGIFactory1(IID_PPV_ARGS(m_factory.ReleaseAndGetAddressOf())); + Microsoft::WRL::ComPtr<IDXGIOutput> pOutput; DX::DeviceResources::Get()->GetOutput(&pOutput); pOutput->GetDesc(&m_outputDesc); @@ -76,7 +78,7 @@ void CVideoSyncD3D::Run(CEvent& stopEvent) // init the vblanktime Now = CurrentHostCounter(); LastVBlankTime = Now; - m_lastUpdateTime = Now - systemFrequency; + while (!stopEvent.Signaled() && !m_displayLost && !m_displayReset) { // sleep until vblank @@ -96,8 +98,10 @@ void CVideoSyncD3D::Run(CEvent& stopEvent) // save the timestamp of this vblank so we can calculate how many vblanks happened next time LastVBlankTime = Now; - if ((Now - m_lastUpdateTime) >= systemFrequency) + if (!m_factory->IsCurrent()) { + CreateDXGIFactory1(IID_PPV_ARGS(m_factory.ReleaseAndGetAddressOf())); + float fps = m_fps; if (fps != GetFps()) break; diff --git a/xbmc/windowing/windows/VideoSyncD3D.h b/xbmc/windowing/windows/VideoSyncD3D.h index aa9d80e6af..01664c08d4 100644 --- a/xbmc/windowing/windows/VideoSyncD3D.h +++ b/xbmc/windowing/windows/VideoSyncD3D.h @@ -18,7 +18,7 @@ class CVideoSyncD3D : public CVideoSync, IDispResource { public: CVideoSyncD3D(CVideoReferenceClock* clock) - : CVideoSync(clock), m_displayLost(false), m_displayReset(false), m_lastUpdateTime(0) + : CVideoSync(clock), m_displayLost(false), m_displayReset(false) { } bool Setup() override; @@ -34,7 +34,7 @@ private: volatile bool m_displayLost; volatile bool m_displayReset; CEvent m_lostEvent; - int64_t m_lastUpdateTime; DXGI_OUTPUT_DESC m_outputDesc{}; + Microsoft::WRL::ComPtr<IDXGIFactory2> m_factory; }; |