[PATCH 6/6] ddraw/tests: Test creating flippable cubemaps.

Józef Kucia jkucia at codeweavers.com
Mon Apr 25 05:25:34 CDT 2016


Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/ddraw/surface.c      |  2 ++
 dlls/ddraw/tests/ddraw7.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index 4e79d1a..d36afe7 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -5755,6 +5755,8 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
         {
             WARN("Tried to specify a back buffer count for a non-flippable surface.\n");
             HeapFree(GetProcessHeap(), 0, texture);
+            if (desc->ddsCaps.dwCaps2 & DDSCAPS2_CUBEMAP)
+                return DDERR_INVALIDPARAMS;
             return DDERR_INVALIDCAPS;
         }
     }
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 7ea1d6e..52c1059 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -5991,6 +5991,8 @@ static void test_flip(void)
     IDirectDrawSurface7 *frontbuffer, *backbuffer1, *backbuffer2, *backbuffer3, *surface;
     DDSCAPS2 caps = {DDSCAPS_FLIP, 0, 0, {0}};
     DDSURFACEDESC2 surface_desc;
+    D3DDEVICEDESC7 device_desc;
+    IDirect3DDevice7 *device;
     BOOL sysmem_primary;
     IDirectDraw7 *ddraw;
     DWORD expected_caps;
@@ -6227,6 +6229,54 @@ static void test_flip(void)
         IDirectDrawSurface7_Release(frontbuffer);
     }
 
+    if (!(device = create_device(window, DDSCL_NORMAL)))
+    {
+        skip("Failed to create 3D device.\n");
+        goto done;
+    }
+    hr = IDirect3DDevice7_GetCaps(device, &device_desc);
+    ok(SUCCEEDED(hr), "Failed to get device caps, hr %#x.\n", hr);
+    IDirect3DDevice7_Release(device);
+    if (!(device_desc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_CUBEMAP))
+    {
+        skip("Cubemaps not supported.\n");
+        goto done;
+    }
+
+    memset(&surface_desc, 0, sizeof(surface_desc));
+    surface_desc.dwSize = sizeof(surface_desc);
+    surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
+    surface_desc.ddsCaps.dwCaps = DDSCAPS_COMPLEX | DDSCAPS_FLIP | DDSCAPS_TEXTURE;
+    surface_desc.ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_ALLFACES;
+    surface_desc.dwWidth = 128;
+    surface_desc.dwHeight = 128;
+    surface_desc.dwBackBufferCount = 3;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+
+    surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_FLIP;
+    surface_desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+    surface_desc.ddsCaps.dwCaps &= ~DDSCAPS_COMPLEX;
+    surface_desc.ddsCaps.dwCaps |= DDSCAPS_FLIP;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+
+    surface_desc.ddsCaps.dwCaps |= DDSCAPS_COMPLEX;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+    surface_desc.dwBackBufferCount = 1;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDPARAMS, "Got unexpected hr %#x.\n", hr);
+
+    surface_desc.dwBackBufferCount = 0;
+    hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &frontbuffer, NULL);
+    ok(hr == DDERR_INVALIDCAPS, "Got unexpected hr %#x.\n", hr);
+
+done:
     refcount = IDirectDraw7_Release(ddraw);
     ok(refcount == 0, "The ddraw object was not properly freed, refcount %u.\n", refcount);
     DestroyWindow(window);
-- 
2.7.3




More information about the wine-patches mailing list