From 860dc38c1051e19b8de9aa75091b9c6b9e14e0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ri=C4=8Dardas=20Barkauskas?= Date: Thu, 11 Mar 2010 21:46:01 +0200 Subject: testing2 --- dlls/d3d9/tests/surface.c | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/dlls/d3d9/tests/surface.c b/dlls/d3d9/tests/surface.c index 396e0c4..e5aa3ae 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", 4, 4, 16}, }; + 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,10 @@ 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); + ok(0, "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,15 +243,17 @@ 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); + //ok(offset == expected_offset, "Got offset %u, expected offset %u for format %s\n", offset, expected_offset, dxt_formats[i].name); + ok(0, "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); } + IDirect3D9_Release(d3d); } static void test_lockrect_invalid(IDirect3DDevice9 *device) -- 1.7.0