Commit b5a531d9 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

ddraw/tests: Compute output caps instead of coding them in test_rt_caps().

parent fb6b5ce7
...@@ -4332,9 +4332,9 @@ static void test_rt_caps(const GUID *device_guid) ...@@ -4332,9 +4332,9 @@ static void test_rt_caps(const GUID *device_guid)
IDirectDrawPalette *palette; IDirectDrawPalette *palette;
IDirect3DDevice *device; IDirect3DDevice *device;
BOOL software_device; BOOL software_device;
DWORD expected_caps;
IDirectDraw *ddraw; IDirectDraw *ddraw;
DWORD z_depth = 0; DWORD z_depth = 0;
DDCAPS hal_caps;
unsigned int i; unsigned int i;
ULONG refcount; ULONG refcount;
HWND window; HWND window;
...@@ -4350,7 +4350,6 @@ static void test_rt_caps(const GUID *device_guid) ...@@ -4350,7 +4350,6 @@ static void test_rt_caps(const GUID *device_guid)
{ {
const DDPIXELFORMAT *pf; const DDPIXELFORMAT *pf;
DWORD caps_in; DWORD caps_in;
DWORD caps_out[2];
HRESULT create_device_hr; HRESULT create_device_hr;
BOOL create_may_fail; BOOL create_may_fail;
} }
...@@ -4359,144 +4358,120 @@ static void test_rt_caps(const GUID *device_guid) ...@@ -4359,144 +4358,120 @@ static void test_rt_caps(const GUID *device_guid)
{ {
NULL, NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
D3D_OK, D3D_OK,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
D3D_OK, D3D_OK,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_OFFSCREENPLAIN, DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
D3DERR_SURFACENOTINVIDMEM, D3DERR_SURFACENOTINVIDMEM,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY, DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY,
{DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
D3D_OK, D3D_OK,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_3DDEVICE, DDSCAPS_3DDEVICE,
{DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
D3D_OK, D3D_OK,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
0, 0,
{DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM, DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE, DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
D3DERR_SURFACENOTINVIDMEM, D3DERR_SURFACENOTINVIDMEM,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_SYSTEMMEMORY, DDSCAPS_SYSTEMMEMORY,
{DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
&p8_fmt, &p8_fmt,
0, 0,
{DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
&p8_fmt, &p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE,
{~0u /* AMD r200 */, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
DDERR_NOPALETTEATTACHED, DDERR_NOPALETTEATTACHED,
FALSE, FALSE,
}, },
{ {
&p8_fmt, &p8_fmt,
DDSCAPS_OFFSCREENPLAIN, DDSCAPS_OFFSCREENPLAIN,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
&p8_fmt, &p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
DDERR_NOPALETTEATTACHED, DDERR_NOPALETTEATTACHED,
FALSE, FALSE,
}, },
{ {
&p8_fmt, &p8_fmt,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
{DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER, DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER,
{DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER | DDSCAPS_LOCALVIDMEM},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
TRUE /* AMD Evergreen */, TRUE /* AMD Evergreen */,
}, },
{ {
NULL, NULL,
DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER, DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER,
{~0u /* AMD Evergreen */, DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_ZBUFFER, DDSCAPS_ZBUFFER,
{~0u /* AMD Evergreen */, DDSCAPS_ZBUFFER | DDSCAPS_SYSTEMMEMORY},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
FALSE, FALSE,
}, },
{ {
NULL, NULL,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER, DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER,
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE | DDSCAPS_ZBUFFER},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
TRUE /* Nvidia Kepler */, TRUE /* Nvidia Kepler */,
}, },
{ {
NULL, NULL,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER, DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER,
{DDSCAPS_SYSTEMMEMORY | DDSCAPS_ZBUFFER},
DDERR_INVALIDCAPS, DDERR_INVALIDCAPS,
TRUE /* Nvidia Kepler */, TRUE /* Nvidia Kepler */,
}, },
...@@ -4522,38 +4497,45 @@ static void test_rt_caps(const GUID *device_guid) ...@@ -4522,38 +4497,45 @@ static void test_rt_caps(const GUID *device_guid)
hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL); hr = IDirectDraw_CreatePalette(ddraw, DDPCAPS_ALLOW256 | DDPCAPS_8BIT, palette_entries, &palette, NULL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr); ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
memset(&hal_caps, 0, sizeof(hal_caps));
hal_caps.dwSize = sizeof(hal_caps);
hr = IDirectDraw_GetCaps(ddraw, &hal_caps, NULL);
ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(test_data); ++i) for (i = 0; i < ARRAY_SIZE(test_data); ++i)
{ {
DWORD caps_in, expected_caps;
IDirectDrawSurface *surface; IDirectDrawSurface *surface;
DDSURFACEDESC surface_desc; DDSURFACEDESC surface_desc;
IDirect3DDevice *device; IDirect3DDevice *device;
HRESULT expected_hr;
caps_in = test_data[i].caps_in;
memset(&surface_desc, 0, sizeof(surface_desc)); memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwSize = sizeof(surface_desc);
surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; surface_desc.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
surface_desc.ddsCaps.dwCaps = test_data[i].caps_in; surface_desc.ddsCaps.dwCaps = caps_in;
if (test_data[i].pf) if (test_data[i].pf)
{ {
surface_desc.dwFlags |= DDSD_PIXELFORMAT; surface_desc.dwFlags |= DDSD_PIXELFORMAT;
surface_desc.ddpfPixelFormat = *test_data[i].pf; surface_desc.ddpfPixelFormat = *test_data[i].pf;
} }
if (test_data[i].caps_in & DDSCAPS_ZBUFFER) if (caps_in & DDSCAPS_ZBUFFER)
{ {
surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH; surface_desc.dwFlags |= DDSD_ZBUFFERBITDEPTH;
U2(surface_desc).dwZBufferBitDepth = z_depth; U2(surface_desc).dwZBufferBitDepth = z_depth;
} }
surface_desc.dwWidth = 640; surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480; surface_desc.dwHeight = 480;
if ((caps_in & DDSCAPS_VIDEOMEMORY) && !(hal_caps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
expected_hr = DDERR_NODIRECTDRAWHW;
else
expected_hr = DD_OK;
hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL); hr = IDirectDraw_CreateSurface(ddraw, &surface_desc, &surface, NULL);
if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW) ok(hr == expected_hr || broken(test_data[i].create_may_fail
{
skip("No 3d hardware, skipping test %u, software_device %u.\n", i, software_device);
continue;
}
ok(hr == DD_OK || broken(test_data[i].create_may_fail
|| (software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT)), || (software_device && test_data[i].pf == &p8_fmt && hr == DDERR_INVALIDPIXELFORMAT)),
"Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device); "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
if (FAILED(hr)) if (FAILED(hr))
continue; continue;
...@@ -4561,23 +4543,18 @@ static void test_rt_caps(const GUID *device_guid) ...@@ -4561,23 +4543,18 @@ static void test_rt_caps(const GUID *device_guid)
surface_desc.dwSize = sizeof(surface_desc); surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc); hr = IDirectDrawSurface_GetSurfaceDesc(surface, &surface_desc);
ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device); ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
if (software_device)
{ if ((caps_in & DDSCAPS_SYSTEMMEMORY) || !(hal_caps.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY))
expected_caps = test_data[i].caps_out[1] expected_caps = caps_in | DDSCAPS_SYSTEMMEMORY;
? test_data[i].caps_out[1] : test_data[i].caps_out[0];
todo_wine_if(test_data[i].caps_out[0] == ~0u && surface_desc.ddsCaps.dwCaps != expected_caps)
ok(surface_desc.ddsCaps.dwCaps == expected_caps
|| surface_desc.ddsCaps.dwCaps == test_data[i].caps_out[0],
"Got unexpected caps %#x, test %u, software_device %u.\n",
surface_desc.ddsCaps.dwCaps, i, software_device);
}
else else
{ expected_caps = caps_in | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM;
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, software_device %u.\n", ok(surface_desc.ddsCaps.dwCaps == expected_caps || (test_data[i].pf == &p8_fmt
surface_desc.ddsCaps.dwCaps, test_data[i].caps_out[0], i, software_device); && surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY))
} || (software_device && caps_in & DDSCAPS_ZBUFFER
&& surface_desc.ddsCaps.dwCaps == (caps_in | DDSCAPS_SYSTEMMEMORY)),
"Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
surface_desc.ddsCaps.dwCaps, expected_caps, i, software_device);
hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device); hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device);
todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM) todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment