mirror of
https://github.com/reactos/wine.git
synced 2024-11-29 06:30:37 +00:00
d3d9: Add a LockRect test for DXTn formats.
This commit is contained in:
parent
fd64779fd0
commit
1283772a26
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Henri Verbeet
|
||||
* Copyright 2006-2007 Henri Verbeet
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -172,6 +172,61 @@ static void test_surface_alignment(IDirect3DDevice9 *device_ptr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Since the DXT formats are based on 4x4 blocks, locking works slightly
|
||||
* different than with regular formats. This patch verifies we return the
|
||||
* correct memory offsets */
|
||||
static void test_lockrect_offset(IDirect3DDevice9 *device)
|
||||
{
|
||||
IDirect3DSurface9 *surface = 0;
|
||||
const RECT rect = {60, 60, 68, 68};
|
||||
D3DLOCKED_RECT locked_rect;
|
||||
unsigned int expected_offset;
|
||||
unsigned int offset;
|
||||
unsigned int i;
|
||||
BYTE *base;
|
||||
HRESULT hr;
|
||||
|
||||
const struct {
|
||||
D3DFORMAT fmt;
|
||||
const char *name;
|
||||
unsigned int block_width;
|
||||
unsigned int block_height;
|
||||
unsigned int block_size;
|
||||
} dxt_formats[] = {
|
||||
{D3DFMT_DXT1, "D3DFMT_DXT1", 4, 4, 8},
|
||||
{D3DFMT_DXT2, "D3DFMT_DXT2", 4, 4, 16},
|
||||
{D3DFMT_DXT3, "D3DFMT_DXT3", 4, 4, 16},
|
||||
{D3DFMT_DXT4, "D3DFMT_DXT4", 4, 4, 16},
|
||||
{D3DFMT_DXT5, "D3DFMT_DXT5", 4, 4, 16},
|
||||
};
|
||||
|
||||
for (i = 0; i < (sizeof(dxt_formats) / sizeof(*dxt_formats)); ++i) {
|
||||
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128, dxt_formats[i].fmt, D3DPOOL_SCRATCH, &surface, 0);
|
||||
ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed (%08x)\n", hr);
|
||||
|
||||
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 0);
|
||||
ok(SUCCEEDED(hr), "LockRect failed (%08x)\n", hr);
|
||||
|
||||
base = locked_rect.pBits;
|
||||
|
||||
hr = IDirect3DSurface9_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
|
||||
|
||||
hr = IDirect3DSurface9_LockRect(surface, &locked_rect, &rect, 0);
|
||||
ok(SUCCEEDED(hr), "LockRect failed (%08x)\n", hr);
|
||||
|
||||
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);
|
||||
|
||||
hr = IDirect3DSurface9_UnlockRect(surface);
|
||||
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
|
||||
|
||||
IDirect3DSurface9_Release(surface);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(surface)
|
||||
{
|
||||
HMODULE d3d9_handle;
|
||||
@ -189,4 +244,5 @@ START_TEST(surface)
|
||||
|
||||
test_surface_get_container(device_ptr);
|
||||
test_surface_alignment(device_ptr);
|
||||
test_lockrect_offset(device_ptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user