From 478b5dcbe145d5e10c9ff0f6dcc5bb03787ab8be Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 19 Mar 2017 14:22:06 +0100 Subject: [PATCH] Fix bug in D3D11 framebuffer readbacks, helps #9361, though seems off by half a pixel? --- GPU/D3D11/FramebufferManagerD3D11.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/D3D11/FramebufferManagerD3D11.cpp b/GPU/D3D11/FramebufferManagerD3D11.cpp index a47c31d105..c67ba5f241 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.cpp +++ b/GPU/D3D11/FramebufferManagerD3D11.cpp @@ -841,6 +841,7 @@ void FramebufferManagerD3D11::PackFramebufferD3D11_(VirtualFramebuffer *vfb, int DEBUG_LOG(G3D, "Reading framebuffer to mem, fb_address = %08x", fb_address); ID3D11Texture2D *colorTex = (ID3D11Texture2D *)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_COLOR_BIT, 0); + // TODO: Only copy the necessary rectangle. D3D11_BOX srcBox{ 0, 0, 0, vfb->width, vfb->height, 1 }; context_->CopySubresourceRegion(packTexture_, 0, 0, 0, 0, colorTex, 0, &srcBox); @@ -858,7 +859,7 @@ void FramebufferManagerD3D11::PackFramebufferD3D11_(VirtualFramebuffer *vfb, int const int srcByteOffset = y * map.RowPitch + x * 4; const int dstByteOffset = (y * vfb->fb_stride + x) * dstBpp; // Pixel size always 4 here because we always request BGRA8888. - ConvertFromRGBA8888(Memory::GetPointer(fb_address + dstByteOffset), (u8 *)map.pData, vfb->fb_stride, map.RowPitch/4, w, h, vfb->format); + ConvertFromRGBA8888(Memory::GetPointer(fb_address + dstByteOffset), (u8 *)map.pData + srcByteOffset, vfb->fb_stride, map.RowPitch/4, w, h, vfb->format); context_->Unmap(packTexture_, 0); }