diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp index 79ed4a489..d03e3d1e7 100644 --- a/src/d3d11/d3d11_device.cpp +++ b/src/d3d11/d3d11_device.cpp @@ -1,6 +1,7 @@ #include #include +#include "../dxgi/dxgi_monitor.h" #include "../dxgi/dxgi_swapchain.h" #include "../dxvk/dxvk_adapter.h" @@ -1720,10 +1721,44 @@ namespace dxvk { if (!ppSwapChain || !pDesc || !hWnd) return DXGI_ERROR_INVALID_CALL; - return CreateDxvkSwapChainForHwnd( - pFactory, m_device, hWnd, pDesc, - pFullscreenDesc, pRestrictToOutput, - ppSwapChain); + // Make sure the back buffer size is not zero + DXGI_SWAP_CHAIN_DESC1 desc = *pDesc; + + GetWindowClientSize(hWnd, + desc.Width ? nullptr : &desc.Width, + desc.Height ? nullptr : &desc.Height); + + // If necessary, set up a default set of + // fullscreen parameters for the swap chain + DXGI_SWAP_CHAIN_FULLSCREEN_DESC fsDesc; + + if (pFullscreenDesc) { + fsDesc = *pFullscreenDesc; + } else { + fsDesc.RefreshRate = { 0, 0 }; + fsDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + fsDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + fsDesc.Windowed = TRUE; + } + + // Create presenter for the device + Com presenter; + + HRESULT hr = m_device->CreateSwapChainForHwnd( + hWnd, &desc, &presenter); + + if (FAILED(hr)) + return hr; + + try { + // Create actual swap chain object + *ppSwapChain = ref(new DxgiSwapChain( + pFactory, presenter.ptr(), hWnd, &desc, &fsDesc)); + return S_OK; + } catch (const DxvkError& e) { + Logger::err(e.message()); + return DXGI_ERROR_UNSUPPORTED; + } } diff --git a/src/dxgi/dxgi_swapchain.cpp b/src/dxgi/dxgi_swapchain.cpp index 3c94edb95..e47a55727 100644 --- a/src/dxgi/dxgi_swapchain.cpp +++ b/src/dxgi/dxgi_swapchain.cpp @@ -688,53 +688,4 @@ namespace dxvk { return DXGI_ERROR_NOT_FOUND; } - - HRESULT CreateDxvkSwapChainForHwnd( - IDXGIFactory* pFactory, - IDXGIVkPresentDevice* pDevice, - HWND hWnd, - const DXGI_SWAP_CHAIN_DESC1* pDesc, - const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain) { - // Make sure the back buffer size is not zero - DXGI_SWAP_CHAIN_DESC1 desc = *pDesc; - - GetWindowClientSize(hWnd, - desc.Width ? nullptr : &desc.Width, - desc.Height ? nullptr : &desc.Height); - - // If necessary, set up a default set of - // fullscreen parameters for the swap chain - DXGI_SWAP_CHAIN_FULLSCREEN_DESC fsDesc; - - if (pFullscreenDesc) { - fsDesc = *pFullscreenDesc; - } else { - fsDesc.RefreshRate = { 0, 0 }; - fsDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; - fsDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; - fsDesc.Windowed = TRUE; - } - - // Create presenter for the device - Com presenter; - - HRESULT hr = pDevice->CreateSwapChainForHwnd( - hWnd, &desc, &presenter); - - if (FAILED(hr)) - return hr; - - try { - // Create actual swap chain object - *ppSwapChain = ref(new DxgiSwapChain( - pFactory, presenter.ptr(), hWnd, &desc, &fsDesc)); - return S_OK; - } catch (const DxvkError& e) { - Logger::err(e.message()); - return DXGI_ERROR_UNSUPPORTED; - } - } - } diff --git a/src/dxgi/dxgi_swapchain.h b/src/dxgi/dxgi_swapchain.h index 8e7f7aa01..05848edf9 100644 --- a/src/dxgi/dxgi_swapchain.h +++ b/src/dxgi/dxgi_swapchain.h @@ -205,14 +205,4 @@ namespace dxvk { }; - - HRESULT CreateDxvkSwapChainForHwnd( - IDXGIFactory* pFactory, - IDXGIVkPresentDevice* pDevice, - HWND hWnd, - const DXGI_SWAP_CHAIN_DESC1* pDesc, - const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc, - IDXGIOutput* pRestrictToOutput, - IDXGISwapChain1** ppSwapChain); - }