Ričardas Barkauskas : d3d9/tests: Test ATI2N pitch and locking offset behaviour.
Alexandre Julliard
julliard at winehq.org
Tue Mar 16 11:49:20 CDT 2010
Module: wine
Branch: master
Commit: 1e754f5e2e7db698e9b2c8f0133214f2d3959f82
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1e754f5e2e7db698e9b2c8f0133214f2d3959f82
Author: Ričardas Barkauskas <miegalius at gmail.com>
Date: Tue Mar 16 01:10:09 2010 +0200
d3d9/tests: Test ATI2N pitch and locking offset behaviour.
---
dlls/d3d9/tests/surface.c | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d9/tests/surface.c b/dlls/d3d9/tests/surface.c
index 396e0c4..4427cc0 100644
--- a/dlls/d3d9/tests/surface.c
+++ b/dlls/d3d9/tests/surface.c
@@ -187,8 +187,10 @@ todo_wine ok(SUCCEEDED(hr), "Double IDirect3DTexture9_UnLockRect failed with %
static void test_lockrect_offset(IDirect3DDevice9 *device)
{
IDirect3DSurface9 *surface = 0;
+ IDirect3D9 *d3d;
const RECT rect = {60, 60, 68, 68};
D3DLOCKED_RECT locked_rect;
+ int expected_pitch;
unsigned int expected_offset;
unsigned int offset;
unsigned int i;
@@ -202,14 +204,24 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
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},
+ {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},
+ {MAKEFOURCC('A','T','I','2'), "ATI2N", 1, 1, 1},
};
+ hr = IDirect3DDevice9_GetDirect3D(device, &d3d);
+ ok(SUCCEEDED(hr), "IDirect3DDevice9_GetDirect3D failed (%08x)\n", hr);
for (i = 0; i < (sizeof(dxt_formats) / sizeof(*dxt_formats)); ++i) {
+ hr = IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, dxt_formats[i].fmt);
+ if(FAILED(hr))
+ {
+ skip("Format %s not supported, skipping lockrect offset test\n", dxt_formats[i].name);
+ continue;
+ }
+
hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128, dxt_formats[i].fmt, D3DPOOL_SCRATCH, &surface, 0);
ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed (%08x)\n", hr);
@@ -217,6 +229,9 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
ok(SUCCEEDED(hr), "LockRect failed (%08x)\n", hr);
base = locked_rect.pBits;
+ expected_pitch = (128 + dxt_formats[i].block_height - 1) / dxt_formats[i].block_width
+ * dxt_formats[i].block_size;
+ ok(locked_rect.Pitch == expected_pitch, "Got pitch %d, expected pitch %d for format %s\n", locked_rect.Pitch, expected_pitch, dxt_formats[i].name);
hr = IDirect3DSurface9_UnlockRect(surface);
ok(SUCCEEDED(hr), "UnlockRect failed (%08x)\n", hr);
@@ -227,7 +242,7 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
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
+ expected_offset = (rect.top / dxt_formats[i].block_height) * expected_pitch
+ (rect.left / dxt_formats[i].block_width) * dxt_formats[i].block_size;
ok(offset == expected_offset, "Got offset %u, expected offset %u for format %s\n", offset, expected_offset, dxt_formats[i].name);
@@ -236,6 +251,7 @@ static void test_lockrect_offset(IDirect3DDevice9 *device)
IDirect3DSurface9_Release(surface);
}
+ IDirect3D9_Release(d3d);
}
static void test_lockrect_invalid(IDirect3DDevice9 *device)
More information about the wine-cvs
mailing list