diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 8403a32f083..efa7f662522 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4245,7 +4245,8 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, WARN("Flags is %x, returning DDERR_INVALIDPARAMS\n", Flags); return DDERR_INVALIDPARAMS; } - if (!(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)) + if (!(This->surface_desc.ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY) || + This->surface_desc.ddsCaps.dwCaps2 & (DDSCAPS2_TEXTUREMANAGE | DDSCAPS2_D3DTEXTUREMANAGE)) { WARN("Surface is not in system memory, returning DDERR_INVALIDSURFACETYPE.\n"); return DDERR_INVALIDSURFACETYPE; diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index d37cedd56b8..154e1b2fa54 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -4414,6 +4414,18 @@ static void test_set_surface_desc(void) IDirectDrawSurface3 *surface3; BYTE data[16*16*4]; ULONG ref; + unsigned int i; + static const struct + { + DWORD caps; + BOOL supported; + const char *name; + } + invalid_caps_tests[] = + { + {DDSCAPS_VIDEOMEMORY, FALSE, "videomemory plain"}, + {DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, TRUE, "systemmemory texture"}, + }; if (!(ddraw = create_ddraw())) { @@ -4611,44 +4623,57 @@ static void test_set_surface_desc(void) IDirectDrawSurface3_Release(surface3); - /* Need systemmemory surfaces. + /* SetSurfaceDesc needs systemmemory surfaces. * * As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */ - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; - ddsd.dwWidth = 8; - ddsd.dwHeight = 8; - ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; - U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; - U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; - U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; - U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; - ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; - - hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL); - ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); - if (FAILED(hr)) + for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++) { - skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n"); - goto done; + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; + ddsd.dwWidth = 8; + ddsd.dwHeight = 8; + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); + ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; + U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; + ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps; + + hr = IDirectDraw_CreateSurface(ddraw, &ddsd, &surface, NULL); + ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); + if (FAILED(hr)) + { + skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n", + invalid_caps_tests[i].name); + goto done; + } + hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3); + ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr); + IDirectDrawSurface_Release(surface); + + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_LPSURFACE; + ddsd.lpSurface = data; + hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0); + if (invalid_caps_tests[i].supported) + { + ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr); + } + else + { + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + + /* Check priority of error conditions. */ + ddsd.dwFlags = DDSD_WIDTH; + hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0); + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + } + + IDirectDrawSurface3_Release(surface3); } - hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirectDrawSurface3, (void **)&surface3); - ok(SUCCEEDED(hr), "Failed to get IDirectDrawSurface3 interface, hr %#x.\n", hr); - IDirectDrawSurface_Release(surface); - - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_LPSURFACE; - ddsd.lpSurface = data; - hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - /* Check priority of error conditions. */ - ddsd.dwFlags = DDSD_WIDTH; - hr = IDirectDrawSurface3_SetSurfaceDesc(surface3, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - IDirectDrawSurface3_Release(surface3); done: ref = IDirectDraw2_Release(ddraw); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index e8128a56e52..6012f738d4b 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -5017,6 +5017,20 @@ static void test_set_surface_desc(void) IDirectDrawSurface4 *surface; BYTE data[16*16*4]; ULONG ref; + unsigned int i; + static const struct + { + DWORD caps, caps2; + BOOL supported; + const char *name; + } + invalid_caps_tests[] = + { + {DDSCAPS_VIDEOMEMORY, 0, FALSE, "videomemory plain"}, + {DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, 0, TRUE, "systemmemory texture"}, + {DDSCAPS_TEXTURE, DDSCAPS2_D3DTEXTUREMANAGE, FALSE, "managed texture"}, + {DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE, FALSE, "managed texture"}, + }; if (!(ddraw = create_ddraw())) { @@ -5210,42 +5224,56 @@ static void test_set_surface_desc(void) IDirectDrawSurface4_Release(surface); - /* Need systemmemory surfaces. + /* SetSurfaceDesc needs systemmemory surfaces. * * As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */ - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; - ddsd.dwWidth = 8; - ddsd.dwHeight = 8; - ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; - U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; - U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; - U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; - U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; - ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; - - hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL); - ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); - if (FAILED(hr)) + for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++) { - skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n"); - goto done; + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; + ddsd.dwWidth = 8; + ddsd.dwHeight = 8; + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); + ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; + U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; + ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps; + ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2; + + hr = IDirectDraw4_CreateSurface(ddraw, &ddsd, &surface, NULL); + ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); + if (FAILED(hr)) + { + skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n", + invalid_caps_tests[i].name); + goto done; + } + + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_LPSURFACE; + ddsd.lpSurface = data; + hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0); + if (invalid_caps_tests[i].supported) + { + ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr); + } + else + { + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + + /* Check priority of error conditions. */ + ddsd.dwFlags = DDSD_WIDTH; + hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0); + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + } + + IDirectDrawSurface4_Release(surface); } - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_LPSURFACE; - ddsd.lpSurface = data; - hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - /* Check priority of error conditions. */ - ddsd.dwFlags = DDSD_WIDTH; - hr = IDirectDrawSurface4_SetSurfaceDesc(surface, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - IDirectDrawSurface4_Release(surface); - done: ref = IDirectDraw4_Release(ddraw); ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index 58bde959137..26bb82cdaff 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -4904,6 +4904,20 @@ static void test_set_surface_desc(void) IDirectDrawSurface7 *surface; BYTE data[16*16*4]; ULONG ref; + unsigned int i; + static const struct + { + DWORD caps, caps2; + BOOL supported; + const char *name; + } + invalid_caps_tests[] = + { + {DDSCAPS_VIDEOMEMORY, 0, FALSE, "videomemory plain"}, + {DDSCAPS_TEXTURE | DDSCAPS_SYSTEMMEMORY, 0, TRUE, "systemmemory texture"}, + {DDSCAPS_TEXTURE, DDSCAPS2_D3DTEXTUREMANAGE, FALSE, "managed texture"}, + {DDSCAPS_TEXTURE, DDSCAPS2_TEXTUREMANAGE, FALSE, "managed texture"}, + }; if (!(ddraw = create_ddraw())) { @@ -5097,42 +5111,56 @@ static void test_set_surface_desc(void) IDirectDrawSurface7_Release(surface); - /* Need systemmemory surfaces. + /* SetSurfaceDesc needs systemmemory surfaces. * * As a sidenote, fourcc surfaces aren't allowed in sysmem, thus testing DDSD_LINEARSIZE is moot. */ - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; - ddsd.dwWidth = 8; - ddsd.dwHeight = 8; - ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); - ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; - U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; - U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; - U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; - U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; - ddsd.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; - - hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL); - ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); - if (FAILED(hr)) + for (i = 0; i < sizeof(invalid_caps_tests) / sizeof(*invalid_caps_tests); i++) { - skip("Cannot create a video memory surface, skipping vidmem SetSurfaceDesc test.\n"); - goto done; + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT; + ddsd.dwWidth = 8; + ddsd.dwHeight = 8; + ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat); + ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB; + U1(ddsd.ddpfPixelFormat).dwRGBBitCount = 32; + U2(ddsd.ddpfPixelFormat).dwRBitMask = 0x00ff0000; + U3(ddsd.ddpfPixelFormat).dwGBitMask = 0x0000ff00; + U4(ddsd.ddpfPixelFormat).dwBBitMask = 0x000000ff; + ddsd.ddsCaps.dwCaps = invalid_caps_tests[i].caps; + ddsd.ddsCaps.dwCaps2 = invalid_caps_tests[i].caps2; + + hr = IDirectDraw7_CreateSurface(ddraw, &ddsd, &surface, NULL); + ok(SUCCEEDED(hr) || hr == DDERR_NODIRECTDRAWHW, "Failed to create surface, hr %#x.\n", hr); + if (FAILED(hr)) + { + skip("Cannot create a %s surface, skipping vidmem SetSurfaceDesc test.\n", + invalid_caps_tests[i].name); + goto done; + } + + reset_ddsd(&ddsd); + ddsd.dwFlags = DDSD_LPSURFACE; + ddsd.lpSurface = data; + hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0); + if (invalid_caps_tests[i].supported) + { + ok(SUCCEEDED(hr), "Failed to set surface desc, hr %#x.\n", hr); + } + else + { + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + + /* Check priority of error conditions. */ + ddsd.dwFlags = DDSD_WIDTH; + hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0); + ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a %s surface returned %#x.\n", + invalid_caps_tests[i].name, hr); + } + + IDirectDrawSurface7_Release(surface); } - reset_ddsd(&ddsd); - ddsd.dwFlags = DDSD_LPSURFACE; - ddsd.lpSurface = data; - hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - /* Check priority of error conditions. */ - ddsd.dwFlags = DDSD_WIDTH; - hr = IDirectDrawSurface7_SetSurfaceDesc(surface, &ddsd, 0); - ok(hr == DDERR_INVALIDSURFACETYPE, "SetSurfaceDesc on a vidmem surface returned %#x.\n", hr); - - IDirectDrawSurface7_Release(surface); - done: ref = IDirectDraw7_Release(ddraw); ok(ref == 0, "Ddraw object not properly released, refcount %u.\n", ref);