[PATCH 1/4] ddraw/tests: Also test RT caps for software device for ddraw1.
Paul Gofman
pgofman at codeweavers.com
Tue Feb 16 03:14:42 CST 2021
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/ddraw/tests/ddraw1.c | 136 +++++++++++++++++++++-----------------
1 file changed, 77 insertions(+), 59 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index d3e9fe0e1ff..77513d92a94 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -4320,10 +4320,10 @@ static void test_rt_caps(void)
{
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
+ unsigned int i, device_type;
IDirect3DDevice *device;
IDirectDraw *ddraw;
DWORD z_depth = 0;
- unsigned int i;
ULONG refcount;
HWND window;
HRESULT hr;
@@ -4334,6 +4334,12 @@ static void test_rt_caps(void)
{8}, {0x00000000}, {0x00000000}, {0x00000000}, {0x00000000},
};
+ static const REFCLSID test_devices[] =
+ {
+ &IID_IDirect3DHALDevice,
+ &IID_IDirect3DRGBDevice,
+ };
+
static const struct
{
const DDPIXELFORMAT *pf;
@@ -4348,14 +4354,14 @@ static void test_rt_caps(void)
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
- D3D_OK,
+ DD_OK,
FALSE,
},
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
- D3D_OK,
+ DD_OK,
FALSE,
},
{
@@ -4383,14 +4389,14 @@ static void test_rt_caps(void)
NULL,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
- D3D_OK,
+ DD_OK,
FALSE,
},
{
NULL,
DDSCAPS_3DDEVICE,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
- D3D_OK,
+ DD_OK,
FALSE,
},
{
@@ -4502,66 +4508,78 @@ static void test_rt_caps(void)
memset(palette_entries, 0, sizeof(palette_entries));
hr = IDirectDraw_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;
- DDSURFACEDESC surface_desc;
- IDirect3DDevice *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 = IDirectDraw_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;
+ DDSURFACEDESC surface_desc;
+ IDirect3DDevice *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 = IDirectDraw_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);
- hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&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 (hr == DDERR_NOPALETTEATTACHED)
- {
- hr = IDirectDrawSurface_SetPalette(surface, palette);
- ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr);
- hr = IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&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 (SUCCEEDED(hr))
- {
- refcount = IDirect3DDevice_Release(device);
- ok(refcount == 1, "Test %u: Got unexpected refcount %u.\n", i, refcount);
- }
+ if (FAILED(hr))
+ continue;
- refcount = IDirectDrawSurface_Release(surface);
- ok(refcount == 0, "Test %u: The surface was not properly freed, refcount %u.\n", i, refcount);
+ 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 = IDirectDrawSurface_QueryInterface(surface, test_devices[device_type], (void **)&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 (hr == DDERR_NOPALETTEATTACHED)
+ {
+ hr = IDirectDrawSurface_SetPalette(surface, palette);
+ ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr);
+ hr = IDirectDrawSurface_QueryInterface(surface, test_devices[device_type], (void **)&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 (SUCCEEDED(hr))
+ {
+ refcount = IDirect3DDevice_Release(device);
+ ok(refcount == 1, "Test %u: Got unexpected 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