From deeb1d837042f7d95404516bf590aa82aa5e1b4d Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 17 Sep 2015 02:13:03 +1200 Subject: [PATCH] Remove segfault from DX11 backend. Instead of blindly using the expected width, clamp it to the stride of the buffer which dx11 returns. This prevents use from reading invalid memory at the end of textures. This doesn't solve the base issue of what to do when a game tries to copy from outside the efb. On real hardware it returns random noise (biased to all ones) --- Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp index a5fa6de7a5..736bf2f042 100644 --- a/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp +++ b/Source/Core/VideoBackends/D3D/PSTextureEncoder.cpp @@ -152,9 +152,10 @@ void PSTextureEncoder::Encode(u8* dst, const TextureCache::TCacheEntryBase *text CHECK(SUCCEEDED(hr), "map staging buffer (0x%x)", hr); u8* src = (u8*)map.pData; + u32 readStride = std::min(texture_entry->CacheLinesPerRow() * 32, map.RowPitch); for (unsigned int y = 0; y < texture_entry->NumBlocksY(); ++y) { - memcpy(dst, src, texture_entry->CacheLinesPerRow() * 32); + memcpy(dst, src, readStride); dst += texture_entry->memory_stride; src += map.RowPitch; }