[7/8] d3dx9/tests: Add tests for compressed pixel formats support in D3DXLoadSurface functions.

Józef Kucia joseph.kucia at gmail.com
Wed May 9 16:32:10 CDT 2012


---
 dlls/d3dx9_36/tests/surface.c |   87 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 86 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx9_36/tests/surface.c b/dlls/d3dx9_36/tests/surface.c
index 3d5a50f..63b4a8f 100644
--- a/dlls/d3dx9_36/tests/surface.c
+++ b/dlls/d3dx9_36/tests/surface.c
@@ -70,7 +70,7 @@ static const unsigned char dds_24bit[] = {
 0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
 0x00,0xff,0x00,0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x40,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
-0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
+0x0a,0x0a,0xd7,0x32,0xff,0x37,0xff,0xb9,0x7a,0xff,0xf7,0xef,0x8e,0xae,0x9e
 };
 
 /* 2x2 16-bit dds, no mipmaps */
@@ -421,6 +421,16 @@ ok(((BYTE*)(lockrect).pBits)[(x) + (y) * (lockrect).Pitch] == color, "Got color
 ok(((WORD*)(lockrect).pBits)[(x) + (y) * (lockrect).Pitch / 2] == color, "Got color 0x%04x, expected 0x%04x.\n", \
 ((WORD*)(lockrect).pBits)[(x) + (y) * (lockrect).Pitch / 2], color)
 
+#define check_pixel_3bpp(lockrect, x, y, color) \
+ok(((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 0] == ((color) & 0xFF) \
+&& ((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 1] == (((color) >> 8) & 0xFF) \
+&& ((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 2] == ((color) >> 16 & 0xFF), \
+"Got color 0x%02x%02x%02x, expected 0x%06x.n", \
+((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 2], \
+((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 1], \
+((BYTE*)(lockrect).pBits)[3 * (x) + (y) * (lockrect).Pitch + 0], \
+color)
+
 #define check_pixel_4bpp(lockrect, x, y, color) \
 ok(((DWORD*)(lockrect).pBits)[(x) + (y) * (lockrect).Pitch / 4] == color, "Got color 0x%08x, expected 0x%08x.\n", \
 ((DWORD*)(lockrect).pBits)[(x) + (y) * (lockrect).Pitch / 4], color)
@@ -830,6 +840,81 @@ static void test_D3DXLoadSurface(IDirect3DDevice9 *device)
         check_release((IUnknown*)surf, 0);
     }
 
+    /* DXT1, DXT2, DXT3, DXT4, DXT5 */
+    hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_R8G8B8, D3DPOOL_SYSTEMMEM, &surf, NULL);
+    if (FAILED(hr))
+        skip("Failed to create R8G8B8 surface, hr %#x.\n", hr);
+    else
+    {
+        hr = D3DXLoadSurfaceFromFileInMemory(surf, NULL, NULL, dds_24bit, sizeof(dds_24bit), NULL, D3DX_FILTER_NONE, 0, NULL);
+        ok(SUCCEEDED(hr), "Failed to load surface, hr %#x.\n", hr);
+
+        hr = IDirect3DSurface9_LockRect(surf, &lockrect, NULL, D3DLOCK_READONLY);
+        ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+        check_pixel_3bpp(lockrect, 0, 0, 0xd70a0a);
+        check_pixel_3bpp(lockrect, 1, 0, 0x37ff32);
+        check_pixel_3bpp(lockrect, 0, 1, 0x7ab9ff);
+        check_pixel_3bpp(lockrect, 1, 1, 0xeff7ff);
+        hr = IDirect3DSurface9_UnlockRect(surf);
+        ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+
+        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_DXT2, D3DPOOL_SYSTEMMEM, &newsurf, NULL);
+        if (FAILED(hr))
+            skip("Failed to create DXT2 surface, hr %#x.\n", hr);
+        else
+        {
+            hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT2 format.\n");
+            check_release((IUnknown*)newsurf, 0);
+        }
+
+        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_DXT3, D3DPOOL_SYSTEMMEM, &newsurf, NULL);
+        if (FAILED(hr))
+            skip("Failed to create DXT3 surface, hr %#x.\n", hr);
+        else
+        {
+            hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT3 format.\n");
+            check_release((IUnknown*)newsurf, 0);
+        }
+
+        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_DXT4, D3DPOOL_SYSTEMMEM, &newsurf, NULL);
+        if (FAILED(hr))
+            skip("Failed to create DXT4 surface, hr %#x.\n", hr);
+        else
+        {
+            hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT4 format.\n");
+            check_release((IUnknown*)newsurf, 0);
+        }
+
+        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_DXT5, D3DPOOL_SYSTEMMEM, &newsurf, NULL);
+        if (FAILED(hr))
+            skip("Failed to create DXT5 surface, hr %#x.\n", hr);
+        else
+        {
+            hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT5 format.\n");
+            check_release((IUnknown*)newsurf, 0);
+        }
+
+        hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 2, 2, D3DFMT_DXT1, D3DPOOL_SYSTEMMEM, &newsurf, NULL);
+        if (FAILED(hr))
+            skip("Failed to create DXT1 surface, hr %#x.\n", hr);
+        else
+        {
+            hr = D3DXLoadSurfaceFromSurface(newsurf, NULL, NULL, surf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels to DXT1 format.\n");
+
+            hr = D3DXLoadSurfaceFromSurface(surf, NULL, NULL, newsurf, NULL, NULL, D3DX_FILTER_NONE, 0);
+            todo_wine ok(SUCCEEDED(hr), "Failed to convert pixels from DXT1 format.\n");
+
+            check_release((IUnknown*)newsurf, 0);
+        }
+
+        check_release((IUnknown*)surf, 0);
+    }
+
     /* cleanup */
     if(testdummy_ok) DeleteFileA("testdummy.bmp");
     if(testbitmap_ok) DeleteFileA("testbitmap.bmp");
-- 
1.7.8.6




More information about the wine-patches mailing list