Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- v2: Reset diff_count3 to 0 after use
dlls/ddraw/tests/d3d.c | 77 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 21 deletions(-)
diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 77836fd627..3cc40e24c4 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -24,6 +24,7 @@
#include "wine/test.h" #include <limits.h> +#include <math.h> #include "initguid.h" #include "ddraw.h" #include "d3d.h" @@ -1418,7 +1419,7 @@ static void DeviceLoadTest(void) RECT loadrect; POINT loadpoint; int i, i1, i2; - unsigned diff_count = 0, diff_count2 = 0; + unsigned diff_count = 0, diff_count2 = 0, diff_count3 = 0; unsigned x, y; BOOL load_mip_subset_broken = FALSE; IDirectDrawPalette *palettes[5]; @@ -1939,6 +1940,7 @@ static void DeviceLoadTest(void) { diff_count = 0; diff_count2 = 0; + diff_count3 = 0;
memset(&ddsd, 0, sizeof(DDSURFACEDESC2)); ddsd.dwSize = sizeof(ddsd); @@ -1953,6 +1955,9 @@ static void DeviceLoadTest(void) for (x = 0; x < ddsd.dwWidth; x++) { DWORD color = *textureRow++; + DWORD r = (color & 0xff0000) >> 16; + DWORD g = (color & 0xff00) >> 8; + DWORD b = (color & 0xff);
if (x < loadpoint.x || x >= loadpoint.x + loadrect.right - loadrect.left || y < loadpoint.y || y >= loadpoint.y + loadrect.bottom - loadrect.top) @@ -1961,10 +1966,6 @@ static void DeviceLoadTest(void) } else { - DWORD r = (color & 0xff0000) >> 16; - DWORD g = (color & 0xff00) >> 8; - DWORD b = (color & 0xff); - if (r != (0xf0 | i1) || g != x + loadrect.left - loadpoint.x || b != y + loadrect.top - loadpoint.y) diff_count++; } @@ -1978,21 +1979,29 @@ static void DeviceLoadTest(void) } else { - DWORD r = (color & 0xff0000) >> 16; - DWORD g = (color & 0xff00) >> 8; - DWORD b = (color & 0xff); - if (r != (0xf0 | i1) || !IS_VALUE_NEAR(g, x + loadrect.left - loadpoint.x) || !IS_VALUE_NEAR(b, y + loadrect.top - loadpoint.y)) diff_count2++; } + + /* some windows 8 and 10 machines copy the wrong mip */ + if (x < loadpoint.x / 16 || x >= ceil((loadpoint.x + loadrect.right - loadrect.left) / 16.0) || + y < loadpoint.y / 16 || y >= ceil((loadpoint.y + loadrect.bottom - loadrect.top) / 16.0)) + { + if (color & 0xffffff) diff_count3++; + } + else + { + if (r != (0xf0 | (i1 + 4)) || g != x || b != y) diff_count3++; + } } }
hr = IDirectDrawSurface7_Unlock(texture_levels[1][i1], NULL); ok(hr==DD_OK, "IDirectDrawSurface7_Unlock returned: %x\n",hr);
- ok(diff_count == 0 || diff_count2 == 0, "Unexpected destination texture level pixels; %u differences at %d level\n", - MIN(diff_count, diff_count2), i1); + ok(diff_count == 0 || diff_count2 == 0 || broken(diff_count3 == 0), + "Unexpected destination texture level pixels; %u differences, %d level\n", + MIN(MIN(diff_count, diff_count2), diff_count3), i1);
loadpoint.x /= 2; loadpoint.y /= 2; @@ -2145,6 +2154,7 @@ static void DeviceLoadTest(void) skip("IDirect3DDevice7_Load is broken (happens on some modern Windows installations like XP). Skipping affected tests.\n"); } else { diff_count = 0; + diff_count3 = 0;
for (y = 0 ; y < ddsd.dwHeight; y++) { @@ -2153,6 +2163,9 @@ static void DeviceLoadTest(void) for (x = 0; x < ddsd.dwWidth; x++) { DWORD color = *textureRow++; + DWORD r = (color & 0xff0000) >> 16; + DWORD g = (color & 0xff00) >> 8; + DWORD b = (color & 0xff);
if (x < loadpoint.x || x >= loadpoint.x + loadrect.right - loadrect.left || y < loadpoint.y || y >= loadpoint.y + loadrect.bottom - loadrect.top) @@ -2161,13 +2174,20 @@ static void DeviceLoadTest(void) } else { - DWORD r = (color & 0xff0000) >> 16; - DWORD g = (color & 0xff00) >> 8; - DWORD b = (color & 0xff); - if (r != (0xf0 | 2) || g != x + loadrect.left - loadpoint.x || b != y + loadrect.top - loadpoint.y) diff_count++; } + + /* some windows 8 and 10 machines copy the wrong mip */ + if (x < loadpoint.x / 16 || x >= (loadpoint.x + loadrect.right - loadrect.left) / 16 || + y < loadpoint.y / 16 || y >= (loadpoint.y + loadrect.bottom - loadrect.top) / 16) + { + if (color & 0xffffff) diff_count3++; + } + else + { + if (r != 0xf7 || g != x || b != y) diff_count3++; + } } } } @@ -2175,7 +2195,9 @@ static void DeviceLoadTest(void) hr = IDirectDrawSurface7_Unlock(texture_levels[1][0], NULL); ok(hr==DD_OK, "IDirectDrawSurface7_Unlock returned: %x\n",hr);
- ok(diff_count == 0, "Unexpected destination texture level pixels; %u differences\n", diff_count); + ok(diff_count == 0 || broken(diff_count3 == 0), + "Unexpected destination texture level pixels; %u differences\n", + MIN(diff_count, diff_count3));
for (i = 0; i < 2; i++) { @@ -2287,6 +2309,7 @@ static void DeviceLoadTest(void) if (ddsd.dwWidth == ddsd2.dwWidth && ddsd.dwHeight == ddsd2.dwHeight) { diff_count = 0; + diff_count3 = 0;
memset(&ddsd, 0, sizeof(DDSURFACEDESC2)); ddsd.dwSize = sizeof(ddsd); @@ -2301,6 +2324,9 @@ static void DeviceLoadTest(void) for (x = 0; x < ddsd.dwWidth; x++) { DWORD color = *textureRow++; + DWORD r = (color & 0xff0000) >> 16; + DWORD g = (color & 0xff00) >> 8; + DWORD b = (color & 0xff);
if (x < loadpoint.x || x >= loadpoint.x + loadrect.right - loadrect.left || y < loadpoint.y || y >= loadpoint.y + loadrect.bottom - loadrect.top) @@ -2309,20 +2335,29 @@ static void DeviceLoadTest(void) } else { - DWORD r = (color & 0xff0000) >> 16; - DWORD g = (color & 0xff00) >> 8; - DWORD b = (color & 0xff); - if (r != (0xf0 | i1) || g != x + loadrect.left - loadpoint.x || b != y + loadrect.top - loadpoint.y) diff_count++; } + + /* some windows 8 and 10 machines copy the wrong mip */ + if (x < loadpoint.x / 16 || x >= ceil((loadpoint.x + loadrect.right - loadrect.left) / 16.0) || + y < loadpoint.y / 16 || y >= ceil((loadpoint.y + loadrect.bottom - loadrect.top) / 16.0)) + { + if (color & 0xffffff) diff_count3++; + } + else + { + if (r != (0xf0 | (i + 4)) || g != x || b != y) diff_count3++; + } } }
hr = IDirectDrawSurface7_Unlock(texture_levels[1][i], NULL); ok(hr==DD_OK, "IDirectDrawSurface7_Unlock returned: %x\n",hr);
- ok(diff_count == 0, "Unexpected destination texture level pixels; %u differences at %d level\n", diff_count, i1); + ok(diff_count == 0 || broken(diff_count3 == 0), + "Unexpected destination texture level pixels; %u differences at %d level\n", + MIN(diff_count, diff_count3), i1);
i++; }
On 20 February 2018 at 11:06, Alex Henrie alexhenrie24@gmail.com wrote:
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
v2: Reset diff_count3 to 0 after use
dlls/ddraw/tests/d3d.c | 77 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 21 deletions(-)
Unfortunately the only way to fix these is by porting them to ddraw[1247].c.
On Wed, Feb 21, 2018 at 5:36 AM Henri Verbeet hverbeet@gmail.com wrote:
On 20 February 2018 at 11:06, Alex Henrie alexhenrie24@gmail.com wrote:
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
v2: Reset diff_count3 to 0 after use
dlls/ddraw/tests/d3d.c | 77 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 21 deletions(-)
Unfortunately the only way to fix these is by porting them to ddraw[1247].c.
I looked at this again today and realized that only IDirect3DDevice7 has a Load function. So, I don't immediately see a way to rewrite the device load tests for DDraw 1-4. It seems like we could just move the existing tests to ddraw7.c.
-Alex
On 15 July 2018 at 03:37, Alex Henrie alexhenrie24@gmail.com wrote:
I looked at this again today and realized that only IDirect3DDevice7 has a Load function. So, I don't immediately see a way to rewrite the device load tests for DDraw 1-4. It seems like we could just move the existing tests to ddraw7.c.
IDirect3DTexture/IDirect3DTexture2 also has a Load() method, although it's a much more limited interface. In principle moving the test from d3d.c to ddraw7.c is fine, but that's a bit more involved than just copying the code, since it would need some general cleanups as well.