From 9222a818ae01323278406e78e5514e89c9962c7e Mon Sep 17 00:00:00 2001 From: Nolan Check Date: Fri, 6 May 2011 23:35:48 +0000 Subject: [PATCH] DX9: Pay attention to the pitch of a locked surface. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7519 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_VideoDX9/Src/TextureConverter.cpp | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp index ca3c394a4c..627db705bd 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp @@ -290,32 +290,25 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); // .. and then read back the results. // TODO: make this less slow. - - D3DLOCKED_RECT drect; hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface); + + D3DLOCKED_RECT drect; hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY); - int writeStride = bpmem.copyMipMapStrideChannels * 32; - if (writeStride != readStride && toTexture) + int srcRowsPerBlockRow = readStride / (dstWidth*4); // 4 bytes per pixel + + int readLoops = dstHeight / srcRowsPerBlockRow; + const u8 *Source = (const u8*)drect.pBits; + for (int i = 0; i < readLoops; i++) { - // writing to a texture of a different size - - int readHeight = readStride / dstWidth; - - int readStart = 0; - int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel - u8 *Source = (u8*)drect.pBits; - for (int i = 0; i < readLoops; i++) + for (int j = 0; j < srcRowsPerBlockRow; ++j) { - int readDist = dstWidth*readHeight; - memcpy(destAddr,Source,readDist); - Source += readDist; - destAddr += writeStride; + memcpy(destAddr + j*dstWidth*4, Source, dstWidth*4); + Source += drect.Pitch; } + destAddr += bpmem.copyMipMapStrideChannels*32; } - else - memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel hr = s_texConvReadSurface->UnlockRect(); }