[PATCH] ddraw/tests: P8 color keying does not work on WARP (v2).

Stefan Dösinger stefandoesinger at gmx.at
Wed Jun 29 16:46:50 CDT 2016


Version 2: Use GetDeviceIdentifier instead of looking at d3d caps. More
direct, and works on 64 bit.

Signed-off-by: Stefan Dösinger <stefandoesinger at gmx.at>
---
 dlls/ddraw/tests/ddraw1.c | 28 +++++++++++++++++++++++++++-
 dlls/ddraw/tests/ddraw2.c | 28 +++++++++++++++++++++++++++-
 dlls/ddraw/tests/ddraw4.c | 24 +++++++++++++++++++++++-
 dlls/ddraw/tests/ddraw7.c | 24 +++++++++++++++++++++++-
 4 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 8c12379..752bfb8 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -5293,6 +5293,23 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static BOOL ddraw_is_warp(IDirectDraw *ddraw)
+{
+    IDirectDraw4 *ddraw4;
+    DDDEVICEIDENTIFIER identifier;
+    HRESULT hr;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+
+    hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw4, (void **)&ddraw4);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#x.\n", hr);
+    hr = IDirectDraw4_GetDeviceIdentifier(ddraw4, &identifier, 0);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    IDirectDraw4_Release(ddraw4);
+    return !!strstr(identifier.szDriver, "warp");
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface *src, *dst, *dst_p8;
@@ -5305,6 +5322,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp;
     static const BYTE src_data[] = {0x10, 0x1, 0x2, 0x3, 0x4, 0x5, 0xff, 0x80};
     static const BYTE src_data2[] = {0x10, 0x5, 0x4, 0x3, 0x2, 0x1, 0xff, 0x80};
     static const BYTE expected_p8[] = {0x10, 0x1, 0x4, 0x3, 0x4, 0x5, 0xff, 0x80};
@@ -5321,6 +5339,7 @@ static void test_p8_blit(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
@@ -5412,7 +5431,14 @@ static void test_p8_blit(void)
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
-    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8)),
+    /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
+     * surface untouched. P8 blits without color keys work. Error checking (DDBLT_KEYSRC without a key
+     * for example) also works as expected.
+     *
+     * Using DDBLT_KEYSRC instead of DDBLT_KEYSRCOVERRIDE doesn't change this. Doing this blit with
+     * the display mode set to P8 doesn't help either. */
+    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8))
+            || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
     ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index b493c04..363133d 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -6350,6 +6350,23 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static BOOL ddraw_is_warp(IDirectDraw2 *ddraw)
+{
+    IDirectDraw4 *ddraw4;
+    DDDEVICEIDENTIFIER identifier;
+    HRESULT hr;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+
+    hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirectDraw4, (void **)&ddraw4);
+    ok(SUCCEEDED(hr), "Failed to get IDirectDraw4 interface, hr %#x.\n", hr);
+    hr = IDirectDraw4_GetDeviceIdentifier(ddraw4, &identifier, 0);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    IDirectDraw4_Release(ddraw4);
+    return !!strstr(identifier.szDriver, "warp");
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface *src, *dst, *dst_p8;
@@ -6362,6 +6379,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp;
     static const BYTE src_data[] = {0x10, 0x1, 0x2, 0x3, 0x4, 0x5, 0xff, 0x80};
     static const BYTE src_data2[] = {0x10, 0x5, 0x4, 0x3, 0x2, 0x1, 0xff, 0x80};
     static const BYTE expected_p8[] = {0x10, 0x1, 0x4, 0x3, 0x4, 0x5, 0xff, 0x80};
@@ -6378,6 +6396,7 @@ static void test_p8_blit(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
@@ -6469,7 +6488,14 @@ static void test_p8_blit(void)
 
     hr = IDirectDrawSurface_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
-    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8)),
+    /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
+     * surface untouched. P8 blits without color keys work. Error checking (DDBLT_KEYSRC without a key
+     * for example) also works as expected.
+     *
+     * Using DDBLT_KEYSRC instead of DDBLT_KEYSRCOVERRIDE doesn't change this. Doing this blit with
+     * the display mode set to P8 doesn't help either. */
+    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8))
+            || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface_Unlock(dst_p8, NULL);
     ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index a096ab0..2fd565d 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -7877,6 +7877,19 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static BOOL ddraw_is_warp(IDirectDraw4 *ddraw)
