[PATCH 01/10] d3d10core: Implement d3d10_device_SetPrivateData().
Henri Verbeet
hverbeet at codeweavers.com
Mon Feb 23 10:59:39 CST 2015
---
dlls/d3d10core/device.c | 12 +++-
dlls/d3d10core/tests/device.c | 140 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 150 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index 7f41360..21f3c30 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -1284,10 +1284,18 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *ifac
static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface,
REFGUID guid, UINT data_size, const void *data)
{
- FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
+ IDXGIDevice *dxgi_device;
+ HRESULT hr;
+
+ TRACE("iface %p, guid %s, data_size %u, data %p.\n",
iface, debugstr_guid(guid), data_size, data);
- return E_NOTIMPL;
+ if (FAILED(hr = ID3D10Device1_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device)))
+ return hr;
+ hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data);
+ IDXGIDevice_Release(dxgi_device);
+
+ return hr;
}
static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface,
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 8b51cda..24bddda 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -2519,6 +2519,145 @@ static void test_texture(void)
DestroyWindow(window);
}
+static void test_private_data(void)
+{
+ ULONG refcount, expected_refcount;
+ ID3D10Device *test_object;
+ IDXGIDevice *dxgi_device;
+ ID3D10Device *device;
+ IUnknown *ptr;
+ HRESULT hr;
+ UINT size;
+
+ static const GUID test_guid =
+ {0xfdb37466, 0x428f, 0x4edf, {0xa3, 0x7f, 0x9b, 0x1d, 0xf4, 0x88, 0xc5, 0xfc}};
+ static const GUID test_guid2 =
+ {0x2e5afac2, 0x87b5, 0x4c10, {0x9b, 0x4b, 0x89, 0xd7, 0xd1, 0x12, 0xe7, 0x2b}};
+ static const DWORD data[] = {1, 2, 3, 4};
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return;
+ }
+
+ test_object = create_device();
+
+ /* SetPrivateData() with a pointer of NULL has the purpose of
+ * FreePrivateData() in previous D3D versions. A successful clear returns
+ * S_OK. A redundant clear S_FALSE. Setting a NULL interface is not
+ * considered a clear but as setting an interface pointer that happens to
+ * be NULL. */
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, 0, NULL);
+ ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, ~0u, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, ~0u, NULL);
+ ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ size = sizeof(ptr) * 2;
+ ptr = (IUnknown *)0xdeadbeef;
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, &size, &ptr);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(!ptr, "Got unexpected pointer %p.\n", ptr);
+ todo_wine ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
+
+ hr = ID3D10Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device);
+ ok(SUCCEEDED(hr), "Failed to get DXGI device, hr %#x.\n", hr);
+ size = sizeof(ptr) * 2;
+ ptr = (IUnknown *)0xdeadbeef;
+ hr = IDXGIDevice_GetPrivateData(dxgi_device, &test_guid, &size, &ptr);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(!ptr, "Got unexpected pointer %p.\n", ptr);
+ todo_wine ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size);
+ IDXGIDevice_Release(dxgi_device);
+
+ refcount = get_refcount((IUnknown *)test_object);
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid,
+ (IUnknown *)test_object);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ expected_refcount = refcount + 1;
+ refcount = get_refcount((IUnknown *)test_object);
+ todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid,
+ (IUnknown *)test_object);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)test_object);
+ todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ --expected_refcount;
+ refcount = get_refcount((IUnknown *)test_object);
+ ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid,
+ (IUnknown *)test_object);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ size = sizeof(data);
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, size, data);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ refcount = get_refcount((IUnknown *)test_object);
+ ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, 42, NULL);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ hr = ID3D10Device_SetPrivateData(device, &test_guid, 42, NULL);
+ ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
+
+ hr = ID3D10Device_SetPrivateDataInterface(device, &test_guid,
+ (IUnknown *)test_object);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ++expected_refcount;
+ size = 2 * sizeof(ptr);
+ ptr = NULL;
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, &size, &ptr);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(size == sizeof(test_object), "Got unexpected size %u.\n", size);
+ ++expected_refcount;
+ refcount = get_refcount((IUnknown *)test_object);
+ todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ if (ptr)
+ IUnknown_Release(ptr);
+ --expected_refcount;
+
+ ptr = (IUnknown *)0xdeadbeef;
+ size = 1;
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, &size, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+ size = 2 * sizeof(ptr);
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, &size, NULL);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+ refcount = get_refcount((IUnknown *)test_object);
+ todo_wine ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+
+ size = 1;
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, &size, &ptr);
+ todo_wine ok(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(size == sizeof(device), "Got unexpected size %u.\n", size);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ hr = ID3D10Device_GetPrivateData(device, &test_guid2, NULL, NULL);
+ todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+ size = 0xdeadbabe;
+ hr = ID3D10Device_GetPrivateData(device, &test_guid2, &size, &ptr);
+ todo_wine ok(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(size == 0, "Got unexpected size %u.\n", size);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+ hr = ID3D10Device_GetPrivateData(device, &test_guid, NULL, &ptr);
+ todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+ ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
+
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+ refcount = ID3D10Device_Release(test_object);
+ ok(!refcount, "Test object has %u references left.\n", refcount);
+}
+
START_TEST(device)
{
test_create_texture2d();
@@ -2537,4 +2676,5 @@ START_TEST(device)
test_clear_state();
test_blend();
test_texture();
+ test_private_data();
}
--
1.7.10.4
More information about the wine-patches
mailing list