[PATCH 5/5] ddraw/tests: Test depth fill results in test_color_fill().
Henri Verbeet
hverbeet at codeweavers.com
Fri Feb 24 01:10:33 CST 2017
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 39 ++++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw2.c | 39 ++++++++++++++++++++++++++++++++++++++-
dlls/ddraw/tests/ddraw4.c | 36 ++++++++++++++++++++++++++++++++++--
dlls/ddraw/tests/ddraw7.c | 36 ++++++++++++++++++++++++++++++++++--
4 files changed, 144 insertions(+), 6 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 1001d4f..92e675a 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -21,6 +21,7 @@
#include "wine/test.h"
#include <limits.h>
+#include <math.h>
#include "d3d.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
@@ -7269,6 +7270,7 @@ static void test_color_fill(void)
ULONG refcount;
HWND window;
unsigned int i;
+ BOOL is_warp;
DDBLTFX fx;
RECT rect = {5, 5, 7, 7};
DWORD *color;
@@ -7321,7 +7323,7 @@ static void test_color_fill(void)
},
{
DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
@@ -7427,6 +7429,7 @@ static void test_color_fill(void)
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ is_warp = ddraw_is_warp(ddraw);
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create a 3D device, skipping test.\n");
@@ -7462,6 +7465,9 @@ static void test_color_fill(void)
for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
{
+ DWORD expected_broken = tests[i].result;
+ DWORD mask = 0xffffffffu;
+
/* Some Windows drivers modify dwFillColor when it is used on P8 or FourCC formats. */
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
@@ -7496,6 +7502,21 @@ static void test_color_fill(void)
surface_desc.dwFlags &= ~DDSD_PIXELFORMAT;
surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
U2(surface_desc).dwZBufferBitDepth = get_device_z_depth(device);
+ mask >>= (32 - U2(surface_desc).dwZBufferBitDepth);
+ /* Some drivers seem to convert depth values incorrectly or not at
+ * all. Affects at least AMD PALM, 8.17.10.1247. */
+ if (tests[i].caps & DDSCAPS_VIDEOMEMORY)
+ {
+ DWORD expected;
+ float f, g;
+
+ expected = tests[i].result & mask;
+ f = ceilf(log2f(expected + 1.0f));
+ g = (f + 1.0f) / 2.0f;
+ g -= (int)g;
+ expected_broken = (expected / exp2f(f) - g) * 256;
+ expected_broken *= 0x01010101;
+ }
}
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
@@ -7531,6 +7552,22 @@ static void test_color_fill(void)
ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
hr, tests[i].depthfill_hr, tests[i].name);
+ if (SUCCEEDED(hr) && tests[i].check_result)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ color = surface_desc.lpSurface;
+ todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U2(surface_desc).dwZBufferBitDepth != 16)
+ ok((*color & mask) == (tests[i].result & mask) || broken((*color & mask) == (expected_broken & mask))
+ || broken(is_warp && (*color & mask) == (~0u & mask)) /* Windows 8+ testbot. */,
+ "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+ *color & mask, tests[i].result & mask, tests[i].name);
+ hr = IDirectDrawSurface_Unlock(surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ }
+
U5(fx).dwFillColor = 0xdeadbeef;
fx.dwROP = BLACKNESS;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 1836f76..efb898a 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -23,6 +23,7 @@
#define COBJMACROS
#include "wine/test.h"
#include <limits.h>
+#include <math.h>
#include "d3d.h"
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
@@ -8409,6 +8410,7 @@ static void test_color_fill(void)
IDirectDrawSurface *surface, *surface2;
DDSURFACEDESC surface_desc;
ULONG refcount;
+ BOOL is_warp;
HWND window;
unsigned int i;
DDBLTFX fx;
@@ -8463,7 +8465,7 @@ static void test_color_fill(void)
},
{
DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
@@ -8569,6 +8571,7 @@ static void test_color_fill(void)
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
+ is_warp = ddraw_is_warp(ddraw);
if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
{
skip("Failed to create a 3D device, skipping test.\n");
@@ -8604,6 +8607,9 @@ static void test_color_fill(void)
for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
{
+ DWORD expected_broken = tests[i].result;
+ DWORD mask = 0xffffffffu;
+
/* Some Windows drivers modify dwFillColor when it is used on P8 or FourCC formats. */
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
@@ -8638,6 +8644,21 @@ static void test_color_fill(void)
surface_desc.dwFlags &= ~DDSD_PIXELFORMAT;
surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
U2(surface_desc).dwZBufferBitDepth = get_device_z_depth(device);
+ mask >>= (32 - U2(surface_desc).dwZBufferBitDepth);
+ /* Some drivers seem to convert depth values incorrectly or not at
+ * all. Affects at least AMD PALM, 8.17.10.1247. */
+ if (tests[i].caps & DDSCAPS_VIDEOMEMORY)
+ {
+ DWORD expected;
+ float f, g;
+
+ expected = tests[i].result & mask;
+ f = ceilf(log2f(expected + 1.0f));
+ g = (f + 1.0f) / 2.0f;
+ g -= (int)g;
+ expected_broken = (expected / exp2f(f) - g) * 256;
+ expected_broken *= 0x01010101;
+ }
}
hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
@@ -8673,6 +8694,22 @@ static void test_color_fill(void)
ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
hr, tests[i].depthfill_hr, tests[i].name);
+ if (SUCCEEDED(hr) && tests[i].check_result)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ color = surface_desc.lpSurface;
+ todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U2(surface_desc).dwZBufferBitDepth != 16)
+ ok((*color & mask) == (tests[i].result & mask) || broken((*color & mask) == (expected_broken & mask))
+ || broken(is_warp && (*color & mask) == (~0u & mask)) /* Windows 8+ testbot. */,
+ "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+ *color & mask, tests[i].result & mask, tests[i].name);
+ hr = IDirectDrawSurface_Unlock(surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ }
+
U5(fx).dwFillColor = 0xdeadbeef;
fx.dwROP = BLACKNESS;
hr = IDirectDrawSurface_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 557854a..811d1aa 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -9359,12 +9359,12 @@ static void test_color_fill(void)
},
{
DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY, 0,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY, 0,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "sysmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "sysmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
@@ -9519,6 +9519,8 @@ static void test_color_fill(void)
for (i = 0; i < sizeof(tests) / sizeof(*tests); i++)
{
+ DWORD expected_broken = tests[i].result;
+
/* Some Windows drivers modify dwFillColor when it is used on P8 or FourCC formats. */
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
@@ -9548,6 +9550,20 @@ static void test_color_fill(void)
continue;
U4(surface_desc).ddpfPixelFormat = z_fmt;
+ /* Some drivers seem to convert depth values incorrectly or not at
+ * all. Affects at least AMD PALM, 8.17.10.1247. */
+ if (tests[i].caps & DDSCAPS_VIDEOMEMORY)
+ {
+ DWORD expected;
+ float f, g;
+
+ expected = tests[i].result & U3(z_fmt).dwZBitMask;
+ f = ceilf(log2f(expected + 1.0f));
+ g = (f + 1.0f) / 2.0f;
+ g -= (int)g;
+ expected_broken = (expected / exp2f(f) - g) * 256;
+ expected_broken *= 0x01010101;
+ }
}
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
@@ -9583,6 +9599,22 @@ static void test_color_fill(void)
ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
hr, tests[i].depthfill_hr, tests[i].name);
+ if (SUCCEEDED(hr) && tests[i].check_result)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ color = surface_desc.lpSurface;
+ todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U3(z_fmt).dwZBitMask != 0xffff)
+ ok((*color & U3(z_fmt).dwZBitMask) == (tests[i].result & U3(z_fmt).dwZBitMask)
+ || broken((*color & U3(z_fmt).dwZBitMask) == (expected_broken & U3(z_fmt).dwZBitMask)),
+ "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+ *color & U3(z_fmt).dwZBitMask, tests[i].result & U3(z_fmt).dwZBitMask, tests[i].name);
+ hr = IDirectDrawSurface4_Unlock(surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ }
+
U5(fx).dwFillColor = 0xdeadbeef;
fx.dwROP = BLACKNESS;
hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 827496b..cf16d64 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -9684,12 +9684,12 @@ static void test_color_fill(void)
},
{
DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY, 0,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "vidmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY, 0,
- DDERR_INVALIDPARAMS, DD_OK, TRUE, "sysmem zbuffer", 0, FALSE,
+ DDERR_INVALIDPARAMS, DD_OK, TRUE, "sysmem zbuffer", 0xdeadbeef, TRUE,
{0, 0, 0, {0}, {0}, {0}, {0}, {0}}
},
{
@@ -9844,6 +9844,8 @@ static void test_color_fill(void)
for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++)
{
+ DWORD expected_broken = tests[i].result;
+
/* Some Windows drivers modify dwFillColor when it is used on P8 or FourCC formats. */
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
@@ -9873,6 +9875,20 @@ static void test_color_fill(void)
continue;
U4(surface_desc).ddpfPixelFormat = z_fmt;
+ /* Some drivers seem to convert depth values incorrectly or not at
+ * all. Affects at least AMD PALM, 8.17.10.1247. */
+ if (tests[i].caps & DDSCAPS_VIDEOMEMORY)
+ {
+ DWORD expected;
+ float f, g;
+
+ expected = tests[i].result & U3(z_fmt).dwZBitMask;
+ f = ceilf(log2f(expected + 1.0f));
+ g = (f + 1.0f) / 2.0f;
+ g -= (int)g;
+ expected_broken = (expected / exp2f(f) - g) * 256;
+ expected_broken *= 0x01010101;
+ }
}
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
@@ -9908,6 +9924,22 @@ static void test_color_fill(void)
ok(hr == tests[i].depthfill_hr, "Blt returned %#x, expected %#x, surface %s.\n",
hr, tests[i].depthfill_hr, tests[i].name);
+ if (SUCCEEDED(hr) && tests[i].check_result)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_READONLY, 0);
+ ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ color = surface_desc.lpSurface;
+ todo_wine_if(tests[i].caps & DDSCAPS_VIDEOMEMORY && U3(z_fmt).dwZBitMask != 0xffff)
+ ok((*color & U3(z_fmt).dwZBitMask) == (tests[i].result & U3(z_fmt).dwZBitMask)
+ || broken((*color & U3(z_fmt).dwZBitMask) == (expected_broken & U3(z_fmt).dwZBitMask)),
+ "Got clear result 0x%08x, expected 0x%08x, surface %s.\n",
+ *color & U3(z_fmt).dwZBitMask, tests[i].result & U3(z_fmt).dwZBitMask, tests[i].name);
+ hr = IDirectDrawSurface7_Unlock(surface, NULL);
+ ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x, surface %s.\n", hr, tests[i].name);
+ }
+
U5(fx).dwFillColor = 0xdeadbeef;
fx.dwROP = BLACKNESS;
hr = IDirectDrawSurface7_Blt(surface, NULL, NULL, NULL, DDBLT_ROP | DDBLT_WAIT, &fx);
--
2.1.4
More information about the wine-patches
mailing list