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:
parent
c225f8b363
commit
9222a818ae
|
@ -291,31 +291,24 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
|
|||
// .. 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)
|
||||
{
|
||||
// writing to a texture of a different size
|
||||
int srcRowsPerBlockRow = readStride / (dstWidth*4); // 4 bytes per pixel
|
||||
|
||||
int readHeight = readStride / dstWidth;
|
||||
|
||||
int readStart = 0;
|
||||
int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel
|
||||
u8 *Source = (u8*)drect.pBits;
|
||||
int readLoops = dstHeight / srcRowsPerBlockRow;
|
||||
const u8 *Source = (const u8*)drect.pBits;
|
||||
for (int i = 0; i < readLoops; i++)
|
||||
{
|
||||
int readDist = dstWidth*readHeight;
|
||||
memcpy(destAddr,Source,readDist);
|
||||
Source += readDist;
|
||||
destAddr += writeStride;
|
||||
for (int j = 0; j < srcRowsPerBlockRow; ++j)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue