From eaa732d0b34374eeb088d3411017aed98423d033 Mon Sep 17 00:00:00 2001 From: Robin Kertels Date: Wed, 7 Feb 2024 00:10:43 +0100 Subject: [PATCH] [d3d9] Place GetFrontBufferData screenshot at window position --- src/d3d9/d3d9_swapchain.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp index 1d9c50c1..a19ca55a 100644 --- a/src/d3d9/d3d9_swapchain.cpp +++ b/src/d3d9/d3d9_swapchain.cpp @@ -382,6 +382,20 @@ namespace dxvk { blitInfo.srcOffsets[0] = VkOffset3D{ 0, 0, 0 }; blitInfo.srcOffsets[1] = VkOffset3D{ int32_t(srcExtent.width), int32_t(srcExtent.height), 1 }; +#ifdef _WIN32 + if (m_presentParams.Windowed) { + // In windowed mode, GetFrontBufferData takes a screenshot of the entire screen. + // So place the copy of the front buffer at the position of the window. + POINT point = { 0, 0 }; + if (ClientToScreen(m_window, &point) != 0) { + blitInfo.dstOffsets[0].x = point.x; + blitInfo.dstOffsets[0].y = point.y; + blitInfo.dstOffsets[1].x += point.x; + blitInfo.dstOffsets[1].y += point.y; + } + } +#endif + m_parent->EmitCs([ cDstImage = blittedSrc, cDstMap = dstTexInfo->GetMapping().Swizzle,