/*
+ * Copyright 2005 Antoine Chavasse (a.chavasse@gmail.com)
* Copyright 2011-2014 Henri Verbeet for CodeWeavers
* Copyright 2012-2013 Stefan Dösinger for CodeWeavers
*
DestroyWindow(window);
}
-static void test_mipmap_lock(void)
+static void test_mipmap(void)
{
IDirectDrawSurface *surface, *surface2;
DDSURFACEDESC surface_desc;
IDirectDraw *ddraw;
+ unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
DDSCAPS caps = {DDSCAPS_COMPLEX};
DDCAPS hal_caps;
+ static const struct
+ {
+ DWORD flags;
+ DWORD caps;
+ DWORD width;
+ DWORD height;
+ DWORD mipmap_count_in;
+ HRESULT hr;
+ DWORD mipmap_count_out;
+ }
+ tests[] =
+ {
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 3, DD_OK, 3},
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DDERR_INVALIDPARAMS, 0},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 1},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 6},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 32, 64, 0, DD_OK, 6},
+ };
+
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
{
- skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ skip("Mipmapped textures not supported, skipping tests.\n");
IDirectDraw_Release(ddraw);
DestroyWindow(window);
return;
}
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- surface_desc.dwWidth = 4;
- surface_desc.dwHeight = 4;
- U2(surface_desc).dwMipMapCount = 2;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
- | DDSCAPS_SYSTEMMEMORY;
- hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | tests[i].flags;
+ surface_desc.ddsCaps.dwCaps = tests[i].caps;
+ surface_desc.dwWidth = tests[i].width;
+ surface_desc.dwHeight = tests[i].height;
+ if (tests[i].flags & DDSD_MIPMAPCOUNT)
+ U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
+ hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface_Lock(surface2, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- IDirectDrawSurface_Unlock(surface2, NULL);
- IDirectDrawSurface_Unlock(surface, NULL);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+ ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
+ "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+
+ if (U2(surface_desc).dwMipMapCount > 1)
+ {
+ hr = IDirectDrawSurface_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ IDirectDrawSurface_Unlock(surface2, NULL);
+ IDirectDrawSurface_Unlock(surface, NULL);
+
+ IDirectDrawSurface_Release(surface2);
+ }
+
+ IDirectDrawSurface_Release(surface);
+ }
- IDirectDrawSurface_Release(surface2);
- IDirectDrawSurface_Release(surface);
refcount = IDirectDraw_Release(ddraw);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
DestroyWindow(window);
test_surface_attachment();
test_pixel_format();
test_create_surface_pitch();
- test_mipmap_lock();
+ test_mipmap();
test_palette_complex();
test_p8_rgb_blit();
test_material();
/*
+ * Copyright 2005 Antoine Chavasse (a.chavasse@gmail.com)
* Copyright 2011-2014 Henri Verbeet for CodeWeavers
* Copyright 2012-2014 Stefan Dösinger for CodeWeavers
*
DestroyWindow(window);
}
-static void test_mipmap_lock(void)
+static void test_mipmap(void)
{
IDirectDrawSurface *surface1;
IDirectDrawSurface2 *surface, *surface2;
DDSURFACEDESC surface_desc;
IDirectDraw2 *ddraw;
+ unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
DDSCAPS caps = {DDSCAPS_COMPLEX};
DDCAPS hal_caps;
+ static const struct
+ {
+ DWORD flags;
+ DWORD caps;
+ DWORD width;
+ DWORD height;
+ DWORD mipmap_count_in;
+ HRESULT hr;
+ DWORD mipmap_count_out;
+ }
+ tests[] =
+ {
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 3, DD_OK, 3},
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DDERR_INVALIDPARAMS, 0},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 1},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 6},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 32, 64, 0, DD_OK, 6},
+ };
+
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
{
- skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ skip("Mipmapped textures not supported, skipping tests.\n");
IDirectDraw2_Release(ddraw);
DestroyWindow(window);
return;
}
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- surface_desc.dwWidth = 4;
- surface_desc.dwHeight = 4;
- U2(surface_desc).dwMipMapCount = 2;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
- | DDSCAPS_SYSTEMMEMORY;
- hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | tests[i].flags;
+ surface_desc.ddsCaps.dwCaps = tests[i].caps;
+ surface_desc.dwWidth = tests[i].width;
+ surface_desc.dwHeight = tests[i].height;
+ if (tests[i].flags & DDSD_MIPMAPCOUNT)
+ U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL);
+ ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
- hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
- ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface2 interface, hr %#x.\n", hr);
- IDirectDrawSurface_Release(surface1);
- hr = IDirectDrawSurface2_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get IDirectDrawSurface2 interface, hr %#x.\n", i, hr);
+ IDirectDrawSurface_Release(surface1);
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface2_Lock(surface2, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- IDirectDrawSurface2_Unlock(surface2, NULL);
- IDirectDrawSurface2_Unlock(surface, NULL);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_GetSurfaceDesc(surface, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+ ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
+ "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+
+ if (U2(surface_desc).dwMipMapCount > 1)
+ {
+ hr = IDirectDrawSurface2_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface2_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ IDirectDrawSurface2_Unlock(surface2, NULL);
+ IDirectDrawSurface2_Unlock(surface, NULL);
+
+ IDirectDrawSurface2_Release(surface2);
+ }
+
+ IDirectDrawSurface2_Release(surface);
+ }
- IDirectDrawSurface2_Release(surface2);
- IDirectDrawSurface2_Release(surface);
refcount = IDirectDraw2_Release(ddraw);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
DestroyWindow(window);
test_surface_attachment();
test_pixel_format();
test_create_surface_pitch();
- test_mipmap_lock();
+ test_mipmap();
test_palette_complex();
test_p8_rgb_blit();
test_material();
/*
+ * Copyright 2005 Antoine Chavasse (a.chavasse@gmail.com)
* Copyright 2011-2014 Henri Verbeet for CodeWeavers
* Copyright 2012-2014 Stefan Dösinger for CodeWeavers
*
DestroyWindow(window);
}
-static void test_mipmap_lock(void)
+static void test_mipmap(void)
{
IDirectDrawSurface4 *surface, *surface2;
DDSURFACEDESC2 surface_desc;
IDirectDraw4 *ddraw;
+ unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, {0}};
DDCAPS hal_caps;
+ static const struct
+ {
+ DWORD flags;
+ DWORD caps;
+ DWORD width;
+ DWORD height;
+ DWORD mipmap_count_in;
+ HRESULT hr;
+ DWORD mipmap_count_out;
+ }
+ tests[] =
+ {
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 3, DD_OK, 3},
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DDERR_INVALIDPARAMS, 0},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 1},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 6},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 32, 64, 0, DD_OK, 6},
+ };
+
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
ok(SUCCEEDED(hr), "Failed to get caps, hr %#x.\n", hr);
if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP))
{
- skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ skip("Mipmapped textures not supported, skipping tests.\n");
IDirectDraw4_Release(ddraw);
DestroyWindow(window);
return;
}
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- surface_desc.dwWidth = 4;
- surface_desc.dwHeight = 4;
- U2(surface_desc).dwMipMapCount = 2;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
- | DDSCAPS_SYSTEMMEMORY;
- hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | tests[i].flags;
+ surface_desc.ddsCaps.dwCaps = tests[i].caps;
+ surface_desc.dwWidth = tests[i].width;
+ surface_desc.dwHeight = tests[i].height;
+ if (tests[i].flags & DDSD_MIPMAPCOUNT)
+ U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
+ hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface4_Lock(surface2, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- IDirectDrawSurface4_Unlock(surface2, NULL);
- IDirectDrawSurface4_Unlock(surface, NULL);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+ ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
+ "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+
+ if (U2(surface_desc).dwMipMapCount > 1)
+ {
+ hr = IDirectDrawSurface4_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface4_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ IDirectDrawSurface4_Unlock(surface2, NULL);
+ IDirectDrawSurface4_Unlock(surface, NULL);
+
+ IDirectDrawSurface4_Release(surface2);
+ }
+
+ IDirectDrawSurface4_Release(surface);
+ }
- IDirectDrawSurface4_Release(surface2);
- IDirectDrawSurface4_Release(surface);
refcount = IDirectDraw4_Release(ddraw);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
DestroyWindow(window);
test_private_data();
test_pixel_format();
test_create_surface_pitch();
- test_mipmap_lock();
+ test_mipmap();
test_palette_complex();
test_p8_rgb_blit();
test_material();
/*
+ * Copyright 2005 Antoine Chavasse (a.chavasse@gmail.com)
* Copyright 2006, 2012-2014 Stefan Dösinger for CodeWeavers
* Copyright 2011-2014 Henri Verbeet for CodeWeavers
*
DestroyWindow(window);
}
-static void test_mipmap_lock(void)
+static void test_mipmap(void)
{
IDirectDrawSurface7 *surface, *surface2;
DDSURFACEDESC2 surface_desc;
IDirectDraw7 *ddraw;
+ unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
DDSCAPS2 caps = {DDSCAPS_COMPLEX, 0, 0, {0}};
DDCAPS hal_caps;
+ static const struct
+ {
+ DWORD flags;
+ DWORD caps;
+ DWORD width;
+ DWORD height;
+ DWORD mipmap_count_in;
+ HRESULT hr;
+ DWORD mipmap_count_out;
+ }
+ tests[] =
+ {
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 3, DD_OK, 3},
+ {DDSD_MIPMAPCOUNT, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DDERR_INVALIDPARAMS, 0},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 1},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 128, 32, 0, DD_OK, 8},
+ {0, DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP, 32, 64, 0, DD_OK, 7},
+ };
+
window = CreateWindowA("static", "ddraw_test", WS_OVERLAPPEDWINDOW,
0, 0, 640, 480, 0, 0, 0, 0);
ddraw = create_ddraw();
if ((hal_caps.ddsCaps.dwCaps & (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)) != (DDSCAPS_TEXTURE | DDSCAPS_MIPMAP)
|| is_ddraw64)
{
- skip("Mipmapped textures not supported, skipping mipmap lock test.\n");
+ skip("Mipmapped textures not supported, skipping tests.\n");
IDirectDraw7_Release(ddraw);
DestroyWindow(window);
return;
}
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- surface_desc.dwWidth = 4;
- surface_desc.dwHeight = 4;
- U2(surface_desc).dwMipMapCount = 2;
- surface_desc.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP
- | DDSCAPS_SYSTEMMEMORY;
- hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
- hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
- ok(SUCCEEDED(hr), "Failed to get attached surface, hr %#x.\n", hr);
+ for (i = 0; i < sizeof(tests) / sizeof(*tests); ++i)
+ {
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | tests[i].flags;
+ surface_desc.ddsCaps.dwCaps = tests[i].caps;
+ surface_desc.dwWidth = tests[i].width;
+ surface_desc.dwHeight = tests[i].height;
+ if (tests[i].flags & DDSD_MIPMAPCOUNT)
+ U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ if (FAILED(hr))
+ continue;
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- memset(&surface_desc, 0, sizeof(surface_desc));
- surface_desc.dwSize = sizeof(surface_desc);
- hr = IDirectDrawSurface7_Lock(surface2, NULL, &surface_desc, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to lock surface, hr %#x.\n", hr);
- IDirectDrawSurface7_Unlock(surface2, NULL);
- IDirectDrawSurface7_Unlock(surface, NULL);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get surface desc, hr %#x.\n", i, hr);
+ ok(surface_desc.dwFlags & DDSD_MIPMAPCOUNT,
+ "Test %u: Got unexpected flags %#x.\n", i, surface_desc.dwFlags);
+ ok(U2(surface_desc).dwMipMapCount == tests[i].mipmap_count_out,
+ "Test %u: Got unexpected mipmap count %u.\n", i, U2(surface_desc).dwMipMapCount);
+
+ if (U2(surface_desc).dwMipMapCount > 1)
+ {
+ hr = IDirectDrawSurface7_GetAttachedSurface(surface, &caps, &surface2);
+ ok(SUCCEEDED(hr), "Test %u: Failed to get attached surface, hr %#x.\n", i, hr);
+
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_Lock(surface2, NULL, &surface_desc, 0, NULL);
+ ok(SUCCEEDED(hr), "Test %u: Failed to lock surface, hr %#x.\n", i, hr);
+ IDirectDrawSurface7_Unlock(surface2, NULL);
+ IDirectDrawSurface7_Unlock(surface, NULL);
+
+ IDirectDrawSurface7_Release(surface2);
+ }
+
+ IDirectDrawSurface7_Release(surface);
+ }
- IDirectDrawSurface7_Release(surface2);
- IDirectDrawSurface7_Release(surface);
refcount = IDirectDraw7_Release(ddraw);
ok(!refcount, "Got unexpected refcount %u.\n", refcount);
DestroyWindow(window);
test_private_data();
test_pixel_format();
test_create_surface_pitch();
- test_mipmap_lock();
+ test_mipmap();
test_palette_complex();
test_p8_rgb_blit();
test_material();
}
}
-static void MipMapCreationTest(void)
-{
- IDirectDrawSurface *lpDDSMipMapTest;
- DDSURFACEDESC ddsd;
- HRESULT rc;
-
- /* First mipmap creation test: create a surface with DDSCAPS_COMPLEX,
- DDSCAPS_MIPMAP, and DDSD_MIPMAPCOUNT. This create the number of
- requested mipmap levels. */
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
- U2(ddsd).dwMipMapCount = 3;
- ddsd.dwWidth = 128;
- ddsd.dwHeight = 32;
- rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
- ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
- if (FAILED(rc))
- {
- skip("failed to create surface\n");
- return;
- }
-
- /* Check the number of created mipmaps */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
- ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
- ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
- "GetSurfaceDesc returned no mipmapcount.\n");
- ok(U2(ddsd).dwMipMapCount == 3, "Incorrect mipmap count: %d.\n",
- U2(ddsd).dwMipMapCount);
-
- /* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
-
-
- /* Second mipmap creation test: create a surface without a mipmap
- count, with DDSCAPS_MIPMAP and without DDSCAPS_COMPLEX.
- This creates a single mipmap level. */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_MIPMAP;
- ddsd.dwWidth = 128;
- ddsd.dwHeight = 32;
- rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
- ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
- if (FAILED(rc))
- {
- skip("failed to create surface\n");
- return;
- }
- /* Check the number of created mipmaps */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
- ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
- ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
- "GetSurfaceDesc returned no mipmapcount.\n");
- ok(U2(ddsd).dwMipMapCount == 1, "Incorrect mipmap count: %d.\n",
- U2(ddsd).dwMipMapCount);
-
- /* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
-
-
- /* Third mipmap creation test: create a surface with DDSCAPS_MIPMAP,
- DDSCAPS_COMPLEX and without DDSD_MIPMAPCOUNT.
- It's an undocumented features where a chain of mipmaps, starting from
- he specified size and down to the smallest size, is automatically
- created.
- Anarchy Online needs this feature to work. */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
- ddsd.dwWidth = 128;
- ddsd.dwHeight = 32;
- rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
- ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
- if (FAILED(rc))
- {
- skip("failed to create surface\n");
- return;
- }
-
- /* Check the number of created mipmaps */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
- ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
- ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
- "GetSurfaceDesc returned no mipmapcount.\n");
- ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %d.\n",
- U2(ddsd).dwMipMapCount);
-
- /* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
-
-
- /* Fourth mipmap creation test: same as above with a different texture
- size.
- The purpose is to verify that the number of generated mipmaps is
- dependent on the smallest dimension. */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
- ddsd.dwWidth = 32;
- ddsd.dwHeight = 64;
- rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
- ok(rc==DD_OK,"CreateSurface returned: %x\n",rc);
- if (FAILED(rc))
- {
- skip("failed to create surface\n");
- return;
- }
-
- /* Check the number of created mipmaps */
- memset(&ddsd, 0, sizeof(DDSURFACEDESC));
- ddsd.dwSize = sizeof(ddsd);
- rc = IDirectDrawSurface_GetSurfaceDesc(lpDDSMipMapTest, &ddsd);
- ok(rc==DD_OK,"GetSurfaceDesc returned: %x\n",rc);
- ok(ddsd.dwFlags & DDSD_MIPMAPCOUNT,
- "GetSurfaceDesc returned no mipmapcount.\n");
- ok(U2(ddsd).dwMipMapCount == 6, "Incorrect mipmap count: %d.\n",
- U2(ddsd).dwMipMapCount);
-
- /* Destroy the surface. */
- IDirectDrawSurface_Release(lpDDSMipMapTest);
-
-
- /* Fifth mipmap creation test: try to create a surface with
- DDSCAPS_COMPLEX, DDSCAPS_MIPMAP, DDSD_MIPMAPCOUNT,
- where dwMipMapCount = 0. This should fail. */
-
- ddsd.dwSize = sizeof(ddsd);
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_MIPMAPCOUNT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_TEXTURE | DDSCAPS_COMPLEX | DDSCAPS_MIPMAP;
- U2(ddsd).dwMipMapCount = 0;
- ddsd.dwWidth = 128;
- ddsd.dwHeight = 32;
- rc = IDirectDraw_CreateSurface(lpDD, &ddsd, &lpDDSMipMapTest, NULL);
- ok(rc==DDERR_INVALIDPARAMS,"CreateSurface returned: %x\n",rc);
-
- /* Destroy the surface. */
- if( rc == DD_OK )
- IDirectDrawSurface_Release(lpDDSMipMapTest);
-
-}
-
static void SrcColorKey32BlitTest(void)
{
IDirectDrawSurface *lpSrc;
return;
}
- MipMapCreationTest();
SrcColorKey32BlitTest();
QueryInterface();
GetDDInterface_1();