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

Stefan Dösinger stefandoesinger at gmx.at
Sun Jun 12 15:21:12 CDT 2016


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

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 8c12379..7ce1f00 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -5293,11 +5293,24 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static HRESULT WINAPI is_warp_cb(GUID *guid, char *description, char *name,
+        D3DDEVICEDESC *hal_desc, D3DDEVICEDESC *hel_desc, void *ctx)
+{
+    BOOL *is_warp = ctx;
+    if (IsEqualGUID(guid, &IID_IDirect3DHALDevice))
+    {
+        *is_warp = !!(hal_desc->dwDevCaps & D3DDEVCAPS_TEXTURESYSTEMMEMORY);
+        return DDENUMRET_CANCEL;
+    }
+    return DDENUMRET_OK;
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface *src, *dst, *dst_p8;
     DDSURFACEDESC surface_desc;
     IDirectDraw *ddraw;
+    IDirect3D *d3d;
     IDirectDrawPalette *palette, *palette2;
     ULONG refcount;
     HWND window;
@@ -5305,6 +5318,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp = FALSE;
     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};
@@ -5322,6 +5336,16 @@ static void test_p8_blit(void)
     hr = IDirectDraw_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
 
+    /* Locking a P8 surface crashes on WARP if a d3d device has been created. So we
+     * need to find the caps via enumeration. */
+    hr = IDirectDraw_QueryInterface(ddraw, &IID_IDirect3D, (void **)&d3d);
+    if (SUCCEEDED(hr))
+    {
+        hr = IDirect3D_EnumDevices(d3d, is_warp_cb, &is_warp);
+        ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+        IDirect3D_Release(d3d);
+    }
+
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
     palette_entries[2].peBlue = 0xff;
@@ -5412,7 +5436,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..629f30e 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -6350,11 +6350,24 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static HRESULT WINAPI is_warp_cb(GUID *guid, char *description, char *name,
+        D3DDEVICEDESC *hal_desc, D3DDEVICEDESC *hel_desc, void *ctx)
+{
+    BOOL *is_warp = ctx;
+    if (IsEqualGUID(guid, &IID_IDirect3DHALDevice))
+    {
+        *is_warp = !!(hal_desc->dwDevCaps & D3DDEVCAPS_TEXTURESYSTEMMEMORY);
+        return DDENUMRET_CANCEL;
+    }
+    return DDENUMRET_OK;
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface *src, *dst, *dst_p8;
     DDSURFACEDESC surface_desc;
     IDirectDraw2 *ddraw;
+    IDirect3D2 *d3d;
     IDirectDrawPalette *palette, *palette2;
     ULONG refcount;
     HWND window;
@@ -6362,6 +6375,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp = FALSE;
     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};
@@ -6379,6 +6393,16 @@ static void test_p8_blit(void)
     hr = IDirectDraw2_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
 
+    /* Locking a P8 surface crashes on WARP if a d3d device has been created. So we
+     * need to find the caps via enumeration. */
+    hr = IDirectDraw2_QueryInterface(ddraw, &IID_IDirect3D2, (void **)&d3d);
+    if (SUCCEEDED(hr))
+    {
+        hr = IDirect3D2_EnumDevices(d3d, is_warp_cb, &is_warp);
+        ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+        IDirect3D2_Release(d3d);
+    }
+
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
     palette_entries[2].peBlue = 0xff;
@@ -6469,7 +6493,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..d1d7f31 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -7877,11 +7877,24 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static HRESULT WINAPI is_warp_cb(GUID *guid, char *description, char *name,
+        D3DDEVICEDESC *hal_desc, D3DDEVICEDESC *hel_desc, void *ctx)
+{
+    BOOL *is_warp = ctx;
+    if (IsEqualGUID(guid, &IID_IDirect3DHALDevice))
+    {
+        *is_warp = !!(hal_desc->dwDevCaps & D3DDEVCAPS_TEXTURESYSTEMMEMORY);
+        return DDENUMRET_CANCEL;
+    }
+    return DDENUMRET_OK;
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface4 *src, *dst, *dst_p8;
     DDSURFACEDESC2 surface_desc;
     IDirectDraw4 *ddraw;
+    IDirect3D3 *d3d;
     IDirectDrawPalette *palette, *palette2;
     ULONG refcount;
     HWND window;
@@ -7889,6 +7902,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp = FALSE;
     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};
@@ -7906,6 +7920,16 @@ static void test_p8_blit(void)
     hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
 
+    /* Locking a P8 surface crashes on WARP if a d3d device has been created. So we
+     * need to find the caps via enumeration. */
+    hr = IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d);
+    if (SUCCEEDED(hr))
+    {
+        hr = IDirect3D3_EnumDevices(d3d, is_warp_cb, &is_warp);
+        ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+        IDirect3D3_Release(d3d);
+    }
+
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
     palette_entries[2].peBlue = 0xff;
@@ -7996,7 +8020,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..3e9403e 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -7789,11 +7789,23 @@ static void test_palette_complex(void)
     DestroyWindow(window);
 }
 
+static HRESULT WINAPI is_warp_cb(char *desc_str, char *name, D3DDEVICEDESC7 *desc, void *ctx)
+{
+    BOOL *is_warp = ctx;
+    if (IsEqualGUID(&desc->deviceGUID, &IID_IDirect3DHALDevice))
+    {
+        *is_warp = !!(desc->dwDevCaps & D3DDEVCAPS_TEXTURESYSTEMMEMORY);
+        return DDENUMRET_CANCEL;
+    }
+    return DDENUMRET_OK;
+}
+
 static void test_p8_blit(void)
 {
     IDirectDrawSurface7 *src, *dst, *dst_p8;
     DDSURFACEDESC2 surface_desc;
     IDirectDraw7 *ddraw;
+    IDirect3D7 *d3d;
     IDirectDrawPalette *palette, *palette2;
     ULONG refcount;
     HWND window;
@@ -7801,6 +7813,7 @@ static void test_p8_blit(void)
     PALETTEENTRY palette_entries[256];
     unsigned int x;
     DDBLTFX fx;
+    BOOL is_warp = FALSE;
     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};
@@ -7818,6 +7831,16 @@ static void test_p8_blit(void)
     hr = IDirectDraw7_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL);
     ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr);
 
+    /* Locking a P8 surface crashes on WARP if a d3d device has been created. So we
+     * need to find the caps via enumeration. */
+    hr = IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d);
+    if (SUCCEEDED(hr))
+    {
+        hr = IDirect3D7_EnumDevices(d3d, is_warp_cb, &is_warp);
+        ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+        IDirect3D7_Release(d3d);
+    }
+
     memset(palette_entries, 0, sizeof(palette_entries));
     palette_entries[1].peGreen = 0xff;
     palette_entries[2].peBlue = 0xff;
@@ -7908,7 +7931,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