[PATCH 2/4] ddraw/tests: Also test RT caps for software device for ddraw2.
Paul Gofman
pgofman at codeweavers.com
Tue Feb 16 03:14:43 CST 2021
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/ddraw/tests/ddraw2.c | 224 +++++++++++++++++++++-----------------
1 file changed, 125 insertions(+), 99 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index bc915c97864..e61bb460220 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -4743,15 +4743,21 @@ static void test_rt_caps(void)
{
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
+ unsigned int i, device_type;
IDirect3DDevice2 *device;
IDirectDraw2 *ddraw;
DWORD z_depth = 0;
IDirect3D2 *d3d;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
+ static const REFCLSID test_devices[] =
+ {
+ &IID_IDirect3DHALDevice,
+ &IID_IDirect3DRGBDevice,
+ };
+
static const DDPIXELFORMAT p8_fmt =
{
sizeof(DDPIXELFORMAT), DDPF_PALETTEINDEXED8 | DDPF_RGB, 0,
@@ -4974,122 +4980,142 @@ static void test_rt_caps(void)
memset(palette_entries, 0, sizeof(palette_entries));
hr = IDirectDraw2_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)
{
- IDirectDrawSurface *surface, *rt, *expected_rt, *tmp;
- DDSURFACEDESC surface_desc;
- IDirect3DDevice2 *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;
- if (test_data[i].pf)
- {
- surface_desc.dwFlags |= DDSD_PIXELFORMAT;
- surface_desc.ddpfPixelFormat = *test_data[i].pf;
- }
- if (test_data[i].caps_in & DDSCAPS_ZBUFFER)
+ for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{
- surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
- U2(surface_desc).dwZBufferBitDepth = z_depth;
- }
- surface_desc.dwWidth = 640;
- surface_desc.dwHeight = 480;
- hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr) || broken(test_data[i].create_may_fail),
- "Test %u: Failed to create surface with caps %#x, hr %#x.\n",
- i, test_data[i].caps_in, hr);
- if (FAILED(hr))
- continue;
+ IDirectDrawSurface *surface, *rt, *expected_rt, *tmp;
+ DDSURFACEDESC surface_desc;
+ IDirect3DDevice2 *device;
- 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(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);
+ 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;
+ if (test_data[i].pf)
+ {
+ surface_desc.dwFlags |= DDSD_PIXELFORMAT;
+ surface_desc.ddpfPixelFormat = *test_data[i].pf;
+ }
+ if (test_data[i].caps_in & DDSCAPS_ZBUFFER)
+ {
+ surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
+ U2(surface_desc).dwZBufferBitDepth = z_depth;
+ }
+ surface_desc.dwWidth = 640;
+ surface_desc.dwHeight = 480;
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
+ ok(hr == DD_OK || broken(test_data[i].create_may_fail),
+ "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ if (FAILED(hr))
+ continue;
- hr = IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, 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))
- {
- if (hr == DDERR_NOPALETTEATTACHED)
+ memset(&surface_desc, 0, sizeof(surface_desc));
+ surface_desc.dwSize = sizeof(surface_desc);
+ hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ ok(test_data[i].caps_out == ~0u || surface_desc.ddsCaps.dwCaps == test_data[i].caps_out,
+ "Got unexpected caps %#x, expected %#x, test %u, device_type %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out, i, device_type);
+
+ hr = IDirect3D2_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))
{
- hr = IDirectDrawSurface_SetPalette(surface, palette);
- ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr);
- hr = IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, 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);
+ if (hr == DDERR_NOPALETTEATTACHED)
+ {
+ hr = IDirectDrawSurface_SetPalette(surface, palette);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type);
+ hr = IDirect3D2_CreateDevice(d3d, test_devices[device_type], surface, &device);
+ if (device_type == 1)
+ todo_wine
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+ else 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
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, device_type %u.\n",
+ hr, i, device_type);
+
+ if (hr == DD_OK)
+ {
+ refcount = IDirect3DDevice2_Release(device);
+ ok(!refcount, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+ }
+ }
+ IDirectDrawSurface_Release(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 = IDirectDraw2_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 = IDirect3D2_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);
}
- IDirectDrawSurface_Release(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.ddsCaps.dwCaps = test_data[i].caps_in;
+ if (test_data[i].pf)
+ {
+ surface_desc.dwFlags |= DDSD_PIXELFORMAT;
+ surface_desc.ddpfPixelFormat = *test_data[i].pf;
+ }
+ if (test_data[i].caps_in & DDSCAPS_ZBUFFER)
+ {
+ surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
+ U2(surface_desc).dwZBufferBitDepth = z_depth;
+ }
surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480;
- hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create surface, hr %#x.\n", i, hr);
-
- hr = IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device);
- ok(SUCCEEDED(hr), "Test %u: Failed to create device, hr %#x.\n", i, hr);
- }
+ hr = IDirectDraw2_CreateSurface(ddraw, &surface_desc, &rt, NULL);
+ 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;
- if (test_data[i].pf)
- {
- surface_desc.dwFlags |= DDSD_PIXELFORMAT;
- surface_desc.ddpfPixelFormat = *test_data[i].pf;
- }
- if (test_data[i].caps_in & DDSCAPS_ZBUFFER)
- {
- surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
- U2(surface_desc).dwZBufferBitDepth = z_depth;
- }
- surface_desc.dwWidth = 640;
- surface_desc.dwHeight = 480;
- hr = IDirectDraw2_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);
+ hr = IDirect3DDevice2_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);
- hr = IDirect3DDevice2_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;
+ if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
+ expected_rt = rt;
+ else
+ expected_rt = surface;
- /* It appears the surface is set as render target in this case, but no
- * reference is taken. */
- if (hr == DDERR_INVALIDPIXELFORMAT)
- {
- refcount = IDirectDrawSurface_AddRef(rt);
- ok(refcount == 2, "Test %u: Got unexpected refcount %u.\n", i, refcount);
- }
+ /* It appears the surface is set as render target in this case, but no
+ * reference is taken. */
+ if (hr == DDERR_INVALIDPIXELFORMAT)
+ {
+ refcount = IDirectDrawSurface_AddRef(rt);
+ ok(refcount == 2, "Test %u: Got unexpected refcount %u.\n", i, refcount);
+ }
- hr = IDirect3DDevice2_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);
+ hr = IDirect3DDevice2_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);
- IDirectDrawSurface_Release(tmp);
- IDirectDrawSurface_Release(rt);
- refcount = IDirect3DDevice2_Release(device);
- ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
- refcount = IDirectDrawSurface_Release(surface);
- ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+ IDirectDrawSurface_Release(tmp);
+ IDirectDrawSurface_Release(rt);
+ refcount = IDirect3DDevice2_Release(device);
+ ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount);
+ refcount = IDirectDrawSurface_Release(surface);
+ ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+ }
}
IDirectDrawPalette_Release(palette);
--
2.29.2
More information about the wine-devel
mailing list