[PATCH 3/4] ddraw/tests: Also test RT caps for software device for ddraw4.
Paul Gofman
pgofman at codeweavers.com
Tue Feb 16 03:14:44 CST 2021
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
dlls/ddraw/tests/ddraw4.c | 299 ++++++++++++++++++++++----------------
1 file changed, 172 insertions(+), 127 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index f009b4583f4..a4feb758449 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,27 @@ 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},
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,},
0,
0,
DDERR_INVALIDCAPS,
@@ -6418,7 +6425,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 +6435,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 +6445,27 @@ 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},
0,
0,
- D3D_OK,
- D3D_OK,
- D3D_OK,
+ DD_OK,
+ DD_OK,
+ DD_OK,
},
{
NULL,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6468,7 +6475,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 +6485,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6488,7 +6495,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 +6505,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 +6515,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6518,7 +6525,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 +6535,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
DDSCAPS_OFFSCREENPLAIN,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6538,7 +6545,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 +6555,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 +6565,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 +6575,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 +6586,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 +6597,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 +6607,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 +6620,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 +6628,156 @@ 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);
+ ok(hr == DD_OK || (device_type && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
+ == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == E_NOTIMPL),
+ "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
+ || 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 = 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);
- 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);
+ 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);
- 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 = 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);
+ }
+
+ 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:
--
2.29.2
More information about the wine-devel
mailing list