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
This commit is contained in:
Nolan Check 2011-05-06 23:35:48 +00:00
parent c225f8b363
commit 9222a818ae
1 changed files with 11 additions and 18 deletions

View File

@ -290,32 +290,25 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER); D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
// .. and then read back the results. // .. and then read back the results.
// TODO: make this less slow. // TODO: make this less slow.
D3DLOCKED_RECT drect;
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface); hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface);
D3DLOCKED_RECT drect;
hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY); 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 for (int j = 0; j < srcRowsPerBlockRow; ++j)
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++)
{ {
int readDist = dstWidth*readHeight; memcpy(destAddr + j*dstWidth*4, Source, dstWidth*4);
memcpy(destAddr,Source,readDist); Source += drect.Pitch;
Source += readDist;
destAddr += writeStride;
} }
destAddr += bpmem.copyMipMapStrideChannels*32;
} }
else
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
hr = s_texConvReadSurface->UnlockRect(); hr = s_texConvReadSurface->UnlockRect();
} }