[PATCH 3/4] ddraw/tests: Don'T use DDBLT_COLORFILL in test_flip.

Stefan Dösinger stefan at codeweavers.com
Mon Apr 17 15:14:58 CDT 2017


It is broken on Geforce 7 cards in some conditions triggered by this
test. Doing the fill manually is awkward but maintains the full
functionality of the test on these cards.

Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
 dlls/ddraw/tests/ddraw1.c | 61 ++++++++++++++++++++++++--------------------
 dlls/ddraw/tests/ddraw2.c | 61 ++++++++++++++++++++++++--------------------
 dlls/ddraw/tests/ddraw4.c | 61 ++++++++++++++++++++++++--------------------
 dlls/ddraw/tests/ddraw7.c | 65 +++++++++++++++++++++++++++--------------------
 4 files changed, 140 insertions(+), 108 deletions(-)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 4f53ee1..bcbece4 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -4250,6 +4250,32 @@ static void test_surface_discard(void)
     DestroyWindow(window);
 }
 
+/* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
+ * the backbuffer has been locked or GetSurfaceDesc has been called. Do it ourselves
+ * as a workaround. */
+static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
+{
+    DDSURFACEDESC surface_desc = {sizeof(surface_desc)};
+    HRESULT hr;
+    unsigned int x, y;
+    DWORD *ptr;
+
+    hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+
+    for (y = 0; y < surface_desc.dwHeight; ++y)
+    {
+        ptr = (DWORD *)((BYTE *)surface_desc.lpSurface + y * surface_desc.lPitch);
+        for (x = 0; x < surface_desc.dwWidth; ++x)
+        {
+            ptr[x] = color;
+        }
+    }
+
+    hr = IDirectDrawSurface_Unlock(surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+}
+
 static void test_flip(void)
 {
     const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
@@ -4263,7 +4289,6 @@ static void test_flip(void)
     D3DCOLOR color;
     ULONG refcount;
     HWND window;
-    DDBLTFX fx;
     HRESULT hr;
 
     static const struct
@@ -4416,17 +4441,9 @@ static void test_flip(void)
         hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
         ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
 
-        memset(&fx, 0, sizeof(fx));
-        fx.dwSize = sizeof(fx);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
+        fill_surface(backbuffer2, 0xff00ff00);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -4437,9 +4454,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -4448,9 +4463,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -4459,9 +4472,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -4470,9 +4481,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -4481,9 +4490,7 @@ static void test_flip(void)
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index be950d8..5f864cc 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4863,6 +4863,32 @@ static void test_surface_discard(void)
     DestroyWindow(window);
 }
 
+/* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
+ * the backbuffer has been locked or GetSurfaceDesc has been called. Do it ourselves
+ * as a workaround. */
+static void fill_surface(IDirectDrawSurface *surface, D3DCOLOR color)
+{
+    DDSURFACEDESC surface_desc = {sizeof(surface_desc)};
+    HRESULT hr;
+    unsigned int x, y;
+    DWORD *ptr;
+
+    hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+
+    for (y = 0; y < surface_desc.dwHeight; ++y)
+    {
+        ptr = (DWORD *)((BYTE *)surface_desc.lpSurface + y * surface_desc.lPitch);
+        for (x = 0; x < surface_desc.dwWidth; ++x)
+        {
+            ptr[x] = color;
+        }
+    }
+
+    hr = IDirectDrawSurface_Unlock(surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+}
+
 static void test_flip(void)
 {
     const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
@@ -4876,7 +4902,6 @@ static void test_flip(void)
     D3DCOLOR color;
     ULONG refcount;
     HWND window;
-    DDBLTFX fx;
     HRESULT hr;
 
     static const struct
@@ -5029,17 +5054,9 @@ static void test_flip(void)
         hr = IDirectDrawSurface_Flip(backbuffer3, NULL, DDFLIP_WAIT);
         ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
 
-        memset(&fx, 0, sizeof(fx));
-        fx.dwSize = sizeof(fx);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
+        fill_surface(backbuffer2, 0xff00ff00);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -5050,9 +5067,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -5061,9 +5076,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -5072,9 +5085,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -5083,9 +5094,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -5094,9 +5103,7 @@ static void test_flip(void)
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 2f92a70..d4173e5 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -6142,6 +6142,32 @@ static void test_surface_discard(void)
     DestroyWindow(window);
 }
 
+/* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
+ * the backbuffer has been locked. Do it ourselves as a workaround. Unlike ddraw1
+ * and 2 GetSurfaceDesc does not cause issues in ddraw4 and ddraw7. */
+static void fill_surface(IDirectDrawSurface4 *surface, D3DCOLOR color)
+{
+    DDSURFACEDESC2 surface_desc = {sizeof(surface_desc)};
+    HRESULT hr;
+    unsigned int x, y;
+    DWORD *ptr;
+
+    hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+
+    for (y = 0; y < surface_desc.dwHeight; ++y)
+    {
+        ptr = (DWORD *)((BYTE *)surface_desc.lpSurface + y * surface_desc.lPitch);
+        for (x = 0; x < surface_desc.dwWidth; ++x)
+        {
+            ptr[x] = color;
+        }
+    }
+
+    hr = IDirectDrawSurface4_Unlock(surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+}
+
 static void test_flip(void)
 {
     const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
@@ -6155,7 +6181,6 @@ static void test_flip(void)
     D3DCOLOR color;
     ULONG refcount;
     HWND window;
-    DDBLTFX fx;
     HRESULT hr;
 
     static const struct
@@ -6308,17 +6333,9 @@ static void test_flip(void)
         hr = IDirectDrawSurface4_Flip(backbuffer3, NULL, DDFLIP_WAIT);
         ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
 
-        memset(&fx, 0, sizeof(fx));
-        fx.dwSize = sizeof(fx);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface4_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface4_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
+        fill_surface(backbuffer2, 0xff00ff00);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6329,9 +6346,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6340,9 +6355,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6351,9 +6364,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface4_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6362,9 +6373,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface4_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6373,9 +6382,7 @@ static void test_flip(void)
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface4_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface4_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 6a35cb8..73509fb 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -6016,6 +6016,32 @@ static void test_surface_discard(void)
     DestroyWindow(window);
 }
 
+/* The Nvidia Geforce 7 driver cannot do a color fill on a texture backbuffer after
+ * the backbuffer has been locked. Do it ourselves as a workaround. Unlike ddraw1
+ * and 2 GetSurfaceDesc does not cause issues in ddraw4 and ddraw7. */
+static void fill_surface(IDirectDrawSurface7 *surface, D3DCOLOR color)
+{
+    DDSURFACEDESC2 surface_desc = {sizeof(surface_desc)};
+    HRESULT hr;
+    unsigned int x, y;
+    DWORD *ptr;
+
+    hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, DDLOCK_WAIT, NULL);
+    ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
+
+    for (y = 0; y < surface_desc.dwHeight; ++y)
+    {
+        ptr = (DWORD *)((BYTE *)surface_desc.lpSurface + y * surface_desc.lPitch);
+        for (x = 0; x < surface_desc.dwWidth; ++x)
+        {
+            ptr[x] = color;
+        }
+    }
+
+    hr = IDirectDrawSurface7_Unlock(surface, NULL);
+    ok(SUCCEEDED(hr), "Failed to unlock surface, hr %#x.\n", hr);
+}
+
 static void test_flip(void)
 {
     const DWORD placement = DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
@@ -6031,7 +6057,6 @@ static void test_flip(void)
     D3DCOLOR color;
     ULONG refcount;
     HWND window;
-    DDBLTFX fx;
     HRESULT hr;
 
     static const struct
@@ -6186,17 +6211,13 @@ static void test_flip(void)
         hr = IDirectDrawSurface7_Flip(backbuffer3, NULL, DDFLIP_WAIT);
         ok(hr == DDERR_NOTFLIPPABLE, "%s: Got unexpected hr %#x.\n", test_data[i].name, hr);
 
-        memset(&fx, 0, sizeof(fx));
-        fx.dwSize = sizeof(fx);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface7_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface7_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        color = get_surface_color(backbuffer1, 320, 240);
+        color = get_surface_color(backbuffer2, 320, 240);
+        color = get_surface_color(backbuffer3, 320, 240);
+
+        fill_surface(backbuffer1, 0xffff0000);
+        fill_surface(backbuffer2, 0xff00ff00);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6207,9 +6228,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xffff0000);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6218,9 +6237,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x00ff0000, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff00ff00);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, NULL, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6229,9 +6246,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer2, 320, 240);
         ok(compare_color(color, 0x0000ff00, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff0000ff;
-        hr = IDirectDrawSurface7_Blt(backbuffer3, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer3, 0xff0000ff);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer1, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6240,9 +6255,7 @@ static void test_flip(void)
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1), "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xffff0000;
-        hr = IDirectDrawSurface7_Blt(backbuffer1, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer1, 0xffff0000);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer2, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
@@ -6251,9 +6264,7 @@ static void test_flip(void)
         color = get_surface_color(backbuffer3, 320, 240);
         ok(compare_color(color, 0x000000ff, 1) || broken(sysmem_primary && compare_color(color, 0x00ff0000, 1)),
                 "%s: Got unexpected color 0x%08x.\n", test_data[i].name, color);
-        U5(fx).dwFillColor = 0xff00ff00;
-        hr = IDirectDrawSurface7_Blt(backbuffer2, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
-        ok(SUCCEEDED(hr), "%s: Failed to fill surface, hr %#x.\n", test_data[i].name, hr);
+        fill_surface(backbuffer2, 0xff00ff00);
 
         hr = IDirectDrawSurface7_Flip(frontbuffer, backbuffer3, DDFLIP_WAIT);
         ok(SUCCEEDED(hr), "%s: Failed to flip, hr %#x.\n", test_data[i].name, hr);
-- 
2.10.2




More information about the wine-patches mailing list