From 60ff2b897704700d3ea5cf8fe87a6ba00e0194ae Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 1 Oct 2019 23:34:11 +0200 Subject: [PATCH] [dxgi] Fix GetContainingOutput and GetFullscreenState output pointer We're supposed to keep a reference to the output around and return that for fullscreen swap chains. Fixes various wine test failures. --- src/dxgi/dxgi_swapchain.cpp | 19 +++++++++++-------- src/dxgi/dxgi_swapchain.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) 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;