From c86263aa5d3bea75f089fd5deeba6235e1d122f6 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Tue, 20 Dec 2022 21:44:43 -0600 Subject: [PATCH] ddraw: Forbid DDSD_MIPMAPCOUNT without DDSCAPS_COMPLEX. --- dlls/ddraw/surface.c | 8 ++++++++ dlls/ddraw/tests/ddraw1.c | 9 +-------- dlls/ddraw/tests/ddraw2.c | 9 +-------- dlls/ddraw/tests/ddraw4.c | 9 +-------- dlls/ddraw/tests/ddraw7.c | 9 +-------- 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index cdb1cfe109d..ddbe08f2260 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -6126,6 +6126,14 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ return DDERR_INVALIDCAPS; } + if ((desc->dwFlags & DDSD_MIPMAPCOUNT) && !(desc->ddsCaps.dwCaps & DDSCAPS_COMPLEX)) + { + /* This is illegal even if there is only one mipmap level. */ + WARN("DDSD_MIPMAPCOUNT specified without DDSCAPS_COMPLEX.\n"); + heap_free(texture); + return DDERR_INVALIDCAPS; + } + if (desc->ddsCaps.dwCaps & DDSCAPS_FLIP) { if (!(desc->dwFlags & DDSD_BACKBUFFERCOUNT) || !desc->u5.dwBackBufferCount) diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 2d7d350517e..4f950d775b2 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -6323,17 +6323,10 @@ static void test_mipmap(void) if (tests[i].flags & DDSD_MIPMAPCOUNT) U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in; hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); - todo_wine_if (i == 7 || i == 8) - ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); + ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); if (FAILED(hr)) continue; - if (FAILED(tests[i].hr)) - { - IDirectDrawSurface_Release(surface); - continue; - } - memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index 5733c879b4e..476531d41a5 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -7452,17 +7452,10 @@ static void test_mipmap(void) if (tests[i].flags & DDSD_MIPMAPCOUNT) U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in; hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface1, NULL); - todo_wine_if (i == 7 || i == 8) - ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); + ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); if (FAILED(hr)) continue; - if (FAILED(tests[i].hr)) - { - IDirectDrawSurface_Release(surface); - continue; - } - hr = IDirectDrawSurface_QueryInterface(surface1, &IID_IDirectDrawSurface2, (void **)&surface); ok(SUCCEEDED(hr), "Test %u: Failed to get IDirectDrawSurface2 interface, hr %#lx.\n", i, hr); IDirectDrawSurface_Release(surface1); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index 81bf170711d..71052214baf 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -9353,17 +9353,10 @@ static void test_mipmap(void) if (tests[i].flags & DDSD_MIPMAPCOUNT) U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in; hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL); - todo_wine_if (i == 7 || i == 8) - ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); + ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); if (FAILED(hr)) continue; - if (FAILED(tests[i].hr)) - { - IDirectDrawSurface4_Release(surface); - continue; - } - memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface4_GetSurfaceDesc(surface, &surface_desc); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 229448d135a..8ac62b303e1 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -9197,17 +9197,10 @@ static void test_mipmap(void) if (tests[i].flags & DDSD_MIPMAPCOUNT) U2(surface_desc).dwMipMapCount = tests[i].mipmap_count_in; hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL); - todo_wine_if (i == 7 || i == 8) - ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); + ok(hr == tests[i].hr, "Test %u: Got unexpected hr %#lx.\n", i, hr); if (FAILED(hr)) continue; - if (FAILED(tests[i].hr)) - { - IDirectDrawSurface7_Release(surface); - continue; - } - memset(&surface_desc, 0, sizeof(surface_desc)); surface_desc.dwSize = sizeof(surface_desc); hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);