Matteo Bruni : d3dx9/tests: Improve tests to check for DXTn fallback formats.

Alexandre Julliard julliard at winehq.org
Thu Sep 26 15:51:20 CDT 2019


Module: wine
Branch: master
Commit: d2f3fc03cb1dbcae77e199f3fd8eb2ccf419cfa5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d2f3fc03cb1dbcae77e199f3fd8eb2ccf419cfa5

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Thu Sep 26 20:54:00 2019 +0200

d3dx9/tests: Improve tests to check for DXTn fallback formats.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx9_36/tests/texture.c | 69 ++++++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 20 deletions(-)

diff --git a/dlls/d3dx9_36/tests/texture.c b/dlls/d3dx9_36/tests/texture.c
index 04513fa4b0..fc1589d25e 100644
--- a/dlls/d3dx9_36/tests/texture.c
+++ b/dlls/d3dx9_36/tests/texture.c
@@ -25,7 +25,7 @@
 #include "d3dx9tex.h"
 #include "resources.h"
 
-static int has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3;
+static int has_2d_dxt1, has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3;
 
 /* 2x2 16-bit dds, no mipmaps */
 static const unsigned char dds_16bit[] = {
@@ -419,30 +419,57 @@ static void test_D3DXCheckTextureRequirements(IDirect3DDevice9 *device)
     ok(format == expected, "Returned format %u, expected %u\n", format, expected);
 
     /* Block-based texture formats and size < block size. */
-    if (has_2d_dxt5)
+    format = D3DFMT_DXT1;
+    width = 2; height = 2;
+    mipmaps = 1;
+    hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
+    if (has_2d_dxt1)
     {
-        format = D3DFMT_DXT5;
-        width = 2; height = 2;
-        mipmaps = 1;
-        hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT);
-        ok(hr == D3D_OK, "D3DXCheckTextureRequirements returned %#x, expected %#x\n", hr, D3D_OK);
-        ok(width == 4, "Returned width %d, expected %d\n", width, 4);
-        ok(height == 4, "Returned height %d, expected %d\n", height, 4);
-        ok(mipmaps == 1, "Returned mipmaps %d, expected %d\n", mipmaps, 1);
-        ok(format == D3DFMT_DXT5, "Returned format %u, expected %u\n", format, D3DFMT_DXT5);
+        ok(width == 4, "Got unexpected width %d.\n", width);
+        ok(height == 4, "Got unexpected height %d.\n", height);
+        ok(format == D3DFMT_DXT1, "Got unexpected format %u.\n", format);
+    }
+    else
+    {
+        ok(width == 2, "Got unexpected width %d.\n", width);
+        ok(height == 2, "Got unexpected height %d.\n", height);
+        ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
+    }
 
-        width = 4;
-        height = 2;
-        hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT);
-        ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
-        ok(width == 4, "Got unexpected width %u.\n", width);
+    format = D3DFMT_DXT5;
+    width = 2; height = 2;
+    hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
+    if (has_2d_dxt5)
+    {
+        ok(width == 4, "Got unexpected width %d.\n", width);
+        ok(height == 4, "Got unexpected height %d.\n", height);
+        ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
+    }
+    else
+    {
+        ok(width == 2, "Got unexpected width %d.\n", width);
+        ok(height == 2, "Got unexpected height %d.\n", height);
+        ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
+    }
+    width = 4;
+    height = 2;
+    hr = D3DXCheckTextureRequirements(device, &width, &height, &mipmaps, 0, &format, D3DPOOL_DEFAULT);
+    ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+    ok(width == 4, "Got unexpected width %u.\n", width);
+    ok(mipmaps == 1, "Got unexpected level count %u.\n", mipmaps);
+    if (has_2d_dxt5)
+    {
         ok(height == 4, "Got unexpected height %u.\n", height);
-        ok(mipmaps == 1, "Got unexpected mipmap level count %u.\n", mipmaps);
         ok(format == D3DFMT_DXT5, "Got unexpected format %u.\n", format);
     }
     else
     {
-        skip("D3DFMT_DXT5 textures are not supported, skipping a test.\n");
+        ok(height == 2, "Got unexpected height %u.\n", height);
+        ok(format == D3DFMT_A8R8G8B8, "Got unexpected format %u.\n", format);
     }
 
     IDirect3D9_Release(d3d);
@@ -2511,6 +2538,8 @@ START_TEST(texture)
     }
 
     /* Check whether DXTn textures are supported. */
+    has_2d_dxt1 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
+            D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
     has_2d_dxt3 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
     has_2d_dxt5 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
@@ -2519,8 +2548,8 @@ START_TEST(texture)
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_CUBETEXTURE, D3DFMT_DXT5));
     has_3d_dxt3 = SUCCEEDED(IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
             D3DFMT_X8R8G8B8, 0, D3DRTYPE_VOLUMETEXTURE, D3DFMT_DXT3));
-    trace("DXTn texture support: 2D DXT3 %#x, 2D DXT5 %#x, cube DXT5 %#x, 3D dxt3 %#x.\n",
-            has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3);
+    trace("DXTn texture support: 2D DXT1 %#x, 2D DXT3 %#x, 2D DXT5 %#x, cube DXT5 %#x, 3D dxt3 %#x.\n",
+            has_2d_dxt1, has_2d_dxt3, has_2d_dxt5, has_cube_dxt5, has_3d_dxt3);
 
     test_D3DXCheckTextureRequirements(device);
     test_D3DXCheckCubeTextureRequirements(device);




More information about the wine-cvs mailing list