diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 10ed13fe..46089035 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -183,6 +183,8 @@ namespace dxvk { m_activeRTsWhichAreTextures = 0; m_alphaSwizzleRTs = 0; m_lastHazardsRT = 0; + + m_gamescopeWSI = dxvk::env::getEnvVar("ENABLE_GAMESCOPE_WSI") == "1"; } @@ -1094,7 +1096,9 @@ namespace dxvk { return D3DERR_INVALIDCALL; #ifdef _WIN32 - return D3D9SwapChainEx::GetFrontBufferDataGDI(pDestSurface); + if (!IsGamescopeWSIEnabled()) { + return D3D9SwapChainEx::GetFrontBufferDataGDI(pDestSurface); + } #endif D3D9DeviceLock lock = LockDevice(); diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index 114a0b9b..79c757ed 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -1273,6 +1273,10 @@ namespace dxvk { m_mostRecentlyUsedSwapchain = m_implicitSwapchain.ptr(); } + bool IsGamescopeWSIEnabled() const { + return m_gamescopeWSI; + } + Com m_parent; D3DDEVTYPE m_deviceType; HWND m_window; @@ -1439,6 +1443,8 @@ namespace dxvk { D3D9SwapChainEx* m_mostRecentlyUsedSwapchain = nullptr; + bool m_gamescopeWSI; + #ifdef D3D9_ALLOW_UNMAPPING lru_list m_mappedTextures; #endif diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 107a92b5..6ef582ee 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -321,7 +321,7 @@ namespace dxvk { HRESULT STDMETHODCALLTYPE D3D9SwapChainEx::GetFrontBufferData(IDirect3DSurface9* pDestSurface) { #ifdef _WIN32 - if (m_presentParams.Windowed || !HasFrontBuffer()) { + if (!m_parent->IsGamescopeWSIEnabled() && (m_presentParams.Windowed || !HasFrontBuffer())) { return D3D9SwapChainEx::GetFrontBufferDataGDI(pDestSurface); } #endif