diff --git a/src/dxgi/dxgi_swapchain.cpp b/src/dxgi/dxgi_swapchain.cpp index 1e6d9d446..2e565dedf 100644 --- a/src/dxgi/dxgi_swapchain.cpp +++ b/src/dxgi/dxgi_swapchain.cpp @@ -100,6 +100,11 @@ namespace dxvk { if (!IsWindow(m_window)) return DXGI_ERROR_INVALID_CALL; + if (m_target != nullptr) { + *ppOutput = m_target.ref(); + return S_OK; + } + RECT windowRect = { 0, 0, 0, 0 }; ::GetWindowRect(m_window, &windowRect); @@ -185,13 +190,9 @@ namespace dxvk { if (pFullscreen != nullptr) *pFullscreen = !m_descFs.Windowed; - if (ppTarget != nullptr) { - *ppTarget = nullptr; - - if (!m_descFs.Windowed) - hr = GetOutputFromMonitor(m_monitor, ppTarget); - } - + if (ppTarget != nullptr) + *ppTarget = m_target.ref(); + return hr; } @@ -532,7 +533,7 @@ namespace dxvk { HRESULT DxgiSwapChain::EnterFullscreenMode(IDXGIOutput* pTarget) { - Com output = static_cast(pTarget); + Com output = pTarget; if (!IsWindow(m_window)) return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; @@ -591,6 +592,7 @@ namespace dxvk { SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE); m_monitor = desc.Monitor; + m_target = std::move(output); // Apply current gamma curve of the output DXGI_VK_MONITOR_DATA* monitorInfo = nullptr; @@ -628,6 +630,7 @@ namespace dxvk { // Restore internal state m_descFs.Windowed = TRUE; m_monitor = nullptr; + m_target = nullptr; // Only restore the window style if the application hasn't // changed them. This is in line with what native DXGI does. diff --git a/src/dxgi/dxgi_swapchain.h b/src/dxgi/dxgi_swapchain.h index 8a60b2710..b39ff6f47 100644 --- a/src/dxgi/dxgi_swapchain.h +++ b/src/dxgi/dxgi_swapchain.h @@ -178,6 +178,7 @@ namespace dxvk { Com m_factory; Com m_adapter; + Com m_target; Com m_monitorInfo; HWND m_window;