From a3bbe8791454697c4d170e1387cbb73f8fdacc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 3 May 2018 23:11:39 +0200 Subject: [PATCH] D3D11 CopyFBToMemory: Clamp rect to fb size. Last-minute style fix, should really debug where the bad parameters came from. Affects MGS Peace Walker intro --- ext/native/thin3d/thin3d_d3d11.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 9cb46b3fc6..2ff8388ca0 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1365,6 +1365,16 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel assert(fb->colorFormat == DXGI_FORMAT_R8G8B8A8_UNORM); } + // TODO: Figure out where the badness really comes from. + if (bx + bw > fb->width) { + bw -= (bx + bw) - fb->width; + } + if (by + bh > fb->height) { + bh -= (by + bh) - fb->height; + } + if (bh <= 0 || bw <= 0) + return true; + bool useGlobalPacktex = (bx + bw <= 512 && by + bh <= 512) && channelBits == FB_COLOR_BIT; ID3D11Texture2D *packTex;