From e281eee795bd4e0194446687dfd8ca5dd9b2351c Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 9 Jun 2021 03:47:20 +0200 Subject: [PATCH] [dxgi] Add NotifyModeChange method to IDXGIVkSwapChain --- src/d3d11/d3d11_swapchain.cpp | 16 ++++++++++++++++ src/d3d11/d3d11_swapchain.h | 4 ++++ src/dxgi/dxgi_interfaces.h | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/src/d3d11/d3d11_swapchain.cpp b/src/d3d11/d3d11_swapchain.cpp index a78515df1..c250bf77e 100644 --- a/src/d3d11/d3d11_swapchain.cpp +++ b/src/d3d11/d3d11_swapchain.cpp @@ -233,6 +233,22 @@ namespace dxvk { } + void STDMETHODCALLTYPE D3D11SwapChain::NotifyModeChange( + BOOL Windowed, + const DXGI_MODE_DESC* pDisplayMode) { + if (Windowed || !pDisplayMode) { + // Display modes aren't meaningful in windowed mode + m_displayRefreshRate = 0.0; + } else { + DXGI_RATIONAL rate = pDisplayMode->RefreshRate; + m_displayRefreshRate = double(rate.Numerator) / double(rate.Denominator); + } + + if (m_presenter != nullptr) + m_presenter->setFrameRateLimiterRefreshRate(m_displayRefreshRate); + } + + HRESULT D3D11SwapChain::PresentImage(UINT SyncInterval) { Com deviceContext = nullptr; m_parent->GetImmediateContext(&deviceContext); diff --git a/src/d3d11/d3d11_swapchain.h b/src/d3d11/d3d11_swapchain.h index 65e1f5f96..530fdca3e 100644 --- a/src/d3d11/d3d11_swapchain.h +++ b/src/d3d11/d3d11_swapchain.h @@ -69,6 +69,10 @@ namespace dxvk { UINT PresentFlags, const DXGI_PRESENT_PARAMETERS* pPresentParameters); + void STDMETHODCALLTYPE NotifyModeChange( + BOOL Windowed, + const DXGI_MODE_DESC* pDisplayMode); + private: enum BindingIds : uint32_t { diff --git a/src/dxgi/dxgi_interfaces.h b/src/dxgi/dxgi_interfaces.h index 427f3976f..f7a939503 100644 --- a/src/dxgi/dxgi_interfaces.h +++ b/src/dxgi/dxgi_interfaces.h @@ -75,6 +75,10 @@ IDXGIVkSwapChain : public IUnknown { UINT SyncInterval, UINT PresentFlags, const DXGI_PRESENT_PARAMETERS* pPresentParameters) = 0; + + virtual void STDMETHODCALLTYPE NotifyModeChange( + BOOL Windowed, + const DXGI_MODE_DESC* pDisplayMode) = 0; };