Signed-off-by: Paul Gofman pgofman@codeweavers.com --- v2: - fix test failures on Testbot.
dlls/ddraw/tests/ddraw4.c | 310 ++++++++++++++++++++++---------------- 1 file changed, 183 insertions(+), 127 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index f009b4583f4..b25ac7f365a 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -6359,10 +6359,11 @@ static void test_rt_caps(void) { PALETTEENTRY palette_entries[256]; IDirectDrawPalette *palette; + unsigned int i, device_type; + DWORD expected_caps; IDirectDraw4 *ddraw; DDPIXELFORMAT z_fmt; IDirect3D3 *d3d; - unsigned int i; ULONG refcount; HWND window; HRESULT hr; @@ -6373,11 +6374,17 @@ static void test_rt_caps(void) {8}, {0x00000000}, {0x00000000}, {0x00000000}, {0x00000000}, };
+ static const REFCLSID 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; @@ -6388,27 +6395,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, + DD_OK, D3D_OK, D3D_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, @@ -6418,7 +6427,7 @@ 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, @@ -6428,7 +6437,7 @@ static void test_rt_caps(void) { NULL, DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, - DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY, + {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY}, 0, 0, DDERR_INVALIDCAPS, @@ -6438,27 +6447,29 @@ 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, @@ -6468,7 +6479,7 @@ static void test_rt_caps(void) { NULL, DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE, - DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE, + {DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE}, 0, 0, D3DERR_SURFACENOTINVIDMEM, @@ -6478,7 +6489,7 @@ static void test_rt_caps(void) { NULL, DDSCAPS_SYSTEMMEMORY, - DDSCAPS_SYSTEMMEMORY, + {DDSCAPS_SYSTEMMEMORY}, 0, 0, DDERR_INVALIDCAPS, @@ -6488,7 +6499,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, @@ -6498,7 +6509,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, @@ -6508,7 +6519,7 @@ static void test_rt_caps(void) { &p8_fmt, 0, - DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM, + {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM}, 0, 0, DDERR_INVALIDCAPS, @@ -6518,7 +6529,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, @@ -6528,7 +6539,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, @@ -6538,7 +6550,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, @@ -6548,7 +6560,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, @@ -6558,7 +6570,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, @@ -6568,7 +6580,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, @@ -6578,7 +6591,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, @@ -6588,7 +6602,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, @@ -6598,7 +6612,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, @@ -6611,7 +6625,7 @@ static void test_rt_caps(void) ddraw = create_ddraw(); ok(!!ddraw, "Failed to create a ddraw object.\n"); hr = IDirectDraw4_SetCooperativeLevel(ddraw, window, DDSCL_NORMAL); - ok(SUCCEEDED(hr), "Failed to set cooperative level, hr %#x.\n", hr); + ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
if (FAILED(IDirectDraw4_QueryInterface(ddraw, &IID_IDirect3D3, (void **)&d3d))) { @@ -6619,120 +6633,162 @@ static void test_rt_caps(void) goto done; }
- memset(&z_fmt, 0, sizeof(z_fmt)); - hr = IDirect3D3_EnumZBufferFormats(d3d, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt); - if (FAILED(hr) || !z_fmt.dwSize) - { - skip("No depth buffer formats available, skipping test.\n"); - IDirect3D3_Release(d3d); - goto done; - } - memset(palette_entries, 0, sizeof(palette_entries)); hr = IDirectDraw4_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) { - IDirectDrawSurface4 *surface, *rt, *expected_rt, *tmp; - DDSURFACEDESC2 surface_desc; - IDirect3DDevice3 *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 = IDirect3D3_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 = IDirectDraw4_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 = IDirectDrawSurface4_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 = IDirect3D3_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device, NULL); - 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 = IDirectDrawSurface4_SetPalette(surface, palette); - ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr); - hr = IDirect3D3_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device, NULL); - 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); - } - IDirectDrawSurface4_Release(surface); + IDirectDrawSurface4 *surface, *rt, *expected_rt, *tmp; + DDSURFACEDESC2 surface_desc; + IDirect3DDevice3 *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 = IDirectDraw4_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 = IDirect3D3_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device, NULL); - 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 = IDirectDrawSurface4_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 = IDirectDraw4_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 + || 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 = IDirect3DDevice3_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; + hr = IDirect3D3_CreateDevice(d3d, test_devices[device_type], surface, &device, NULL); + + 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 = IDirectDrawSurface4_SetPalette(surface, palette); + ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type); + if (device_type) + { + /* _CreateDevice succeeds with software device, but the palette gets extra reference + * on Windows (probably due to a bug) which doesn't go away on the device and surface + * destruction and ddraw is not destroyed cleanly, so skipping this test. */ + IDirectDrawSurface4_Release(surface); + continue; + } + hr = IDirect3D3_CreateDevice(d3d, test_devices[device_type], surface, &device, NULL); + 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); + } + IDirectDrawSurface4_Release(surface);
- hr = IDirect3DDevice3_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 = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; + surface_desc.dwWidth = 640; + surface_desc.dwHeight = 480; + hr = IDirectDraw4_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 = IDirect3D3_CreateDevice(d3d, test_devices[device_type], surface, &device, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type); + }
- IDirectDrawSurface4_Release(tmp); - IDirectDrawSurface4_Release(rt); - refcount = IDirect3DDevice3_Release(device); - ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount); - refcount = IDirectDrawSurface4_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); + 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 = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &rt, NULL); + ok(hr == DD_OK, "Got unexpected hr %#x, test %u, device_type %u.\n", hr, i, device_type); + + hr = IDirect3DDevice3_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 = IDirect3DDevice3_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); + + IDirectDrawSurface4_Release(tmp); + IDirectDrawSurface4_Release(rt); + refcount = IDirect3DDevice3_Release(device); + ok(refcount == 0, "Test %u: The device was not properly freed, refcount %u.\n", i, refcount); + refcount = IDirectDrawSurface4_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); IDirect3D3_Release(d3d);
done:
On Tue, 16 Feb 2021 at 12:10, Paul Gofman pgofman@codeweavers.com wrote:
- static const REFCLSID test_devices[] =
- {
&IID_IDirect3DHALDevice,
&IID_IDirect3DRGBDevice,
- };
I think typedefs in general, but pointer typedefs in particular are usually best avoided, so I'd prefer this as "static const CLSID * const test_devices[]". (Or "static const GUID * const test_devices[]"; ddraw considers these CLSIDs for CreateDevice(), but GUIDs for LPD3DENUMDEVICESCALLBACK, and IIDs for QueryInterface().)
@@ -6388,27 +6395,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,
DD_OK, D3D_OK, D3D_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, },
D3D_OK and DD_OK are defined to the same value, of course, but since you're changing them: As a principle IDirect3D* interfaces return D3D* HRESULTs, so conceptually I think D3D_OK is correct here.
if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW)
{
skip("No 3d hardwate, skipping test %u, device_type %u.\n", i, device_type);
"hardware"
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;
Perhaps an "is_software_device_type()" would be clearer than testing the index of the test_devices[] array.
Do you expect we'll have more RGB/software device tests in the future? Perhaps it makes sense to handle this the same way we handle feature levels in the d3d11 tests. I.e., passing the device type as a parameter to the test function, and then simply invoking it multiple times. One of the advantages would be that we could check whether a particular device type is supported in a common caller.
As an aside, I'm not sure whether I mentioned this before or not, but splitting ddraw test changes per ddraw version is probably one of the few cases where splitting patches doesn't do much for making review easier. If it's the same to you, feel free to combine these into a single patch in the future.
On 2/17/21 18:01, Henri Verbeet wrote:
Perhaps an "is_software_device_type()" would be clearer than testing the index of the test_devices[] array.
Do you expect we'll have more RGB/software device tests in the future?
Yes, I was going to add at least the test for actual rendering to the _SYSMEM rendertarget and locking it in process. I also have a specific test for using the surface without DDSCAPS_TEXTURE as texture in Staging [1] which I was going to add some time later when we have the sysmem rendertarget support in place.
Perhaps it makes sense to handle this the same way we handle feature levels in the d3d11 tests. I.e., passing the device type as a parameter to the test function, and then simply invoking it multiple times. One of the advantages would be that we could check whether a particular device type is supported in a common caller.
I will do that.
As an aside, I'm not sure whether I mentioned this before or not, but splitting ddraw test changes per ddraw version is probably one of the few cases where splitting patches doesn't do much for making review easier. If it's the same to you, feel free to combine these into a single patch in the future.
Ok, I will send the update as a single patch.
1. https://github.com/wine-staging/wine-staging/blob/master/patches/ddraw-Textu...