mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
wined3d: Fix LockRect memory location calculation for WINED3DFMT_DXT*.
This commit is contained in:
parent
7a43e79087
commit
01199072dd
@ -218,7 +218,7 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
|
||||
offset = (BYTE *)locked_rect.pBits - base;
|
||||
expected_offset = (rect.top / dxt_formats[i].block_height) * locked_rect.Pitch
|
||||
+ (rect.left / dxt_formats[i].block_width) * dxt_formats[i].block_size;
|
||||
todo_wine ok(offset == expected_offset, "Got offset %u, expected offset %u for format %s\n", offset, expected_offset, dxt_formats[i].name);
|
||||
ok(offset == expected_offset, "Got offset %u, expected offset %u for format %s\n", offset, expected_offset, dxt_formats[i].name);
|
||||
|
||||
hr = IDirect3DSurface9_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
|
||||
|
@ -623,8 +623,18 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
|
||||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
if (This->resource.format == WINED3DFMT_DXT1) { /* DXT1 is half byte per pixel */
|
||||
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + ((pRect->left * This->bytesPerPixel / 2));
|
||||
/* DXTn textures are based on compressed blocks of 4x4 pixels, each
|
||||
* 16 bytes large (8 bytes in case of DXT1). Because of that Pitch has
|
||||
* slightly different meaning compared to regular textures. For DXTn
|
||||
* textures Pitch is the size of a row of blocks, 4 high and "width"
|
||||
* long. The x offset is calculated differently as well, since moving 4
|
||||
* pixels to the right actually moves an entire 4x4 block to right, ie
|
||||
* 16 bytes (8 in case of DXT1). */
|
||||
if (This->resource.format == WINED3DFMT_DXT1) {
|
||||
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 2);
|
||||
} else if (This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3
|
||||
|| This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5) {
|
||||
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top / 4) + (pRect->left * 4);
|
||||
} else {
|
||||
pLockedRect->pBits = This->resource.allocatedMemory + (pLockedRect->Pitch * pRect->top) + (pRect->left * This->bytesPerPixel);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user