Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
v2:
- fix test failures on Testbot.
dlls/ddraw/tests/ddraw7.c | 313 ++++++++++++++++++++++----------------
1 file changed, 181 insertions(+), 132 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 628360630dc..89bdb9dffd4 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -6087,14 +6087,14 @@ static void test_unsupported_formats(void)
static void test_rt_caps(void)
{
- const GUID *devtype = &IID_IDirect3DHALDevice;
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
+ unsigned int i, device_type;
+ DWORD expected_caps;
IDirectDraw7 *ddraw;
BOOL hal_ok = FALSE;
DDPIXELFORMAT z_fmt;
IDirect3D7 *d3d;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -6105,11 +6105,17 @@ static void test_rt_caps(void)
{8}, {0x00000000}, {0x00000000}, {0x00000000}, {0x00000000},
};
+ static const GUID *test_devices[] =
+ {
+ &IID_IDirect3DHALDevice,
+ &IID_IDirect3DRGBDevice,
+ };
+
const struct
{
const DDPIXELFORMAT *pf;
DWORD caps_in;
- DWORD caps_out;
+ DWORD caps_out[ARRAY_SIZE(test_devices)];
DWORD caps2_in;
DWORD caps2_out;
HRESULT create_device_hr;
@@ -6120,27 +6126,29 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,},
0,
0,
- D3D_OK,
- D3D_OK,
- D3D_OK,
+ DD_OK,
+ DD_OK,
+ DD_OK,
},
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
0,
0,
- D3D_OK,
- D3D_OK,
- D3D_OK,
+ DD_OK,
+ DD_OK,
+ DD_OK,
},
{
NULL,
DDSCAPS_OFFSCREENPLAIN,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6150,17 +6158,17 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
0,
0,
D3DERR_SURFACENOTINVIDMEM,
DDERR_INVALIDPARAMS,
- D3D_OK,
+ DD_OK,
},
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6170,27 +6178,28 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
- D3D_OK,
- D3D_OK,
- D3D_OK,
+ DD_OK,
+ DD_OK,
+ DD_OK,
},
{
NULL,
DDSCAPS_3DDEVICE,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
0,
0,
- D3D_OK,
- D3D_OK,
- D3D_OK,
+ DD_OK,
+ DD_OK,
+ DD_OK,
},
{
NULL,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM, DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6200,7 +6209,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
- DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
+ {DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
0,
0,
D3DERR_SURFACENOTINVIDMEM,
@@ -6210,7 +6219,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6220,7 +6229,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE,
- DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
DDSCAPS2_TEXTUREMANAGE,
DDSCAPS2_TEXTUREMANAGE,
D3DERR_SURFACENOTINVIDMEM,
@@ -6230,7 +6239,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE,
- DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_TEXTURE | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
DDSCAPS2_D3DTEXTUREMANAGE,
DDSCAPS2_D3DTEXTUREMANAGE,
D3DERR_SURFACENOTINVIDMEM,
@@ -6240,7 +6249,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6250,7 +6259,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE,
- ~0U /* AMD r200 */,
+ {~0u /* AMD r200 */, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_NOPALETTEATTACHED,
@@ -6260,7 +6269,8 @@ static void test_rt_caps(void)
{
&p8_fmt,
DDSCAPS_OFFSCREENPLAIN,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6270,7 +6280,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
0,
0,
DDERR_NOPALETTEATTACHED,
@@ -6280,7 +6290,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6290,7 +6300,7 @@ static void test_rt_caps(void)
{
&z_fmt,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6300,7 +6310,8 @@ static void test_rt_caps(void)
{
&z_fmt,
DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER},
0,
0,
DDERR_INVALIDCAPS,
@@ -6310,7 +6321,8 @@ static void test_rt_caps(void)
{
&z_fmt,
DDSCAPS_ZBUFFER,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER},
0,
0,
DDERR_INVALIDCAPS,
@@ -6320,7 +6332,7 @@ static void test_rt_caps(void)
{
&z_fmt,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER,
- DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER,
+ {DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER},
0,
0,
DDERR_INVALIDCAPS,
@@ -6330,7 +6342,7 @@ static void test_rt_caps(void)
{
&z_fmt,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER,
- DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER,
+ {DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER},
0,
0,
DDERR_INVALIDCAPS,
@@ -6352,124 +6364,161 @@ static void test_rt_caps(void)
}
hr = IDirect3D7_EnumDevices(d3d, enum_devtype_cb, &hal_ok);
- ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
if (hal_ok)
- devtype = &IID_IDirect3DTnLHalDevice;
-
- memset(&z_fmt, 0, sizeof(z_fmt));
- hr = IDirect3D7_EnumZBufferFormats(d3d, devtype, enum_z_fmt, &z_fmt);
- if (FAILED(hr) || !z_fmt.dwSize)
- {
- skip("No depth buffer formats available, skipping test.\n");
- IDirect3D7_Release(d3d);
- goto done;
- }
+ test_devices[0] = &IID_IDirect3DTnLHalDevice;
memset(palette_entries, 0, sizeof(palette_entries));
hr = IDirectDraw7_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
- ok(SUCCEEDED(hr), "Failed to create palette, hr %#x.\n", hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
- for (i = 0; i < ARRAY_SIZE(test_data); ++i)
+ for (device_type = 0; device_type < ARRAY_SIZE(test_devices); ++device_type)
{
- IDirectDrawSurface7 *surface, *rt, *expected_rt, *tmp;
- DDSURFACEDESC2 surface_desc;
- IDirect3DDevice7 *device;
-
- 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 = test_data[i].caps_in;
- surface_desc.ddsCaps.dwCaps2 = test_data[i].caps2_in;
- if (test_data[i].pf)
+ memset(&z_fmt, 0, sizeof(z_fmt));
+ hr = IDirect3D7_EnumZBufferFormats(d3d, test_devices[device_type], enum_z_fmt, &z_fmt);
+ if (FAILED(hr) || !z_fmt.dwSize)
{
- surface_desc.dwFlags |= DDSD_PIXELFORMAT;
- U4(surface_desc).ddpfPixelFormat = *test_data[i].pf;
+ skip("No depth buffer formats available, device_type %u, skipping test.\n", device_type);
+ continue;
}
- surface_desc.dwWidth = 640;
- surface_desc.dwHeight = 480;
- hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create surface with caps %#x and caps2 %#x, hr %#x.\n",
- i, test_data[i].caps_in, test_data[i].caps2_in, hr);
-
- 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(test_data[i].caps_out == ~0U || surface_desc.ddsCaps.dwCaps == test_data[i].caps_out,
- "Test %u: Got unexpected caps %#x, expected %#x.\n",
- i, surface_desc.ddsCaps.dwCaps, test_data[i].caps_out);
- ok(surface_desc.ddsCaps.dwCaps2 == test_data[i].caps2_out,
- "Test %u: Got unexpected caps2 %#x, expected %#x.\n",
- i, surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_out);
- hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
- ok(hr == test_data[i].create_device_hr, "Test %u: Got unexpected hr %#x, expected %#x.\n",
- i, hr, test_data[i].create_device_hr);
- if (FAILED(hr))
+ for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
- if (hr == DDERR_NOPALETTEATTACHED)
- {
- hr = IDirectDrawSurface7_SetPalette(surface, palette);
- ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr);
- hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
- if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
- ok(hr == DDERR_INVALIDPIXELFORMAT, "Test %u: Got unexpected hr %#x.\n", i, hr);
- else
- ok(hr == D3DERR_SURFACENOTINVIDMEM, "Test %u: Got unexpected hr %#x.\n", i, hr);
- }
- IDirectDrawSurface7_Release(surface);
+ IDirectDrawSurface7 *surface, *rt, *expected_rt, *tmp;
+ DDSURFACEDESC2 surface_desc;
+ IDirect3DDevice7 *device;
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_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
+ surface_desc.ddsCaps.dwCaps = test_data[i].caps_in;
+ surface_desc.ddsCaps.dwCaps2 = test_data[i].caps2_in;
+ if (test_data[i].pf)
+ {
+ surface_desc.dwFlags |= DDSD_PIXELFORMAT;
+ U4(surface_desc).ddpfPixelFormat = *test_data[i].pf;
+ }
surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create surface, hr %#x.\n", i, hr);
+ if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW)
+ {
+ skip("No 3d hardwate, skipping test %u, device_type %u.\n", i, device_type);
+ continue;
+ }
+ ok(hr == DD_OK || (device_type && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
+ == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == DDERR_UNSUPPORTED)
+ || broken(device_type && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT),
+ "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ if (FAILED(hr))
+ continue;
- hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
- ok(SUCCEEDED(hr), "Test %u: Failed to create device, hr %#x.\n", i, hr);
- }
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface7_GetSurfaceDesc(surface, &surface_desc);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
- 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 = test_data[i].caps_in;
- surface_desc.ddsCaps.dwCaps2 = test_data[i].caps2_in;
- if (test_data[i].pf)
- {
- surface_desc.dwFlags |= DDSD_PIXELFORMAT;
- U4(surface_desc).ddpfPixelFormat = *test_data[i].pf;
- }
- surface_desc.dwWidth = 640;
- surface_desc.dwHeight = 480;
- hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create surface with caps %#x, hr %#x.\n",
- i, test_data[i].caps_in, hr);
+ if (device_type)
+ {
+ expected_caps = test_data[i].caps_out[device_type]
+ ? test_data[i].caps_out[device_type] : test_data[i].caps_out[0];
+
+ todo_wine_if(test_data[i].caps_out[device_type]
+ && surface_desc.ddsCaps.dwCaps == test_data[i].caps_out[0])
+ ok(surface_desc.ddsCaps.dwCaps == expected_caps
+ || broken(surface_desc.ddsCaps.dwCaps == test_data[i].caps_out[0]),
+ "Got unexpected caps %#x, test %u, device_type %u.\n",
+ surface_desc.ddsCaps.dwCaps, i, device_type);
+ }
+ else
+ {
+ ok(test_data[i].caps_out[0] == ~0u || surface_desc.ddsCaps.dwCaps == test_data[i].caps_out[0],
+ "Got unexpected caps %#x, expected %#x, test %u, device_type %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out[0], i, device_type);
+ }
+ ok(surface_desc.ddsCaps.dwCaps2 == test_data[i].caps2_out,
+ "Got unexpected caps2 %#x, expected %#x, test %u, device_type %u.\n",
+ surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_out, i, device_type);
+
+ hr = IDirect3D7_CreateDevice(d3d, test_devices[device_type], surface, &device);
+ todo_wine_if(device_type && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
+ ok((!device_type && hr == test_data[i].create_device_hr)
+ || (device_type && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
+ ? DD_OK : test_data[i].create_device_hr))),
+ "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ if (FAILED(hr))
+ {
+ if (hr == DDERR_NOPALETTEATTACHED)
+ {
+ hr = IDirectDrawSurface7_SetPalette(surface, palette);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ hr = IDirect3D7_CreateDevice(d3d, test_devices[device_type], surface, &device);
+ if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
+ ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+ else if (device_type)
+ todo_wine
+ ok(hr == E_FAIL, "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+ else
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+ }
+ IDirectDrawSurface7_Release(surface);
- hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
- ok(hr == test_data[i].set_rt_hr || broken(hr == test_data[i].alternative_set_rt_hr),
- "Test %u: Got unexpected hr %#x, expected %#x.\n",
- i, hr, test_data[i].set_rt_hr);
- if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
- expected_rt = rt;
- else
- expected_rt = surface;
+ 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_OFFSCREENPLAIN | DDSCAPS_3DDEVICE;
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+
+ hr = IDirect3D7_CreateDevice(d3d, test_devices[device_type], surface, &device);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ }
- hr = IDirect3DDevice7_GetRenderTarget(device, &tmp);
- ok(SUCCEEDED(hr), "Test %u: Failed to get render target, hr %#x.\n", i, hr);
- ok(tmp == expected_rt, "Test %u: Got unexpected rt %p.\n", i, tmp);
+ 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 = test_data[i].caps_in;
+ surface_desc.ddsCaps.dwCaps2 = test_data[i].caps2_in;
+ if (test_data[i].pf)
+ {
+ surface_desc.dwFlags |= DDSD_PIXELFORMAT;
+ U4(surface_desc).ddpfPixelFormat = *test_data[i].pf;
+ }
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &rt, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
- IDirectDrawSurface7_Release(tmp);
- IDirectDrawSurface7_Release(rt);
- refcount = IDirect3DDevice7_Release(device);
- ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
- refcount = IDirectDrawSurface7_Release(surface);
- ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+ hr = IDirect3DDevice7_SetRenderTarget(device, rt, 0);
+ ok(hr == test_data[i].set_rt_hr || (device_type && hr == DDERR_NOPALETTEATTACHED)
+ || broken(hr == test_data[i].alternative_set_rt_hr),
+ "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+ if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
+ expected_rt = rt;
+ else
+ expected_rt = surface;
+
+ hr = IDirect3DDevice7_GetRenderTarget(device, &tmp);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ ok(tmp == expected_rt, "Got unexpected rt %p, test %u, device_type %u.\n", tmp, i, device_type);
+
+ IDirectDrawSurface7_Release(tmp);
+ IDirectDrawSurface7_Release(rt);
+ refcount = IDirect3DDevice7_Release(device);
+ ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+ refcount = IDirectDrawSurface7_Release(surface);
+ ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+ }
}
- IDirectDrawPalette_Release(palette);
+ refcount = IDirectDrawPalette_Release(palette);
+ ok(!refcount, "Got unexpected refcount %u.\n", refcount);
IDirect3D7_Release(d3d);
done:
--
2.29.2