+{
+    DDDEVICEIDENTIFIER identifier;
+    HRESULT hr;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+
+    hr = IDirectDraw4_GetDeviceIdentifier(ddraw, &identifier, 0);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    return !!strstr(identifier.szDriver, "warp");
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface4 *src, *dst, *dst_p8;
@@ -7889,6 +7902,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp;
     static const BYTE src_data[] = {0x10, 0x1, 0x2, 0x3, 0x4, 0x5, 0xff, 0x80};
     static const BYTE src_data2[] = {0x10, 0x5, 0x4, 0x3, 0x2, 0x1, 0xff, 0x80};
     static const BYTE expected_p8[] = {0x10, 0x1, 0x4, 0x3, 0x4, 0x5, 0xff, 0x80};
@@ -7905,6 +7919,7 @@ static void test_p8_blit(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
@@ -7996,7 +8011,14 @@ static void test_p8_blit(void)
 
     hr = IDirectDrawSurface4_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
-    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8)),
+    /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
+     * surface untouched. P8 blits without color keys work. Error checking (DDBLT_KEYSRC without a key
+     * for example) also works as expected.
+     *
+     * Using DDBLT_KEYSRC instead of DDBLT_KEYSRCOVERRIDE doesn't change this. Doing this blit with
+     * the display mode set to P8 doesn't help either. */
+    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8))
+            || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface4_Unlock(dst_p8, NULL);
     ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index b2b33d3..d808ad3 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -7789,6 +7789,19 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static BOOL ddraw_is_warp(IDirectDraw7 *ddraw)
+{
+    DDDEVICEIDENTIFIER2 identifier;
+    HRESULT hr;
+
+    if (!strcmp(winetest_platform, "wine"))
+        return FALSE;
+
+    hr = IDirectDraw7_GetDeviceIdentifier(ddraw, &identifier, 0);
+    ok(SUCCEEDED(hr), "Failed to get device identifier, hr %#x.\n", hr);
+    return !!strstr(identifier.szDriver, "warp");
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface7 *src, *dst, *dst_p8;
@@ -7801,6 +7814,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp;
     static const BYTE src_data[] = {0x10, 0x1, 0x2, 0x3, 0x4, 0x5, 0xff, 0x80};
     static const BYTE src_data2[] = {0x10, 0x5, 0x4, 0x3, 0x2, 0x1, 0xff, 0x80};
     static const BYTE expected_p8[] = {0x10, 0x1, 0x4, 0x3, 0x4, 0x5, 0xff, 0x80};
@@ -7817,6 +7831,7 @@ static void test_p8_blit(void)
     ok(!!ddraw, "Failed to create a ddraw object.\n");
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
+    is_warp = ddraw_is_warp(ddraw);
 
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
@@ -7908,7 +7923,14 @@ static void test_p8_blit(void)
 
     hr = IDirectDrawSurface7_Lock(dst_p8, NULL, &surface_desc, DDLOCK_READONLY | DDLOCK_WAIT, NULL);
     ok(SUCCEEDED(hr), "Failed to lock destination surface, hr %#x.\n", hr);
-    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8)),
+    /* A color keyed P8 blit doesn't do anything on WARP - it just leaves the data in the destination
+     * surface untouched. P8 blits without color keys work. Error checking (DDBLT_KEYSRC without a key
+     * for example) also works as expected.
+     *
+     * Using DDBLT_KEYSRC instead of DDBLT_KEYSRCOVERRIDE doesn't change this. Doing this blit with
+     * the display mode set to P8 doesn't help either. */
+    ok(!memcmp(surface_desc.lpSurface, expected_p8, sizeof(expected_p8))
+            || broken(is_warp && !memcmp(surface_desc.lpSurface, src_data2, sizeof(src_data2))),
             "Got unexpected P8 color key blit result.\n");
     hr = IDirectDrawSurface7_Unlock(dst_p8, NULL);
     ok(SUCCEEDED(hr), "Failed to unlock destination surface, hr %#x.\n", hr);
-- 
2.7.3




More information about the wine-patches mailing list