diff --git a/src/dxgi/dxgi_adapter.cpp b/src/dxgi/dxgi_adapter.cpp index 1f3b2bd7..5e731e79 100644 --- a/src/dxgi/dxgi_adapter.cpp +++ b/src/dxgi/dxgi_adapter.cpp @@ -321,28 +321,6 @@ namespace dxvk { } - HRESULT DxgiAdapter::GetOutputFromMonitor( - HMONITOR Monitor, - IDXGIOutput** ppOutput) { - if (ppOutput == nullptr) - return DXGI_ERROR_INVALID_CALL; - - for (uint32_t i = 0; SUCCEEDED(EnumOutputs(i, ppOutput)); i++) { - DXGI_OUTPUT_DESC outputDesc; - (*ppOutput)->GetDesc(&outputDesc); - - if (outputDesc.Monitor == Monitor) - return S_OK; - - (*ppOutput)->Release(); - (*ppOutput) = nullptr; - } - - // No such output found - return DXGI_ERROR_NOT_FOUND; - } - - HRESULT DxgiAdapter::GetOutputData( HMONITOR Monitor, DXGI_VK_OUTPUT_DATA* pOutputData) { diff --git a/src/dxgi/dxgi_adapter.h b/src/dxgi/dxgi_adapter.h index 4724d6ef..38c6dcde 100644 --- a/src/dxgi/dxgi_adapter.h +++ b/src/dxgi/dxgi_adapter.h @@ -76,10 +76,6 @@ namespace dxvk { DXGI_FORMAT Format, DXGI_VK_FORMAT_MODE Mode); - HRESULT GetOutputFromMonitor( - HMONITOR Monitor, - IDXGIOutput** ppOutput); - HRESULT GetOutputData( HMONITOR Monitor, DXGI_VK_OUTPUT_DATA* pOutputData); diff --git a/src/dxgi/dxgi_swapchain.cpp b/src/dxgi/dxgi_swapchain.cpp index 06e2be92..6495711b 100644 --- a/src/dxgi/dxgi_swapchain.cpp +++ b/src/dxgi/dxgi_swapchain.cpp @@ -45,7 +45,7 @@ namespace dxvk { DxgiSwapChain::~DxgiSwapChain() { Com output; - if (SUCCEEDED(m_adapter->GetOutputFromMonitor(m_monitor, &output))) + if (SUCCEEDED(GetOutputFromMonitor(m_monitor, &output))) RestoreDisplayMode(output.ptr()); } @@ -104,7 +104,7 @@ namespace dxvk { (windowRect.top + windowRect.bottom) / 2 }, MONITOR_DEFAULTTOPRIMARY); - return m_adapter->GetOutputFromMonitor(monitor, ppOutput); + return GetOutputFromMonitor(monitor, ppOutput); } @@ -185,7 +185,7 @@ namespace dxvk { *ppTarget = nullptr; if (!m_descFs.Windowed) - hr = m_adapter->GetOutputFromMonitor(m_monitor, ppTarget); + hr = GetOutputFromMonitor(m_monitor, ppTarget); } return hr; @@ -358,7 +358,7 @@ namespace dxvk { } else { Com output; - if (FAILED(m_adapter->GetOutputFromMonitor(m_monitor, &output))) { + if (FAILED(GetOutputFromMonitor(m_monitor, &output))) { Logger::err("DXGI: ResizeTarget: Failed to query containing output"); return E_FAIL; } @@ -570,7 +570,7 @@ namespace dxvk { if (!IsWindow(m_window)) return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; - if (FAILED(m_adapter->GetOutputFromMonitor(m_monitor, &output)) + if (FAILED(GetOutputFromMonitor(m_monitor, &output)) || FAILED(RestoreDisplayMode(output.ptr()))) Logger::warn("DXGI: LeaveFullscreenMode: Failed to restore display mode"); @@ -677,4 +677,25 @@ namespace dxvk { return E_INVALIDARG; } + + HRESULT DxgiSwapChain::GetOutputFromMonitor( + HMONITOR Monitor, + IDXGIOutput** ppOutput) { + if (!ppOutput) + return DXGI_ERROR_INVALID_CALL; + + for (uint32_t i = 0; SUCCEEDED(m_adapter->EnumOutputs(i, ppOutput)); i++) { + DXGI_OUTPUT_DESC outputDesc; + (*ppOutput)->GetDesc(&outputDesc); + + if (outputDesc.Monitor == Monitor) + return S_OK; + + (*ppOutput)->Release(); + (*ppOutput) = nullptr; + } + + return DXGI_ERROR_NOT_FOUND; + } + } diff --git a/src/dxgi/dxgi_swapchain.h b/src/dxgi/dxgi_swapchain.h index 8c86b68e..e6e5e77f 100644 --- a/src/dxgi/dxgi_swapchain.h +++ b/src/dxgi/dxgi_swapchain.h @@ -201,6 +201,10 @@ namespace dxvk { IUnknown* pDevice, IDXGIVkSwapChain** ppSwapChain); + HRESULT GetOutputFromMonitor( + HMONITOR Monitor, + IDXGIOutput** ppOutput); + }; }