DXTn stride is to the next block, which is the equivalent to 4 rows

worth of bytes.
This commit is contained in:
Jason Edmeades 2003-10-07 03:31:46 +00:00 committed by Alexandre Julliard
parent ee1eb63b31
commit e0faa866e0
2 changed files with 11 additions and 5 deletions

View File

@ -1487,7 +1487,7 @@ void drawPrimitive(LPDIRECT3DDEVICE8 iface,
TRACE("Saving texture %s (Format:%s)\n", buffer, debug_d3dformat(((IDirect3DBaseTexture8Impl *)This->StateBlock->textures[textureNo])->format)); TRACE("Saving texture %s (Format:%s)\n", buffer, debug_d3dformat(((IDirect3DBaseTexture8Impl *)This->StateBlock->textures[textureNo])->format));
IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) This->StateBlock->textures[textureNo], 0, &pSur); IDirect3DTexture8Impl_GetSurfaceLevel((LPDIRECT3DTEXTURE8) This->StateBlock->textures[textureNo], 0, &pSur);
IDirect3DSurface8Impl_SaveSnapshot(pSur, buffer); IDirect3DSurface8Impl_SaveSnapshot(pSur, buffer);
IDirect3DSurface8Impl_ReleaseRef(pSur); IDirect3DSurface8Impl_Release(pSur);
} }
} }
} }

View File

@ -152,10 +152,16 @@ HRESULT WINAPI IDirect3DSurface8Impl_LockRect(LPDIRECT3DSURFACE8 iface, D3DLOCKE
TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory); TRACE("(%p) : rect@%p flags(%08lx), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->allocatedMemory);
} }
pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */ /* DXTn formats dont have exact pitches as they are to the newt row of blocks,
if (This->myDesc.Format == D3DFMT_DXT1) /* DXT1 is half byte per pixel */ where each block is 4x4 pixels, 8 bytes (dxt1) and 16 bytes (dxt3/5)
pLockedRect->Pitch = pLockedRect->Pitch/2; ie pitch = (width/4) * bytes per block */
if (This->myDesc.Format == D3DFMT_DXT1) /* DXT1 is 8 bytes per block */
pLockedRect->Pitch = (This->myDesc.Width/4) * 8;
else if (This->myDesc.Format == D3DFMT_DXT3 || This->myDesc.Format == D3DFMT_DXT5) /* DXT3/5 is 16 bytes per block */
pLockedRect->Pitch = (This->myDesc.Width/4) * 16;
else
pLockedRect->Pitch = This->bytesPerPixel * This->myDesc.Width; /* Bytes / row */
if (NULL == pRect) { if (NULL == pRect) {
pLockedRect->pBits = This->allocatedMemory; pLockedRect->pBits = This->allocatedMemory;
This->lockedRect.left = 0; This->lockedRect.left = 0;