From 51332b7a032a6f17dcec9252eefdbd821ca62585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= Date: Thu, 2 Sep 2010 22:00:35 +0200 Subject: [PATCH] ddraw/tests: New tests for CreateSurface for 3D DDSCAPS_BACKBUFFER. --- dlls/ddraw/tests/d3d.c | 93 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/dlls/ddraw/tests/d3d.c b/dlls/ddraw/tests/d3d.c index 2f0f3c4f17b..3427563b5ef 100644 --- a/dlls/ddraw/tests/d3d.c +++ b/dlls/ddraw/tests/d3d.c @@ -3526,6 +3526,98 @@ static void FindDevice(void) "Expected IDirect3D1::FindDevice to return D3D_OK, got 0x%08x\n", hr); } +static void BackBuffer3DCreateSurfaceTest(void) +{ + DDSURFACEDESC ddsd; + DDSURFACEDESC created_ddsd; + DDSURFACEDESC2 ddsd2; + IDirectDrawSurface *surf; + IDirectDrawSurface4 *surf4; + IDirectDrawSurface7 *surf7; + HRESULT hr; + IDirectDraw2 *dd2; + IDirectDraw4 *dd4; + IDirectDraw7 *dd7; + DDCAPS ddcaps; + IDirect3DDevice *d3dhal; + + const DWORD caps = DDSCAPS_BACKBUFFER | DDSCAPS_3DDEVICE; + const DWORD expected_caps = DDSCAPS_BACKBUFFER | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM; + + memset(&ddcaps, 0, sizeof(ddcaps)); + ddcaps.dwSize = sizeof(DDCAPS); + hr = IDirectDraw_GetCaps(DirectDraw1, &ddcaps, NULL); + if (!(ddcaps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)) + { + skip("DDraw reported no VIDEOMEMORY cap. Broken video driver? Skipping surface caps tests.\n"); + return ; + } + + memset(&ddsd, 0, sizeof(ddsd)); + ddsd.dwSize = sizeof(ddsd); + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd.dwWidth = 64; + ddsd.dwHeight = 64; + ddsd.ddsCaps.dwCaps = caps; + memset(&ddsd2, 0, sizeof(ddsd2)); + ddsd2.dwSize = sizeof(ddsd2); + ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; + ddsd2.dwWidth = 64; + ddsd2.dwHeight = 64; + ddsd2.ddsCaps.dwCaps = caps; + memset(&created_ddsd, 0, sizeof(created_ddsd)); + created_ddsd.dwSize = sizeof(DDSURFACEDESC); + + hr = IDirectDraw_CreateSurface(DirectDraw1, &ddsd, &surf, NULL); + todo_wine ok(SUCCEEDED(hr), "IDirectDraw_CreateSurface failed: 0x%08x\n", hr); + if (surf != NULL) + { + hr = IDirectDrawSurface_GetSurfaceDesc(surf, &created_ddsd); + ok(SUCCEEDED(hr), "IDirectDraw_GetSurfaceDesc failed: 0x%08x\n", hr); + todo_wine ok(created_ddsd.ddsCaps.dwCaps == expected_caps, + "GetSurfaceDesc returned caps %x, expected %x\n", created_ddsd.ddsCaps.dwCaps, + expected_caps); + + hr = IDirectDrawSurface_QueryInterface(surf, &IID_IDirect3DHALDevice, (void **)&d3dhal); + /* Currently Wine only supports the creation of one Direct3D device + for a given DirectDraw instance. It has been created already + in D3D1_createObjects() - IID_IDirect3DRGBDevice */ + todo_wine ok(SUCCEEDED(hr), "Expected IDirectDrawSurface::QueryInterface to succeed, got 0x%08x\n", hr); + + if (SUCCEEDED(hr)) + IDirect3DDevice_Release(d3dhal); + + IDirectDrawSurface_Release(surf); + } + + hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw2, (void **) &dd2); + ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr); + + hr = IDirectDraw2_CreateSurface(dd2, &ddsd, &surf, NULL); + ok(hr == DDERR_INVALIDCAPS, "IDirectDraw2_CreateSurface didn't return %x08x, but %x08x\n", + DDERR_INVALIDCAPS, hr); + + IDirectDraw2_Release(dd2); + + hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw4, (void **) &dd4); + ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr); + + hr = IDirectDraw4_CreateSurface(dd4, &ddsd2, &surf4, NULL); + ok(hr == DDERR_INVALIDCAPS, "IDirectDraw4_CreateSurface didn't return %x08x, but %x08x\n", + DDERR_INVALIDCAPS, hr); + + IDirectDraw4_Release(dd4); + + hr = IDirectDraw_QueryInterface(DirectDraw1, &IID_IDirectDraw7, (void **) &dd7); + ok(SUCCEEDED(hr), "IDirectDraw_QueryInterface failed: 0x%08x\n", hr); + + hr = IDirectDraw7_CreateSurface(dd7, &ddsd2, &surf7, NULL); + ok(hr == DDERR_INVALIDCAPS, "IDirectDraw7_CreateSurface didn't return %x08x, but %x08x\n", + DDERR_INVALIDCAPS, hr); + + IDirectDraw7_Release(dd7); +} + START_TEST(d3d) { init_function_pointers(); @@ -3561,6 +3653,7 @@ START_TEST(d3d) TextureLoadTest(); ViewportTest(); FindDevice(); + BackBuffer3DCreateSurfaceTest(); D3D1_releaseObjects(); }