Wine-Devel
Threads by month
- ----- 2026 -----
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 2 participants
- 84531 discussions
Signed-off-by: Esme Povirk <esme(a)codeweavers.com>
---
This just causes log spam. Any useful information can be found from
errors or using WINE_MONO_VERBOSE=1.
dlls/mscoree/corruntimehost.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/dlls/mscoree/corruntimehost.c b/dlls/mscoree/corruntimehost.c
index cf8acae09e0..51522c57d83 100644
--- a/dlls/mscoree/corruntimehost.c
+++ b/dlls/mscoree/corruntimehost.c
@@ -1319,7 +1319,6 @@ static void CDECL ReallyFixupVTable(struct dll_fixup *fixup)
ULONG_PTR *tokens = fixup->tokens;
for (i=0; i<fixup->fixup->count; i++)
{
- TRACE("%#lx\n", tokens[i]);
vtable[i] = mono_marshal_get_vtfixup_ftnptr(
image, tokens[i], fixup->fixup->type);
}
@@ -1363,7 +1362,6 @@ static void FixupVTableEntry(HMODULE hmodule, VTableFixup *vtable_fixup)
fixup->vtable = (BYTE*)hmodule + vtable_fixup->rva;
fixup->done = FALSE;
- TRACE("vtable_fixup->type=0x%x\n",vtable_fixup->type);
#if __x86_64__
if (vtable_fixup->type & COR_VTABLE_64BIT)
#else
--
2.25.1
1
0
Feb. 17, 2021
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
Supersedes 199974, 199975, 199989, 199990.
Changes:
- squash patches for different ddraw versions into one;
- use 'const GUID *' instead of 'REFCLSID';
- don't change D3D_OK to DD_OK in test data;
- fix typo ("hardware");
- pass the device guid as parameter to test function.
dlls/ddraw/tests/ddraw1.c | 72 +++++++++-----
dlls/ddraw/tests/ddraw2.c | 98 ++++++++++++-------
dlls/ddraw/tests/ddraw4.c | 170 ++++++++++++++++++++++-----------
dlls/ddraw/tests/ddraw7.c | 191 +++++++++++++++++++++++++-------------
4 files changed, 361 insertions(+), 170 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index d3e9fe0e1ff..96930a5f722 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -166,6 +166,11 @@ static BOOL ddraw_is_vmware(IDirectDraw *ddraw)
return ddraw_is_vendor(ddraw, 0x15ad);
}
+static BOOL is_software_device_type(const GUID *device_guid)
+{
+ return device_guid != &IID_IDirect3DHALDevice;
+}
+
static IDirectDrawSurface *create_overlay(IDirectDraw *ddraw,
unsigned int width, unsigned int height, DWORD format)
{
@@ -605,7 +610,7 @@ static IDirectDraw *create_ddraw(void)
return ddraw;
}
-static IDirect3DDevice *create_device(IDirectDraw *ddraw, HWND window, DWORD coop_level)
+static IDirect3DDevice *create_device_ex(IDirectDraw *ddraw, HWND window, DWORD coop_level, const GUID *device_guid)
{
/* Prefer 16 bit depth buffers because Nvidia gives us an unpadded D24 buffer if we ask
* for 24 bit and handles such buffers incorrectly in DDBLT_DEPTHFILL. AMD only supports
@@ -665,7 +670,7 @@ static IDirect3DDevice *create_device(IDirectDraw *ddraw, HWND window, DWORD coo
if (FAILED(hr))
continue;
- if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface, &IID_IDirect3DHALDevice, (void **)&device)))
+ if (SUCCEEDED(IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device)))
break;
IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
@@ -675,6 +680,11 @@ static IDirect3DDevice *create_device(IDirectDraw *ddraw, HWND window, DWORD coo
return device;
}
+static IDirect3DDevice *create_device(IDirectDraw *ddraw, HWND window, DWORD coop_level)
+{
+ return create_device_ex(ddraw, window, coop_level, &IID_IDirect3DHALDevice);
+}
+
static IDirect3DViewport *create_viewport(IDirect3DDevice *device, UINT x, UINT y, UINT w, UINT h)
{
IDirect3DViewport *viewport;
@@ -4316,11 +4326,12 @@ static void test_unsupported_formats(void)
DestroyWindow(window);
}
-static void test_rt_caps(void)
+static void test_rt_caps(const GUID *device_guid)
{
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
IDirect3DDevice *device;
+ BOOL software_device;
IDirectDraw *ddraw;
DWORD z_depth = 0;
unsigned int i;
@@ -4486,10 +4497,12 @@ static void test_rt_caps(void)
},
};
+ software_device = is_software_device_type(device_guid);
+
window = create_window();
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
+ if (!(device = create_device_ex(ddraw, window, DDSCL_NORMAL, device_guid)))
{
skip("Failed to create a 3D device, skipping test.\n");
IDirectDraw_Release(ddraw);
@@ -4502,7 +4515,7 @@ 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)
{
@@ -4527,32 +4540,41 @@ static void test_rt_caps(void)
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);
+ ok(hr == DD_OK || broken(test_data[i].create_may_fail),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+
if (FAILED(hr))
continue;
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);
-
- 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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ ok(test_data[i].caps_out == ~0u || surface_desc.ddsCaps.dwCaps == test_data[i].caps_out,
+ "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out, i, software_device);
+
+ hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device);
+ todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
+ ok((!software_device && hr == test_data[i].create_device_hr)
+ || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
+ ? DD_OK : test_data[i].create_device_hr))),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ hr = IDirectDrawSurface_QueryInterface(surface, device_guid, (void **)&device);
+ if (software_device)
+ todo_wine
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
+ else if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
+ ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
else
- ok(hr == D3DERR_SURFACENOTINVIDMEM, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
}
if (SUCCEEDED(hr))
{
@@ -14407,6 +14429,12 @@ static void test_get_display_mode(void)
IDirectDraw_Release(ddraw);
}
+static void run_for_each_device_type(void (*test_func)(const GUID *))
+{
+ test_func(&IID_IDirect3DHALDevice);
+ test_func(&IID_IDirect3DRGBDevice);
+}
+
START_TEST(ddraw1)
{
DDDEVICEIDENTIFIER identifier;
@@ -14468,7 +14496,7 @@ START_TEST(ddraw1)
test_clear_rect_count();
test_coop_level_activateapp();
test_unsupported_formats();
- test_rt_caps();
+ run_for_each_device_type(test_rt_caps);
test_primary_caps();
test_surface_lock();
test_surface_discard();
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index bc915c97864..2b16b742a32 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -163,6 +163,11 @@ static BOOL ddraw_is_vmware(IDirectDraw2 *ddraw)
return ddraw_is_vendor(ddraw, 0x15ad);
}
+static BOOL is_software_device_type(const GUID *device_guid)
+{
+ return device_guid != &IID_IDirect3DHALDevice;
+}
+
static IDirectDrawSurface *create_overlay(IDirectDraw2 *ddraw,
unsigned int width, unsigned int height, DWORD format)
{
@@ -435,7 +440,7 @@ static IDirectDraw2 *create_ddraw(void)
return ddraw2;
}
-static IDirect3DDevice2 *create_device(IDirectDraw2 *ddraw, HWND window, DWORD coop_level)
+static IDirect3DDevice2 *create_device_ex(IDirectDraw2 *ddraw, HWND window, DWORD coop_level, const GUID *device_guid)
{
/* Prefer 16 bit depth buffers because Nvidia gives us an unpadded D24 buffer if we ask
* for 24 bit and handles such buffers incorrectly in DDBLT_DEPTHFILL. AMD only supports
@@ -503,7 +508,7 @@ static IDirect3DDevice2 *create_device(IDirectDraw2 *ddraw, HWND window, DWORD c
if (FAILED(hr))
continue;
- if (SUCCEEDED(IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device)))
+ if (SUCCEEDED(IDirect3D2_CreateDevice(d3d, device_guid, surface, &device)))
break;
IDirectDrawSurface_DeleteAttachedSurface(surface, 0, ds);
@@ -514,6 +519,11 @@ static IDirect3DDevice2 *create_device(IDirectDraw2 *ddraw, HWND window, DWORD c
return device;
}
+static IDirect3DDevice2 *create_device(IDirectDraw2 *ddraw, HWND window, DWORD coop_level)
+{
+ return create_device_ex(ddraw, window, coop_level, &IID_IDirect3DHALDevice);
+}
+
static IDirect3DViewport2 *create_viewport(IDirect3DDevice2 *device, UINT x, UINT y, UINT w, UINT h)
{
IDirect3DViewport2 *viewport;
@@ -4739,11 +4749,12 @@ static void test_unsupported_formats(void)
DestroyWindow(window);
}
-static void test_rt_caps(void)
+static void test_rt_caps(const GUID *device_guid)
{
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
IDirect3DDevice2 *device;
+ BOOL software_device;
IDirectDraw2 *ddraw;
DWORD z_depth = 0;
IDirect3D2 *d3d;
@@ -4952,10 +4963,12 @@ static void test_rt_caps(void)
},
};
+ software_device = is_software_device_type(device_guid);
+
window = create_window();
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
- if (!(device = create_device(ddraw, window, DDSCL_NORMAL)))
+ if (!(device = create_device_ex(ddraw, window, DDSCL_NORMAL, device_guid)))
{
skip("Failed to create a 3D device, skipping test.\n");
IDirectDraw2_Release(ddraw);
@@ -4974,7 +4987,7 @@ 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)
{
@@ -4999,34 +5012,50 @@ static void test_rt_caps(void)
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);
+ ok(hr == DD_OK || broken(test_data[i].create_may_fail),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
if (FAILED(hr))
continue;
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ ok(test_data[i].caps_out == ~0u || surface_desc.ddsCaps.dwCaps == test_data[i].caps_out,
+ "Got unexpected caps %#x, expected %#x, test %u, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out, i, software_device);
+
+ hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
+
+ todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
+ ok((!software_device && hr == test_data[i].create_device_hr)
+ || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
+ ? DD_OK : test_data[i].create_device_hr))),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
- 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)
{
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
+ if (software_device)
+ todo_wine
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
+ else if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
+ ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
else
- ok(hr == D3DERR_SURFACENOTINVIDMEM, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
+
+ 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);
@@ -5037,10 +5066,10 @@ static void test_rt_caps(void)
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
- hr = IDirect3D2_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device);
- ok(SUCCEEDED(hr), "Test %u: Failed to create device, hr %#x.\n", i, hr);
+ hr = IDirect3D2_CreateDevice(d3d, device_guid, surface, &device);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
}
memset(&surface_desc, 0, sizeof(surface_desc));
@@ -5060,13 +5089,14 @@ static void test_rt_caps(void)
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
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);
+ ok(hr == test_data[i].set_rt_hr || (software_device && hr == DDERR_NOPALETTEATTACHED)
+ || broken(hr == test_data[i].alternative_set_rt_hr),
+ "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
+
if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
expected_rt = rt;
else
@@ -5081,8 +5111,8 @@ static void test_rt_caps(void)
}
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
IDirectDrawSurface_Release(tmp);
IDirectDrawSurface_Release(rt);
@@ -15211,6 +15241,12 @@ done:
IDirectDraw2_Release(ddraw);
}
+static void run_for_each_device_type(void (*test_func)(const GUID *))
+{
+ test_func(&IID_IDirect3DHALDevice);
+ test_func(&IID_IDirect3DRGBDevice);
+}
+
START_TEST(ddraw2)
{
DDDEVICEIDENTIFIER identifier;
@@ -15276,7 +15312,7 @@ START_TEST(ddraw2)
test_lighting_interface_versions();
test_coop_level_activateapp();
test_unsupported_formats();
- test_rt_caps();
+ run_for_each_device_type(test_rt_caps);
test_primary_caps();
test_surface_lock();
test_surface_discard();
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index f009b4583f4..7e1c9837243 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -164,6 +164,11 @@ static BOOL ddraw_is_vmware(IDirectDraw4 *ddraw)
return ddraw_is_vendor(ddraw, 0x15ad);
}
+static BOOL is_software_device_type(const GUID *device_guid)
+{
+ return device_guid != &IID_IDirect3DHALDevice;
+}
+
static IDirectDrawSurface4 *create_overlay(IDirectDraw4 *ddraw,
unsigned int width, unsigned int height, DWORD format)
{
@@ -6355,10 +6360,12 @@ static void test_unsupported_formats(void)
DestroyWindow(window);
}
-static void test_rt_caps(void)
+static void test_rt_caps(const GUID *device_guid)
{
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
+ BOOL software_device;
+ DWORD expected_caps;
IDirectDraw4 *ddraw;
DDPIXELFORMAT z_fmt;
IDirect3D3 *d3d;
@@ -6377,7 +6384,7 @@ static void test_rt_caps(void)
{
const DDPIXELFORMAT *pf;
DWORD caps_in;
- DWORD caps_out;
+ DWORD caps_out[2];
DWORD caps2_in;
DWORD caps2_out;
HRESULT create_device_hr;
@@ -6388,7 +6395,7 @@ 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,
@@ -6398,7 +6405,8 @@ static void test_rt_caps(void)
{
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,
@@ -6408,7 +6416,8 @@ static void test_rt_caps(void)
{
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,7 +6447,7 @@ 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,
@@ -6448,7 +6457,8 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_3DDEVICE,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
0,
0,
D3D_OK,
@@ -6458,7 +6468,8 @@ static void test_rt_caps(void)
{
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,
@@ -6607,11 +6621,13 @@ static void test_rt_caps(void)
},
};
+ software_device = is_software_device_type(device_guid);
+
window = create_window();
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)))
{
@@ -6620,17 +6636,17 @@ static void test_rt_caps(void)
}
memset(&z_fmt, 0, sizeof(z_fmt));
- hr = IDirect3D3_EnumZBufferFormats(d3d, &IID_IDirect3DHALDevice, enum_z_fmt, &z_fmt);
+ hr = IDirect3D3_EnumZBufferFormats(d3d, device_guid, enum_z_fmt, &z_fmt);
if (FAILED(hr) || !z_fmt.dwSize)
{
- skip("No depth buffer formats available, skipping test.\n");
+ skip("No depth buffer formats available, software_device %u, skipping test.\n", software_device);
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)
{
@@ -6651,34 +6667,71 @@ static void test_rt_caps(void)
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);
+ if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW)
+ {
+ skip("No 3d hardware, skipping test %u, software_device %u.\n", i, software_device);
+ continue;
+ }
+ ok(hr == DD_OK || (software_device && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
+ == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == DDERR_UNSUPPORTED)
+ || broken(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);
+ if (FAILED(hr))
+ continue;
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(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+
+ if (software_device)
+ {
+ expected_caps = test_data[i].caps_out[software_device]
+ ? test_data[i].caps_out[software_device] : 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, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, i, software_device);
+ }
+ 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, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out[0], i, software_device);
+ }
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);
+ "Got unexpected caps2 %#x, expected %#x, test %u, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_out, i, software_device);
+
+ hr = IDirect3D3_CreateDevice(d3d, device_guid, surface, &device, NULL);
- 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);
+ todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
+ ok((!software_device && hr == test_data[i].create_device_hr)
+ || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
+ ? DD_OK : test_data[i].create_device_hr))),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
if (FAILED(hr))
{
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ if (software_device)
+ {
+ /* _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, device_guid, surface, &device, NULL);
if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
- ok(hr == DDERR_INVALIDPIXELFORMAT, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
else
- ok(hr == D3DERR_SURFACENOTINVIDMEM, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
}
IDirectDrawSurface4_Release(surface);
@@ -6689,10 +6742,10 @@ static void test_rt_caps(void)
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, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
- hr = IDirect3D3_CreateDevice(d3d, &IID_IDirect3DHALDevice, surface, &device, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create device, hr %#x.\n", i, hr);
+ hr = IDirect3D3_CreateDevice(d3d, device_guid, surface, &device, NULL);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
}
memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6708,21 +6761,21 @@ static void test_rt_caps(void)
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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
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);
+ ok(hr == test_data[i].set_rt_hr || (software_device && hr == DDERR_NOPALETTEATTACHED)
+ || broken(hr == test_data[i].alternative_set_rt_hr),
+ "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
expected_rt = rt;
else
expected_rt = 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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
IDirectDrawSurface4_Release(tmp);
IDirectDrawSurface4_Release(rt);
@@ -6732,7 +6785,8 @@ static void test_rt_caps(void)
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:
@@ -18271,6 +18325,12 @@ done:
IDirectDraw4_Release(ddraw);
}
+static void run_for_each_device_type(void (*test_func)(const GUID *))
+{
+ test_func(&IID_IDirect3DHALDevice);
+ test_func(&IID_IDirect3DRGBDevice);
+}
+
START_TEST(ddraw4)
{
DDDEVICEIDENTIFIER identifier;
@@ -18343,7 +18403,7 @@ START_TEST(ddraw4)
test_texturemanage();
test_block_formats_creation();
test_unsupported_formats();
- test_rt_caps();
+ run_for_each_device_type(test_rt_caps);
test_primary_caps();
test_surface_lock();
test_surface_discard();
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 628360630dc..68f68ef6446 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -30,6 +30,7 @@ HRESULT WINAPI GetSurfaceFromDC(HDC dc, struct IDirectDrawSurface **surface, HDC
static HRESULT (WINAPI *pDirectDrawCreateEx)(GUID *guid, void **ddraw, REFIID iid, IUnknown *outer_unknown);
static BOOL is_ddraw64 = sizeof(DWORD) != sizeof(DWORD *);
static DEVMODEW registry_mode;
+static const GUID *hw_device_guid = &IID_IDirect3DHALDevice;
static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL *);
@@ -190,6 +191,11 @@ static BOOL ddraw_is_amd(IDirectDraw7 *ddraw)
return ddraw_is_vendor(ddraw, 0x1002);
}
+static BOOL is_software_device_type(const GUID *device_guid)
+{
+ return device_guid != &IID_IDirect3DTnLHalDevice && device_guid != &IID_IDirect3DHALDevice;
+}
+
static IDirectDrawSurface7 *create_overlay(IDirectDraw7 *ddraw,
unsigned int width, unsigned int height, DWORD format)
{
@@ -6085,13 +6091,13 @@ static void test_unsupported_formats(void)
DestroyWindow(window);
}
-static void test_rt_caps(void)
+static void test_rt_caps(const GUID *device_guid)
{
- const GUID *devtype = &IID_IDirect3DHALDevice;
PALETTEENTRY palette_entries[256];
IDirectDrawPalette *palette;
+ BOOL software_device;
+ DWORD expected_caps;
IDirectDraw7 *ddraw;
- BOOL hal_ok = FALSE;
DDPIXELFORMAT z_fmt;
IDirect3D7 *d3d;
unsigned int i;
@@ -6109,7 +6115,7 @@ static void test_rt_caps(void)
{
const DDPIXELFORMAT *pf;
DWORD caps_in;
- DWORD caps_out;
+ DWORD caps_out[2];
DWORD caps2_in;
DWORD caps2_out;
HRESULT create_device_hr;
@@ -6120,7 +6126,7 @@ 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,
@@ -6130,7 +6136,8 @@ static void test_rt_caps(void)
{
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,
@@ -6140,7 +6147,8 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_OFFSCREENPLAIN,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6150,7 +6158,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,
@@ -6160,7 +6168,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6170,7 +6178,7 @@ 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,
@@ -6180,7 +6188,8 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_3DDEVICE,
- DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_3DDEVICE | DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ DDSCAPS_3DDEVICE | DDSCAPS_SYSTEMMEMORY},
0,
0,
D3D_OK,
@@ -6190,7 +6199,7 @@ static void test_rt_caps(void)
{
NULL,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM, DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6200,7 +6209,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
- DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE,
+ {DDSCAPS_SYSTEMMEMORY | DDSCAPS_3DDEVICE},
0,
0,
D3DERR_SURFACENOTINVIDMEM,
@@ -6210,7 +6219,7 @@ static void test_rt_caps(void)
{
NULL,
DDSCAPS_SYSTEMMEMORY,
- DDSCAPS_SYSTEMMEMORY,
+ {DDSCAPS_SYSTEMMEMORY},
0,
0,
DDERR_INVALIDCAPS,
@@ -6220,7 +6229,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,
@@ -6230,7 +6239,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,
@@ -6240,7 +6249,7 @@ static void test_rt_caps(void)
{
&p8_fmt,
0,
- DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM,
+ {DDSCAPS_VIDEOMEMORY | DDSCAPS_LOCALVIDMEM},
0,
0,
DDERR_INVALIDCAPS,
@@ -6250,7 +6259,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,
@@ -6260,7 +6269,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,
@@ -6270,7 +6280,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,
@@ -6280,7 +6290,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,
@@ -6290,7 +6300,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,
@@ -6300,7 +6310,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,
@@ -6310,7 +6321,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,
@@ -6320,7 +6332,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,
@@ -6330,7 +6342,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,
@@ -6339,6 +6351,8 @@ static void test_rt_caps(void)
},
};
+ software_device = is_software_device_type(device_guid);
+
window = create_window();
ddraw = create_ddraw();
ok(!!ddraw, "Failed to create a ddraw object.\n");
@@ -6351,23 +6365,18 @@ static void test_rt_caps(void)
goto done;
}
- hr = IDirect3D7_EnumDevices(d3d, enum_devtype_cb, &hal_ok);
- ok(SUCCEEDED(hr), "Failed to enumerate devices, hr %#x.\n", hr);
- if (hal_ok)
- devtype = &IID_IDirect3DTnLHalDevice;
-
memset(&z_fmt, 0, sizeof(z_fmt));
- hr = IDirect3D7_EnumZBufferFormats(d3d, devtype, enum_z_fmt, &z_fmt);
+ hr = IDirect3D7_EnumZBufferFormats(d3d, device_guid, enum_z_fmt, &z_fmt);
if (FAILED(hr) || !z_fmt.dwSize)
{
- skip("No depth buffer formats available, skipping test.\n");
+ skip("No depth buffer formats available, software_device %u, skipping test.\n", software_device);
IDirect3D7_Release(d3d);
goto done;
}
memset(palette_entries, 0, sizeof(palette_entries));
hr = IDirectDraw7_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)
{
@@ -6388,34 +6397,68 @@ static void test_rt_caps(void)
surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480;
hr = IDirectDraw7_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);
+ if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY && hr == DDERR_NODIRECTDRAWHW)
+ {
+ skip("No 3d hardware, skipping test %u, software_device %u.\n", i, software_device);
+ continue;
+ }
+ ok(hr == DD_OK || (software_device && (surface_desc.ddsCaps.dwCaps & (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER))
+ == (DDSCAPS_VIDEOMEMORY | DDSCAPS_ZBUFFER) && hr == DDERR_UNSUPPORTED)
+ || broken(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);
+ if (FAILED(hr))
+ continue;
memset(&surface_desc, 0, sizeof(surface_desc));
surface_desc.dwSize = sizeof(surface_desc);
hr = IDirectDrawSurface7_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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
- hr = IDirect3D7_CreateDevice(d3d, devtype, 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 (software_device)
+ {
+ expected_caps = test_data[i].caps_out[software_device]
+ ? test_data[i].caps_out[software_device] : test_data[i].caps_out[0];
+
+ todo_wine_if(test_data[i].caps_out[software_device]
+ && 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, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, i, software_device);
+ }
+ 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, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps, test_data[i].caps_out[0], i, software_device);
+ }
+ ok(surface_desc.ddsCaps.dwCaps2 == test_data[i].caps2_out,
+ "Got unexpected caps2 %#x, expected %#x, test %u, software_device %u.\n",
+ surface_desc.ddsCaps.dwCaps2, test_data[i].caps2_out, i, software_device);
+
+ hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
+ todo_wine_if(software_device && test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM)
+ ok((!software_device && hr == test_data[i].create_device_hr)
+ || (software_device && (hr == (test_data[i].create_device_hr == D3DERR_SURFACENOTINVIDMEM
+ ? DD_OK : test_data[i].create_device_hr))),
+ "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
if (FAILED(hr))
{
if (hr == DDERR_NOPALETTEATTACHED)
{
hr = IDirectDrawSurface7_SetPalette(surface, palette);
- ok(SUCCEEDED(hr), "Test %u: Failed to set palette, hr %#x.\n", i, hr);
- hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
if (surface_desc.ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
- ok(hr == DDERR_INVALIDPIXELFORMAT, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == DDERR_INVALIDPIXELFORMAT, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
+ else if (software_device)
+ todo_wine
+ ok(hr == E_FAIL, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
else
- ok(hr == D3DERR_SURFACENOTINVIDMEM, "Test %u: Got unexpected hr %#x.\n", i, hr);
+ ok(hr == D3DERR_SURFACENOTINVIDMEM, "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
}
IDirectDrawSurface7_Release(surface);
@@ -6426,10 +6469,10 @@ static void test_rt_caps(void)
surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480;
hr = IDirectDraw7_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Test %u: Failed to create surface, hr %#x.\n", i, hr);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
- hr = IDirect3D7_CreateDevice(d3d, devtype, surface, &device);
- ok(SUCCEEDED(hr), "Test %u: Failed to create device, hr %#x.\n", i, hr);
+ hr = IDirect3D7_CreateDevice(d3d, device_guid, surface, &device);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
}
memset(&surface_desc, 0, sizeof(surface_desc));
@@ -6445,21 +6488,21 @@ static void test_rt_caps(void)
surface_desc.dwWidth = 640;
surface_desc.dwHeight = 480;
hr = IDirectDraw7_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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
hr = IDirect3DDevice7_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);
+ ok(hr == test_data[i].set_rt_hr || (software_device && hr == DDERR_NOPALETTEATTACHED)
+ || broken(hr == test_data[i].alternative_set_rt_hr),
+ "Got unexpected hr %#x, test %u, software_device %u.\n",
+ hr, i, software_device);
if (SUCCEEDED(hr) || hr == DDERR_INVALIDPIXELFORMAT)
expected_rt = rt;
else
expected_rt = surface;
hr = IDirect3DDevice7_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);
+ ok(hr == DD_OK, "Got unexpected hr %#x, test %u, software_device %u.\n", hr, i, software_device);
+ ok(tmp == expected_rt, "Got unexpected rt %p, test %u, software_device %u.\n", tmp, i, software_device);
IDirectDrawSurface7_Release(tmp);
IDirectDrawSurface7_Release(rt);
@@ -6469,7 +6512,8 @@ static void test_rt_caps(void)
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);
IDirect3D7_Release(d3d);
done:
@@ -18533,12 +18577,21 @@ done:
IDirectDraw7_Release(ddraw);
}
+static void run_for_each_device_type(void (*test_func)(const GUID *))
+{
+ test_func(hw_device_guid);
+ test_func(&IID_IDirect3DRGBDevice);
+}
+
START_TEST(ddraw7)
{
DDDEVICEIDENTIFIER2 identifier;
HMODULE module, dwmapi;
DEVMODEW current_mode;
IDirectDraw7 *ddraw;
+ IDirect3D7 *d3d;
+ BOOL hal_ok;
+ HRESULT hr;
module = GetModuleHandleA("ddraw.dll");
if (!(pDirectDrawCreateEx = (void *)GetProcAddress(module, "DirectDrawCreateEx")))
@@ -18561,6 +18614,20 @@ START_TEST(ddraw7)
HIWORD(U(identifier.liDriverVersion).HighPart), LOWORD(U(identifier.liDriverVersion).HighPart),
HIWORD(U(identifier.liDriverVersion).LowPart), LOWORD(U(identifier.liDriverVersion).LowPart));
}
+
+ if (IDirectDraw7_QueryInterface(ddraw, &IID_IDirect3D7, (void **)&d3d) == DD_OK)
+ {
+ hr = IDirect3D7_EnumDevices(d3d, enum_devtype_cb, &hal_ok);
+ ok(hr == DD_OK, "Got unexpected hr %#x.\n", hr);
+ if (hal_ok)
+ hw_device_guid = &IID_IDirect3DTnLHalDevice;
+ IDirectDraw7_Release(d3d);
+ }
+ else
+ {
+ trace("D3D interface is not available.\n");
+ }
+
IDirectDraw7_Release(ddraw);
memset(¤t_mode, 0, sizeof(current_mode));
@@ -18612,7 +18679,7 @@ START_TEST(ddraw7)
test_texturemanage();
test_block_formats_creation();
test_unsupported_formats();
- test_rt_caps();
+ run_for_each_device_type(test_rt_caps);
test_primary_caps();
test_surface_lock();
test_surface_discard();
--
2.29.2
2
1
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v3: I got caught by the change to the parameterized_arg rule that was
actually prepending types instead of appending types them, as the helper
name suggests, reversing the list order.
So I decided to clean all this type_list_t single linked list mess
first, to use the usual double linked list structure and helpers. As
there was already a ifref_list_t / ifref_t that is mostly a type list,
I just renamed it and used it everywhere type_list_t was used.
Then this also:
* Fix memmove off-by-one error in format_parameterized_type_c_name.
* Fix incorrect usage of u.type_list for STMT_TYPE and STMT_TYPEREF,
* Use STMT_TYPE with a partially specialized parameterized type for the
delayed definitions, instead of trying to force use of type_list.
* Removes development code leftovers.
* Add loc_info_t to replace_type_parameters_in_statement(_list).
* Print proper error message in unsupported cases.
* Delay the delegate patches to a later batch.
Thanks Jacek for the review!
tools/widl/parser.y | 4 ++--
tools/widl/typetree.c | 8 ++++----
tools/widl/typetree.h | 2 +-
tools/widl/widltypes.h | 2 +-
tools/widl/write_msft.c | 6 +++---
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 6ab4f83a0ad..54006529ba9 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -1821,10 +1821,10 @@ static ifref_list_t *append_ifref(ifref_list_t *list, ifref_t *iface)
return list;
}
-static ifref_t *make_ifref(type_t *iface)
+static ifref_t *make_ifref(type_t *type)
{
ifref_t *l = xmalloc(sizeof(ifref_t));
- l->iface = iface;
+ l->type = type;
l->attrs = NULL;
return l;
}
diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c
index 203fffcdee6..2f49a92511a 100644
--- a/tools/widl/typetree.c
+++ b/tools/widl/typetree.c
@@ -565,19 +565,19 @@ type_t *type_runtimeclass_define(type_t *runtimeclass, attr_list_t *attrs, ifref
/* FIXME: this should probably not be allowed, here or in coclass, */
/* but for now there's too many places in Wine IDL where it is to */
/* even print a warning. */
- if (!(ifref->iface->defined)) continue;
- if (!(requires = type_iface_get_requires(ifref->iface))) continue;
+ if (!(ifref->type->defined)) continue;
+ if (!(requires = type_iface_get_requires(ifref->type))) continue;
LIST_FOR_EACH_ENTRY(required, requires, ifref_t, entry)
{
int found = 0;
LIST_FOR_EACH_ENTRY(tmp, ifaces, ifref_t, entry)
- if ((found = type_is_equal(tmp->iface, required->iface))) break;
+ if ((found = type_is_equal(tmp->type, required->type))) break;
if (!found)
error_loc("interface '%s' also requires interface '%s', "
"but runtimeclass '%s' does not implement it.\n",
- ifref->iface->name, required->iface->name, runtimeclass->name);
+ ifref->type->name, required->type->name, runtimeclass->name);
}
}
diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h
index 96b681e0379..186f42307f4 100644
--- a/tools/widl/typetree.h
+++ b/tools/widl/typetree.h
@@ -363,7 +363,7 @@ static inline type_t *type_runtimeclass_get_default_iface(const type_t *type)
if (!ifaces) return NULL;
LIST_FOR_EACH_ENTRY(entry, ifaces, ifref_t, entry)
if (is_attr(entry->attrs, ATTR_DEFAULT))
- return entry->iface;
+ return entry->type;
return NULL;
}
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 7596577493d..f31d40cad91 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -538,7 +538,7 @@ struct _declarator_t {
};
struct _ifref_t {
- type_t *iface;
+ type_t *type;
attr_list_t *attrs;
/* parser-internal */
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index 5728f041f6f..63635cec011 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -2352,10 +2352,10 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
i = 0;
if (ifaces) LIST_FOR_EACH_ENTRY( iref, ifaces, ifref_t, entry ) {
- if(iref->iface->typelib_idx == -1)
- add_interface_typeinfo(typelib, iref->iface);
+ if(iref->type->typelib_idx == -1)
+ add_interface_typeinfo(typelib, iref->type);
ref = (MSFT_RefRecord*) (typelib->typelib_segment_data[MSFT_SEG_REFERENCES] + offset + i * sizeof(*ref));
- ref->reftype = typelib->typelib_typeinfo_offsets[iref->iface->typelib_idx];
+ ref->reftype = typelib->typelib_typeinfo_offsets[iref->type->typelib_idx];
ref->flags = 0;
ref->oCustData = -1;
ref->onext = -1;
--
2.30.0
2
14
Signed-off-by: Floris Renaud <jkfloris(a)dds.nl>
---
po/nl.po | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/po/nl.po b/po/nl.po
index 27ef0b5aaba..9bc3c9f9e53 100644
--- a/po/nl.po
+++ b/po/nl.po
@@ -6043,7 +6043,7 @@ msgstr "Geen MDI-kindvenster.\n"
#: dlls/kernel32/winerror.mc:2628
msgid "Popup menu already active.\n"
-msgstr "Popup-menu reeds actief.\n"
+msgstr "Pop-up menu reeds actief.\n"
#: dlls/kernel32/winerror.mc:2633
msgid "No scrollbars.\n"
@@ -8102,7 +8102,7 @@ msgstr "client"
#: dlls/oleacc/oleacc.rc:42
msgid "popup menu"
-msgstr "popupmenu"
+msgstr "pop-up menu"
#: dlls/oleacc/oleacc.rc:43
msgid "menu item"
@@ -12961,7 +12961,7 @@ msgstr "&Verwijder dubbelen"
#: programs/conhost/conhost.rc:65
msgid "Popup menu"
-msgstr "Popup menu"
+msgstr "Pop-up menu"
#: programs/conhost/conhost.rc:66
msgid "&Control"
@@ -13021,7 +13021,7 @@ msgstr "H&oogte :"
#: programs/conhost/conhost.rc:111
msgid "End of program"
-msgstr "Programma is beëindigd"
+msgstr "Einde programma"
#: programs/conhost/conhost.rc:112
msgid "&Close console"
@@ -13029,7 +13029,7 @@ msgstr "&Console afsluiten"
#: programs/conhost/conhost.rc:114
msgid "Edition"
-msgstr "Versie"
+msgstr "Modus"
#: programs/conhost/conhost.rc:120
msgid "Console parameters"
@@ -16108,7 +16108,7 @@ msgstr ""
#: programs/wineboot/wineboot.rc:46
msgid "The Wine configuration in %s is being updated, please wait..."
msgstr ""
-"De Wine configuratie in %s wordt bijgewerkt, even geduld alstublieft..."
+"De Wine configuratie in %s wordt bijgewerkt.\nEven geduld alstublieft..."
#: programs/winecfg/winecfg.rc:140
msgid ""
@@ -16205,7 +16205,7 @@ msgid ""
msgstr ""
"Elke DLL (Dynamic Link Library) kan apart worden ingesteld op "
"'ingebouwd' (de versie van Wine) of 'windows' (afkomstig van Windows of "
-"meegeleverd met een programma."
+"meegeleverd met een programma)."
#: programs/winecfg/winecfg.rc:193
msgid "&New override for library:"
--
2.30.0
1
0
Feb. 17, 2021
Fixes a typo from 9faa5eeddd24a057d9ff522259c9dbdc6203c098.
Signed-off-by: Jacek Caban <jacek(a)codeweavers.com>
---
tools/winegcc/winegcc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
1
0
[PATCH v3 1/6] quartz/tests: Add tests for IMediaEventEx::SetNotifyFlags.
by Anton Baskanov Feb. 17, 2021
by Anton Baskanov Feb. 17, 2021
Feb. 17, 2021
Signed-off-by: Anton Baskanov <baskanov(a)gmail.com>
---
v2: Pass BSTR instead of a C string.
---
dlls/quartz/tests/filtergraph.c | 130 ++++++++++++++++++++++++++++++++
1 file changed, 130 insertions(+)
diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c
index e4b72958e10..835a735667a 100644
--- a/dlls/quartz/tests/filtergraph.c
+++ b/dlls/quartz/tests/filtergraph.c
@@ -5148,6 +5148,135 @@ static void test_autoplug_uyvy(void)
ok(source_pin.ref == 1, "Got outstanding refcount %d.\n", source_pin.ref);
}
+static void test_set_notify_flags(void)
+{
+ IFilterGraph2 *graph = create_graph();
+ IMediaEventSink *media_event_sink;
+ IMediaControl *media_control;
+ IMediaEventEx *media_event;
+ struct testfilter filter;
+ LONG_PTR param1, param2;
+ HANDLE event;
+ HWND window;
+ BSTR status;
+ HRESULT hr;
+ ULONG ref;
+ LONG code;
+ MSG msg;
+
+ window = CreateWindowA("static", NULL, WS_OVERLAPPEDWINDOW,
+ 50, 50, 150, 150, NULL, NULL, NULL, NULL);
+ ok(!!window, "Failed to create window.\n");
+ status = SysAllocString(L"status");
+
+ hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaControl, (void **)&media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaEventEx, (void **)&media_event);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IFilterGraph2_QueryInterface(graph, &IID_IMediaEventSink, (void **)&media_event_sink);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ testfilter_init(&filter, NULL, 0);
+ filter.IAMFilterMiscFlags_iface.lpVtbl = &testmiscflags_vtbl;
+ filter.misc_flags = AM_FILTER_MISC_FLAGS_IS_RENDERER;
+
+ hr = IFilterGraph2_AddFilter(graph, &filter.IBaseFilter_iface, NULL);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventEx_GetEventHandle(media_event, (OAEVENT *)&event);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventEx_SetNotifyWindow(media_event, (OAHWND)window, WM_USER, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Run(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(WaitForSingleObject(event, 0) == 0, "Event should be signaled.\n");
+
+ while (PeekMessageA(&msg, window, WM_USER, WM_USER, PM_REMOVE));
+
+ hr = IMediaEventEx_SetNotifyFlags(media_event, AM_MEDIAEVENT_NONOTIFY);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+ hr = IMediaEventEx_GetEvent(media_event, &code, ¶m1, ¶m2, 50);
+ todo_wine ok(hr == E_ABORT, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventSink_Notify(media_event_sink, EC_STATUS, (LONG_PTR)status, (LONG_PTR)status);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+ ok(!PeekMessageA(&msg, window, WM_USER, WM_USER, PM_REMOVE), "Window should not be notified.\n");
+
+ hr = IMediaEventEx_GetEvent(media_event, &code, ¶m1, ¶m2, 50);
+ todo_wine ok(hr == E_ABORT, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK,
+ (LONG_PTR)&filter.IBaseFilter_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(WaitForSingleObject(event, 0) == 0, "Event should be signaled.\n");
+
+ hr = IMediaControl_Stop(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(WaitForSingleObject(event, 0) == 0, "Event should be signaled.\n");
+
+ hr = IMediaControl_Pause(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(WaitForSingleObject(event, 0) == 0, "Event should be signaled.\n");
+
+ hr = IMediaControl_Run(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+ hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK,
+ (LONG_PTR)&filter.IBaseFilter_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ ok(WaitForSingleObject(event, 0) == 0, "Event should be signaled.\n");
+
+ hr = IMediaEventEx_GetEvent(media_event, &code, ¶m1, ¶m2, 50);
+ todo_wine ok(hr == E_ABORT, "Got hr %#x.\n", hr);
+
+ todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+ hr = IMediaEventEx_SetNotifyFlags(media_event, 0);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaControl_Stop(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ hr = IMediaControl_Run(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventSink_Notify(media_event_sink, EC_COMPLETE, S_OK,
+ (LONG_PTR)&filter.IBaseFilter_iface);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ hr = IMediaEventEx_SetNotifyFlags(media_event, AM_MEDIAEVENT_NONOTIFY);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ todo_wine ok(WaitForSingleObject(event, 0) == WAIT_TIMEOUT, "Event should not be signaled.\n");
+
+ hr = IMediaControl_Stop(media_control);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+
+ IMediaControl_Release(media_control);
+ IMediaEventEx_Release(media_event);
+ IMediaEventSink_Release(media_event_sink);
+ ref = IFilterGraph2_Release(graph);
+ ok(!ref, "Got outstanding refcount %d.\n", ref);
+ ok(filter.ref == 1, "Got outstanding refcount %d.\n", filter.ref);
+
+ SysFreeString(status);
+ DestroyWindow(window);
+}
+
START_TEST(filtergraph)
{
CoInitializeEx(NULL, COINIT_MULTITHREADED);
@@ -5172,6 +5301,7 @@ START_TEST(filtergraph)
test_add_source_filter();
test_window_threading();
test_autoplug_uyvy();
+ test_set_notify_flags();
CoUninitialize();
test_render_with_multithread();
--
2.25.1
3
10
Feb. 17, 2021
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
dlls/advapi32/crypt.c | 8 +-------
dlls/advapi32/tests/crypt.c | 3 +++
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index a9314d31472..79eeec98c2d 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -582,13 +582,7 @@ BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFl
TRACE("(0x%lx, %p, %08x)\n", hProv, pdwReserved, dwFlags);
- if (!pProv)
- {
- SetLastError(NTE_BAD_UID);
- return FALSE;
- }
-
- if (pProv->dwMagic != MAGIC_CRYPTPROV)
+ if (!pProv || pProv->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
diff --git a/dlls/advapi32/tests/crypt.c b/dlls/advapi32/tests/crypt.c
index f34c99ee9bf..8d4f2ae5936 100644
--- a/dlls/advapi32/tests/crypt.c
+++ b/dlls/advapi32/tests/crypt.c
@@ -152,6 +152,9 @@ static void test_CryptReleaseContext(void)
ret = CryptContextAddRef(prov, NULL, 0);
ok(ret, "got %u\n", GetLastError());
+ ret = CryptContextAddRef(0, NULL, 0);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
+
ret = CryptReleaseContext(prov, 0);
ok(ret, "got %u\n", GetLastError());
--
2.29.2
2
4
[PATCH 1/2] advapi32: Return ERROR_INVALID_PARAMETER for invalid crypt objects' handles.
by Paul Gofman Feb. 17, 2021
by Paul Gofman Feb. 17, 2021
Feb. 17, 2021
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
---
Supersedes 199774-199776
v2:
- don't pass error code to helper and always return _INVALID_PARAMETER
(renamed patch accordingly).
- add tests showing that _INVALID_PARAMETER is returned on Windows
where we were previously returning _INVALID_HANDLE.
- squash with patch 1.
dlls/advapi32/crypt.c | 410 +++++++++++++++++++-----------------
dlls/advapi32/tests/crypt.c | 55 ++++-
2 files changed, 264 insertions(+), 201 deletions(-)
diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index a9314d31472..e56a90795a8 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -57,6 +57,31 @@ static HWND crypt_hWindow;
#define CRYPT_Alloc(size) (LocalAlloc(LMEM_ZEROINIT, size))
#define CRYPT_Free(buffer) (LocalFree(buffer))
+static void *pointer_from_handle(UINT_PTR handle, DWORD magic)
+{
+ if (!handle || *(DWORD *)handle != magic)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+ return (void *)handle;
+}
+
+static PCRYPTPROV provider_from_handle(HCRYPTPROV handle)
+{
+ return pointer_from_handle(handle, MAGIC_CRYPTPROV);
+}
+
+static PCRYPTHASH hash_from_handle(HCRYPTHASH handle)
+{
+ return pointer_from_handle(handle, MAGIC_CRYPTHASH);
+}
+
+static PCRYPTKEY key_from_handle(HCRYPTKEY handle)
+{
+ return pointer_from_handle(handle, MAGIC_CRYPTKEY);
+}
+
static inline PWSTR CRYPT_GetProvKeyName(PCWSTR pProvName)
{
static const WCHAR KEYSTR[] = L"Software\\Microsoft\\Cryptography\\Defaults\\Provider\\";
@@ -578,21 +603,12 @@ BOOL WINAPI CryptAcquireContextA (HCRYPTPROV *phProv, LPCSTR pszContainer,
*/
BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFlags)
{
- PCRYPTPROV pProv = (PCRYPTPROV)hProv;
+ PCRYPTPROV pProv = provider_from_handle(hProv);
TRACE("(0x%lx, %p, %08x)\n", hProv, pdwReserved, dwFlags);
if (!pProv)
- {
- SetLastError(NTE_BAD_UID);
- return FALSE;
- }
-
- if (pProv->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
- }
InterlockedIncrement(&pProv->refcount);
return TRUE;
@@ -613,22 +629,13 @@ BOOL WINAPI CryptContextAddRef (HCRYPTPROV hProv, DWORD *pdwReserved, DWORD dwFl
*/
BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, DWORD dwFlags)
{
- PCRYPTPROV pProv = (PCRYPTPROV)hProv;
+ PCRYPTPROV pProv = provider_from_handle(hProv);
BOOL ret = TRUE;
TRACE("(0x%lx, %08x)\n", hProv, dwFlags);
if (!pProv)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if (pProv->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
- }
if (InterlockedDecrement(&pProv->refcount) == 0)
{
@@ -665,21 +672,12 @@ BOOL WINAPI CryptReleaseContext (HCRYPTPROV hProv, DWORD dwFlags)
*/
BOOL WINAPI CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
+ PCRYPTPROV prov = provider_from_handle(hProv);
TRACE("(0x%lx, %d, %p)\n", hProv, dwLen, pbBuffer);
- if (!hProv)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- if (prov->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
+ if (!prov)
return FALSE;
- }
return prov->pFuncs->pCPGenRandom(prov->hPrivate, dwLen, pbBuffer);
}
@@ -704,45 +702,51 @@ BOOL WINAPI CryptGenRandom (HCRYPTPROV hProv, DWORD dwLen, BYTE *pbBuffer)
* If the algorithm is a keyed hash, hKey is the key.
*/
BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
- DWORD dwFlags, HCRYPTHASH *phHash)
+ DWORD dwFlags, HCRYPTHASH *phHash)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
- PCRYPTHASH hash;
+ PCRYPTKEY key = NULL;
+ PCRYPTPROV prov;
+ PCRYPTHASH hash;
- TRACE("(0x%lx, 0x%x, 0x%lx, %08x, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
+ TRACE("(0x%lx, 0x%x, 0x%lx, %08x, %p)\n", hProv, Algid, hKey, dwFlags, phHash);
- if (!prov || !phHash || prov->dwMagic != MAGIC_CRYPTPROV ||
- (key && key->dwMagic != MAGIC_CRYPTKEY))
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
- if (dwFlags)
- {
- SetLastError(NTE_BAD_FLAGS);
- return FALSE;
- }
- if ( !(hash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
+ if (!(prov = provider_from_handle(hProv)))
+ return FALSE;
+
+ if (hKey && !(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (!phHash)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ if (dwFlags)
+ {
+ SetLastError(NTE_BAD_FLAGS);
+ return FALSE;
+ }
+ if ( !(hash = CRYPT_Alloc(sizeof(CRYPTHASH))) )
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
- hash->pProvider = prov;
- hash->dwMagic = MAGIC_CRYPTHASH;
- if (prov->pFuncs->pCPCreateHash(prov->hPrivate, Algid,
- key ? key->hPrivate : 0, 0, &hash->hPrivate))
+ hash->pProvider = prov;
+ hash->dwMagic = MAGIC_CRYPTHASH;
+ if (prov->pFuncs->pCPCreateHash(prov->hPrivate, Algid,
+ key ? key->hPrivate : 0, 0, &hash->hPrivate))
{
*phHash = (HCRYPTHASH)hash;
return TRUE;
}
- /* CSP error! */
- hash->dwMagic = 0;
- CRYPT_Free(hash);
- *phHash = 0;
- return FALSE;
+ /* CSP error! */
+ hash->dwMagic = 0;
+ CRYPT_Free(hash);
+ *phHash = 0;
+ return FALSE;
}
/******************************************************************************
@@ -764,25 +768,29 @@ BOOL WINAPI CryptCreateHash (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTKEY hKey,
* Failure: FALSE
*/
BOOL WINAPI CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
- DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
+ DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
{
- PCRYPTPROV prov;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash = NULL;
+ PCRYPTPROV prov;
+ PCRYPTKEY key;
- TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
+ TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen);
- if (!key || !pbData || !pdwDataLen ||
- !key->pProvider || key->dwMagic != MAGIC_CRYPTKEY ||
- key->pProvider->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
- prov = key->pProvider;
- return prov->pFuncs->pCPDecrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
- Final, dwFlags, pbData, pdwDataLen);
+ if (hHash && !(hash = hash_from_handle(hHash)))
+ return FALSE;
+
+ if (!pbData || !pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ prov = key->pProvider;
+ return prov->pFuncs->pCPDecrypt(prov->hPrivate, key->hPrivate, hash ? hash->hPrivate : 0,
+ Final, dwFlags, pbData, pdwDataLen);
}
/******************************************************************************
@@ -802,43 +810,44 @@ BOOL WINAPI CryptDecrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
* Failure: FALSE
*/
BOOL WINAPI CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData,
- DWORD dwFlags, HCRYPTKEY *phKey)
+ DWORD dwFlags, HCRYPTKEY *phKey)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
- PCRYPTHASH hash = (PCRYPTHASH)hBaseData;
- PCRYPTKEY key;
+ PCRYPTPROV prov;
+ PCRYPTHASH hash;
+ PCRYPTKEY key;
- TRACE("(0x%lx, 0x%08x, 0x%lx, 0x%08x, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
+ TRACE("(0x%lx, 0x%08x, 0x%lx, 0x%08x, %p)\n", hProv, Algid, hBaseData, dwFlags, phKey);
- if (!prov || !hash)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
- if (!phKey || prov->dwMagic != MAGIC_CRYPTPROV || hash->dwMagic != MAGIC_CRYPTHASH)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
- if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
+ if (!(prov = provider_from_handle(hProv)))
+ return FALSE;
- key->pProvider = prov;
- key->dwMagic = MAGIC_CRYPTKEY;
- if (prov->pFuncs->pCPDeriveKey(prov->hPrivate, Algid, hash->hPrivate, dwFlags, &key->hPrivate))
+ if (!(hash = hash_from_handle(hBaseData)))
+ return FALSE;
+
+ if (!phKey)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+ if ( !(key = CRYPT_Alloc(sizeof(CRYPTKEY))) )
+ {
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return FALSE;
+ }
+
+ key->pProvider = prov;
+ key->dwMagic = MAGIC_CRYPTKEY;
+ if (prov->pFuncs->pCPDeriveKey(prov->hPrivate, Algid, hash->hPrivate, dwFlags, &key->hPrivate))
{
*phKey = (HCRYPTKEY)key;
return TRUE;
}
- /* CSP error! */
- key->dwMagic = 0;
- CRYPT_Free(key);
- *phKey = 0;
- return FALSE;
+ /* CSP error! */
+ key->dwMagic = 0;
+ CRYPT_Free(key);
+ *phKey = 0;
+ return FALSE;
}
/******************************************************************************
@@ -855,20 +864,16 @@ BOOL WINAPI CryptDeriveKey (HCRYPTPROV hProv, ALG_ID Algid, HCRYPTHASH hBaseData
*/
BOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash)
{
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash;
PCRYPTPROV prov;
BOOL ret;
TRACE("(0x%lx)\n", hHash);
- if (!hash)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(hash = hash_from_handle(hHash)))
return FALSE;
- }
- if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
- hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -895,20 +900,16 @@ BOOL WINAPI CryptDestroyHash (HCRYPTHASH hHash)
*/
BOOL WINAPI CryptDestroyKey (HCRYPTKEY hKey)
{
- PCRYPTKEY key = (PCRYPTKEY)hKey;
PCRYPTPROV prov;
+ PCRYPTKEY key;
BOOL ret;
TRACE("(0x%lx)\n", hKey);
- if (!key)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(key = key_from_handle(hKey)))
return FALSE;
- }
- if (!key->pProvider || key->dwMagic != MAGIC_CRYPTKEY ||
- key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -944,9 +945,10 @@ BOOL WINAPI CryptDuplicateHash (HCRYPTHASH hHash, DWORD *pdwReserved,
TRACE("(0x%lx, %p, %08x, %p)\n", hHash, pdwReserved, dwFlags, phHash);
- orghash = (PCRYPTHASH)hHash;
- if (!orghash || pdwReserved || !phHash || !orghash->pProvider ||
- orghash->dwMagic != MAGIC_CRYPTHASH || orghash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(orghash = hash_from_handle(hHash)))
+ return FALSE;
+
+ if (pdwReserved || !phHash || !orghash->pProvider || orghash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -999,10 +1001,10 @@ BOOL WINAPI CryptDuplicateKey (HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags
TRACE("(0x%lx, %p, %08x, %p)\n", hKey, pdwReserved, dwFlags, phKey);
- orgkey = (PCRYPTKEY)hKey;
- if (!orgkey || pdwReserved || !phKey || !orgkey->pProvider ||
- orgkey->dwMagic != MAGIC_CRYPTKEY ||
- orgkey->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(orgkey = key_from_handle(hKey)))
+ return FALSE;
+
+ if (pdwReserved || !phKey || !orgkey->pProvider || orgkey->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1059,14 +1061,19 @@ BOOL WINAPI CryptDuplicateKey (HCRYPTKEY hKey, DWORD *pdwReserved, DWORD dwFlags
BOOL WINAPI CryptEncrypt (HCRYPTKEY hKey, HCRYPTHASH hHash, BOOL Final,
DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen, DWORD dwBufLen)
{
+ PCRYPTHASH hash = NULL;
PCRYPTPROV prov;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTKEY key;
TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p, %d)\n", hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen);
- if (!key || !pdwDataLen || !key->pProvider ||
- key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (hHash && !(hash = hash_from_handle(hHash)))
+ return FALSE;
+
+ if (!pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1367,12 +1374,17 @@ BOOL WINAPI CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType,
DWORD dwFlags, BYTE *pbData, DWORD *pdwDataLen)
{
PCRYPTPROV prov;
- PCRYPTKEY key = (PCRYPTKEY)hKey, expkey = (PCRYPTKEY)hExpKey;
+ PCRYPTKEY key, expkey = NULL;
TRACE("(0x%lx, 0x%lx, %d, %08x, %p, %p)\n", hKey, hExpKey, dwBlobType, dwFlags, pbData, pdwDataLen);
- if (!key || !pdwDataLen || !key->pProvider ||
- key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (hExpKey && !(expkey = key_from_handle(hExpKey)))
+ return FALSE;
+
+ if (!pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1400,12 +1412,15 @@ BOOL WINAPI CryptExportKey (HCRYPTKEY hKey, HCRYPTKEY hExpKey, DWORD dwBlobType,
*/
BOOL WINAPI CryptGenKey (HCRYPTPROV hProv, ALG_ID Algid, DWORD dwFlags, HCRYPTKEY *phKey)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
+ PCRYPTPROV prov;
PCRYPTKEY key;
TRACE("(0x%lx, %d, %08x, %p)\n", hProv, Algid, dwFlags, phKey);
- if (!phKey || !prov || prov->dwMagic != MAGIC_CRYPTPROV)
+ if (!(prov = provider_from_handle(hProv)))
+ return FALSE;
+
+ if (!phKey)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1560,12 +1575,15 @@ BOOL WINAPI CryptGetHashParam (HCRYPTHASH hHash, DWORD dwParam, BYTE *pbData,
DWORD *pdwDataLen, DWORD dwFlags)
{
PCRYPTPROV prov;
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash;
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hHash, dwParam, pbData, pdwDataLen, dwFlags);
- if (!hash || !pdwDataLen || !hash->pProvider ||
- hash->dwMagic != MAGIC_CRYPTHASH || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(hash = hash_from_handle(hHash)))
+ return FALSE;
+
+
+ if (!pdwDataLen || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1599,12 +1617,14 @@ BOOL WINAPI CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData,
DWORD *pdwDataLen, DWORD dwFlags)
{
PCRYPTPROV prov;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
+ PCRYPTKEY key;
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hKey, dwParam, pbData, pdwDataLen, dwFlags);
- if (!key || !pdwDataLen || !key->pProvider ||
- key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (!pdwDataLen || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1637,15 +1657,12 @@ BOOL WINAPI CryptGetKeyParam (HCRYPTKEY hKey, DWORD dwParam, BYTE *pbData,
BOOL WINAPI CryptGetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData,
DWORD *pdwDataLen, DWORD dwFlags)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
+ PCRYPTPROV prov;
TRACE("(0x%lx, %d, %p, %p, %08x)\n", hProv, dwParam, pbData, pdwDataLen, dwFlags);
- if (!prov || prov->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
+ if (!(prov = provider_from_handle(hProv)))
return FALSE;
- }
return prov->pFuncs->pCPGetProvParam(prov->hPrivate, dwParam, pbData, pdwDataLen, dwFlags);
}
@@ -1666,17 +1683,15 @@ BOOL WINAPI CryptGetProvParam (HCRYPTPROV hProv, DWORD dwParam, BYTE *pbData,
*/
BOOL WINAPI CryptGetUserKey (HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUserKey)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
+ PCRYPTPROV prov;
PCRYPTKEY key;
TRACE("(0x%lx, %d, %p)\n", hProv, dwKeySpec, phUserKey);
- if (!prov)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(prov = provider_from_handle(hProv)))
return FALSE;
- }
- if (!phUserKey || prov->dwMagic != MAGIC_CRYPTPROV)
+
+ if (!phUserKey)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1719,18 +1734,15 @@ BOOL WINAPI CryptGetUserKey (HCRYPTPROV hProv, DWORD dwKeySpec, HCRYPTKEY *phUse
*/
BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen, DWORD dwFlags)
{
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash;
PCRYPTPROV prov;
TRACE("(0x%lx, %p, %d, %08x)\n", hHash, pbData, dwDataLen, dwFlags);
- if (!hash)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(hash = hash_from_handle(hHash)))
return FALSE;
- }
- if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
- hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+
+ if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1756,20 +1768,19 @@ BOOL WINAPI CryptHashData (HCRYPTHASH hHash, const BYTE *pbData, DWORD dwDataLen
*/
BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags)
{
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
+ PCRYPTHASH hash;
+ PCRYPTKEY key;
PCRYPTPROV prov;
TRACE("(0x%lx, 0x%lx, %08x)\n", hHash, hKey, dwFlags);
- if (!hash || !key)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(hash = hash_from_handle(hHash)))
return FALSE;
- }
- if (!hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
- hash->pProvider->dwMagic != MAGIC_CRYPTPROV || key->dwMagic != MAGIC_CRYPTKEY)
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1799,14 +1810,18 @@ BOOL WINAPI CryptHashSessionKey (HCRYPTHASH hHash, HCRYPTKEY hKey, DWORD dwFlags
BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLen,
HCRYPTKEY hPubKey, DWORD dwFlags, HCRYPTKEY *phKey)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
- PCRYPTKEY pubkey = (PCRYPTKEY)hPubKey, importkey;
+ PCRYPTPROV prov;
+ PCRYPTKEY pubkey = NULL, importkey;
TRACE("(0x%lx, %p, %d, 0x%lx, %08x, %p)\n", hProv, pbData, dwDataLen, hPubKey, dwFlags, phKey);
- if (!prov || !pbData || !dwDataLen || !phKey ||
- prov->dwMagic != MAGIC_CRYPTPROV ||
- (pubkey && pubkey->dwMagic != MAGIC_CRYPTKEY))
+ if (!(prov = provider_from_handle(hProv)))
+ return FALSE;
+
+ if (hPubKey && !(pubkey = key_from_handle(hPubKey)))
+ return FALSE;
+
+ if (!pbData || !dwDataLen || !phKey)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1857,19 +1872,16 @@ BOOL WINAPI CryptImportKey (HCRYPTPROV hProv, const BYTE *pbData, DWORD dwDataLe
BOOL WINAPI CryptSignHashW (HCRYPTHASH hHash, DWORD dwKeySpec, LPCWSTR sDescription,
DWORD dwFlags, BYTE *pbSignature, DWORD *pdwSigLen)
{
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash;
PCRYPTPROV prov;
TRACE("(0x%lx, %d, %s, %08x, %p, %p)\n",
hHash, dwKeySpec, debugstr_w(sDescription), dwFlags, pbSignature, pdwSigLen);
- if (!hash)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(hash = hash_from_handle(hHash)))
return FALSE;
- }
- if (!pdwSigLen || !hash->pProvider || hash->dwMagic != MAGIC_CRYPTHASH ||
- hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+
+ if (!pdwSigLen || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1919,12 +1931,14 @@ BOOL WINAPI CryptSignHashA (HCRYPTHASH hHash, DWORD dwKeySpec, LPCSTR sDescripti
BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
{
PCRYPTPROV prov;
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
+ PCRYPTHASH hash;
TRACE("(0x%lx, %d, %p, %08x)\n", hHash, dwParam, pbData, dwFlags);
- if (!hash || !pbData || !hash->pProvider ||
- hash->dwMagic != MAGIC_CRYPTHASH || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(hash = hash_from_handle(hHash)))
+ return FALSE;
+
+ if (!pbData || !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -1953,12 +1967,14 @@ BOOL WINAPI CryptSetHashParam (HCRYPTHASH hHash, DWORD dwParam, const BYTE *pbDa
BOOL WINAPI CryptSetKeyParam (HCRYPTKEY hKey, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
{
PCRYPTPROV prov;
- PCRYPTKEY key = (PCRYPTKEY)hKey;
+ PCRYPTKEY key;
TRACE("(0x%lx, %d, %p, %08x)\n", hKey, dwParam, pbData, dwFlags);
- if (!key || !pbData || !key->pProvider ||
- key->dwMagic != MAGIC_CRYPTKEY || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
+ if (!(key = key_from_handle(hKey)))
+ return FALSE;
+
+ if (!pbData || !key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -2126,20 +2142,13 @@ BOOL WINAPI CryptSetProviderExA (LPCSTR pszProvName, DWORD dwProvType, DWORD *pd
*/
BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbData, DWORD dwFlags)
{
- PCRYPTPROV prov = (PCRYPTPROV)hProv;
+ PCRYPTPROV prov;
TRACE("(0x%lx, %d, %p, %08x)\n", hProv, dwParam, pbData, dwFlags);
- if (!prov)
- {
- SetLastError(ERROR_INVALID_HANDLE);
+ if (!(prov = provider_from_handle(hProv)))
return FALSE;
- }
- if (prov->dwMagic != MAGIC_CRYPTPROV)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
+
if (dwParam == PP_USE_HARDWARE_RNG)
{
FIXME("PP_USE_HARDWARE_RNG: What do I do with this?\n");
@@ -2186,15 +2195,20 @@ BOOL WINAPI CryptSetProvParam (HCRYPTPROV hProv, DWORD dwParam, const BYTE *pbDa
BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH hHash, const BYTE *pbSignature, DWORD dwSigLen,
HCRYPTKEY hPubKey, LPCWSTR sDescription, DWORD dwFlags)
{
- PCRYPTHASH hash = (PCRYPTHASH)hHash;
- PCRYPTKEY key = (PCRYPTKEY)hPubKey;
+ PCRYPTHASH hash;
+ PCRYPTKEY key;
PCRYPTPROV prov;
TRACE("(0x%lx, %p, %d, 0x%lx, %s, %08x)\n", hHash, pbSignature,
dwSigLen, hPubKey, debugstr_w(sDescription), dwFlags);
- if (!hash || !key || key->dwMagic != MAGIC_CRYPTKEY || hash->dwMagic != MAGIC_CRYPTHASH ||
- !hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV ||
+ if (!(hash = hash_from_handle(hHash)))
+ return FALSE;
+
+ if (!(key = key_from_handle(hPubKey)))
+ return FALSE;
+
+ if (!hash->pProvider || hash->pProvider->dwMagic != MAGIC_CRYPTPROV ||
!key->pProvider || key->pProvider->dwMagic != MAGIC_CRYPTPROV)
{
SetLastError(ERROR_INVALID_PARAMETER);
diff --git a/dlls/advapi32/tests/crypt.c b/dlls/advapi32/tests/crypt.c
index f34c99ee9bf..a6e3d447ba8 100644
--- a/dlls/advapi32/tests/crypt.c
+++ b/dlls/advapi32/tests/crypt.c
@@ -152,6 +152,9 @@ static void test_CryptReleaseContext(void)
ret = CryptContextAddRef(prov, NULL, 0);
ok(ret, "got %u\n", GetLastError());
+ ret = CryptContextAddRef(0, NULL, 0);
+ ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "got %u\n", GetLastError());
+
ret = CryptReleaseContext(prov, 0);
ok(ret, "got %u\n", GetLastError());
@@ -272,18 +275,49 @@ static void test_incorrect_api_usage(void)
result = CryptCreateHash(hProv, CALG_SHA, 0, 0, &hHash);
ok (result, "%d\n", GetLastError());
if (!result) return;
- CryptDestroyHash(hHash);
- result = CryptCreateHash(0, CALG_SHA, 0, 0, &hHash);
+ result = CryptDeriveKey(0, CALG_RC4, hHash, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
- result = CryptGenKey(0, CALG_RC4, 0, &hKey);
+ result = CryptDeriveKey(hProv, CALG_RC4, 0, 0, &hKey2);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptHashData(0, &temp, 1, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGenKey(hProv, CALG_RC4, 0, &hKey);
ok (result, "%d\n", GetLastError());
if (!result) return;
+ result = pCryptHashSessionKey(hHash, 0, 0);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = pCryptHashSessionKey(0, hKey, 0);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptDestroyHash(hHash);
+ ok (result, "%08x\n", GetLastError());
+
+ result = CryptDestroyHash(0);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptCreateHash(0, CALG_SHA, 0, 0, &hHash);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptGenKey(0, CALG_RC4, 0, &hKey);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ dwLen = 1;
+ result = CryptDecrypt(hKey, 0, TRUE, 0, &temp, &dwLen);
+ ok (result, "%d\n", GetLastError());
+ result = CryptDecrypt(0, 0, TRUE, 0, &temp, &dwLen);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptEncrypt(hKey, 0, TRUE, 0, &temp, &dwLen, sizeof(temp));
+ ok (result, "%d\n", GetLastError());
+ result = CryptEncrypt(0, 0, TRUE, 0, &temp, &dwLen, sizeof(temp));
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
result = CryptDestroyKey(hKey);
ok (result, "%d\n", GetLastError());
@@ -294,6 +328,9 @@ static void test_incorrect_api_usage(void)
result = CryptDestroyKey(hKey2);
ok (result, "%d\n", GetLastError());
+ result = CryptDestroyKey(0);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
dwTemp = CRYPT_MODE_ECB;
result = CryptSetKeyParam(hKey2, KP_MODE, (BYTE*)&dwTemp, sizeof(DWORD));
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
@@ -309,6 +346,9 @@ static void test_incorrect_api_usage(void)
ok(result, "got %u\n", GetLastError());
if (!result) return;
+ result = pCryptGenRandom(0, 1, &temp);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
result = pCryptGenRandom(hProv, 1, &temp);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
@@ -353,6 +393,9 @@ static void test_incorrect_api_usage(void)
dwLen = 1;
result = CryptGetProvParam(hProv, 0, &temp, &dwLen, 0);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
+ result = CryptGetUserKey(0, 0, &hKey2);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
result = CryptGetUserKey(hProv, 0, &hKey2);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
@@ -372,6 +415,9 @@ static void test_incorrect_api_usage(void)
result = pCryptSignHashW(hHash, 0, NULL, 0, &temp, &dwLen);
ok (!result && (GetLastError() == ERROR_INVALID_PARAMETER ||
GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
+ result = pCryptSignHashW(hHash, 0, NULL, 0, &temp, &dwLen);
+ ok (!result && (GetLastError() == ERROR_INVALID_PARAMETER ||
+ GetLastError() == ERROR_CALL_NOT_IMPLEMENTED), "%d\n", GetLastError());
}
else
win_skip("CryptSignHashW is not available\n");
@@ -382,6 +428,9 @@ static void test_incorrect_api_usage(void)
result = CryptSetHashParam(hHash, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+ result = CryptSetProvParam(0, 0, &temp, 1);
+ ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
+
result = CryptSetProvParam(hProv, 0, &temp, 1);
ok (!result && GetLastError() == ERROR_INVALID_PARAMETER, "%d\n", GetLastError());
--
2.29.2
1
1
[PATCH 1/2] d3d11: Make SwapDeviceContextState truly no-op when state is NULL.
by Rémi Bernon Feb. 17, 2021
by Rémi Bernon Feb. 17, 2021
Feb. 17, 2021
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
These two patches should be mostly independent from the rest of the
d3d11 state swap implementation, so I'm sending them now.
In the first patch, I'm not making any change to the rest of the logic,
although some ifs are now redundant with the initial checks, because
the function will have to be completely rewritten later anyway.
dlls/d3d11/device.c | 3 +++
dlls/d3d11/tests/d3d11.c | 3 +--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 8e5beb8893b..914b64d6019 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2761,6 +2761,9 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3
FIXME("iface %p, state %p, prev_state %p semi-stub!\n", iface, state, prev_state);
+ if (prev_state) *prev_state = NULL;
+ if (!state) return;
+
wined3d_mutex_lock();
if (prev_state)
{
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 044c1ce5a17..1505b3fddbc 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -7078,8 +7078,7 @@ static void test_device_context_state(void)
previous_context_state = (ID3DDeviceContextState *)0xdeadbeef;
ID3D11DeviceContext1_SwapDeviceContextState(context, NULL, &previous_context_state);
- todo_wine ok(previous_context_state == NULL, "Got unexpected state pointer.\n");
- if (previous_context_state) ID3DDeviceContextState_Release(previous_context_state);
+ ok(previous_context_state == NULL, "Got unexpected state pointer.\n");
previous_context_state = NULL;
ID3D11DeviceContext1_SwapDeviceContextState(context, context_state, &previous_context_state);
ok(previous_context_state != NULL, "Failed to get previous context state\n");
--
2.30.0
3
4
[PATCH v2 3/4] ddraw/tests: Also test RT caps for software device for ddraw4.
by Paul Gofman Feb. 17, 2021
by Paul Gofman Feb. 17, 2021
Feb. 17, 2021
Signed-off-by: Paul Gofman <pgofman(a)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:
--
2.29.2
2
2