From 2d18cf57acb5be6a6bc00e31a915a340dab9a7c5 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 12 Feb 2015 09:34:59 +0100 Subject: [PATCH] dxgi: Implement dxgi_device_GetPrivateData(). --- dlls/dxgi/device.c | 6 ++++-- dlls/dxgi/dxgi_private.h | 2 ++ dlls/dxgi/tests/device.c | 32 +++++++++++++++--------------- dlls/dxgi/utils.c | 42 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 18 deletions(-) diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 8b320412432..2b8a05fc684 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -116,9 +116,11 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDe static HRESULT STDMETHODCALLTYPE dxgi_device_GetPrivateData(IWineDXGIDevice *iface, REFGUID guid, UINT *data_size, void *data) { - FIXME("iface %p, guid %s, data_size %p, data %p stub!\n", iface, debugstr_guid(guid), data_size, data); + struct dxgi_device *device = impl_from_IWineDXGIDevice(iface); - return E_NOTIMPL; + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return dxgi_get_private_data(&device->private_store, guid, data_size, data); } static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, REFIID riid, void **parent) diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index 655dd404d81..55837f9e6b4 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -76,6 +76,8 @@ const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; DXGI_FORMAT dxgi_format_from_wined3dformat(enum wined3d_format_id format) DECLSPEC_HIDDEN; enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; +HRESULT dxgi_get_private_data(struct wined3d_private_store *store, + REFGUID guid, UINT *data_size, void *data) DECLSPEC_HIDDEN; HRESULT dxgi_set_private_data(struct wined3d_private_store *store, REFGUID guid, UINT data_size, const void *data) DECLSPEC_HIDDEN; HRESULT dxgi_set_private_data_interface(struct wined3d_private_store *store, diff --git a/dlls/dxgi/tests/device.c b/dlls/dxgi/tests/device.c index b00c5e4354b..9181c420f5f 100644 --- a/dlls/dxgi/tests/device.c +++ b/dlls/dxgi/tests/device.c @@ -634,9 +634,9 @@ static void test_private_data(void) size = sizeof(ptr) * 2; ptr = (IUnknown *)0xdeadbeef; hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(!ptr, "Got unexpected pointer %p.\n", ptr); + ok(size == sizeof(IUnknown *), "Got unexpected size %u.\n", size); refcount = get_refcount((IUnknown *)test_object); hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, @@ -677,11 +677,11 @@ static void test_private_data(void) size = 2 * sizeof(ptr); ptr = NULL; hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + 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); + ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); if (ptr) IUnknown_Release(ptr); expected_refcount--; @@ -689,29 +689,29 @@ static void test_private_data(void) ptr = (IUnknown *)0xdeadbeef; size = 1; hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(size == sizeof(device), "Got unexpected size %u.\n", size); size = 2 * sizeof(ptr); hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(size == sizeof(device), "Got unexpected size %u.\n", size); refcount = get_refcount((IUnknown *)test_object); ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); size = 1; hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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(hr == DXGI_ERROR_MORE_DATA, "Got unexpected hr %#x.\n", hr); + ok(size == sizeof(device), "Got unexpected size %u.\n", size); ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid2, NULL, NULL); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); size = 0xdeadbabe; hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_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(hr == DXGI_ERROR_NOT_FOUND, "Got unexpected hr %#x.\n", hr); + ok(size == 0, "Got unexpected size %u.\n", size); ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); hr = IDXGIDevice_GetPrivateData(device, &dxgi_private_data_test_guid, NULL, &ptr); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr); refcount = IDXGIDevice_Release(device); diff --git a/dlls/dxgi/utils.c b/dlls/dxgi/utils.c index 576a9baf8ff..be2b5f7926d 100644 --- a/dlls/dxgi/utils.c +++ b/dlls/dxgi/utils.c @@ -325,6 +325,48 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) } } +HRESULT dxgi_get_private_data(struct wined3d_private_store *store, + REFGUID guid, UINT *data_size, void *data) +{ + const struct wined3d_private_data *stored_data; + DWORD size_in; + HRESULT hr; + + if (!data_size) + return E_INVALIDARG; + + EnterCriticalSection(&dxgi_cs); + if (!(stored_data = wined3d_private_store_get_private_data(store, guid))) + { + hr = DXGI_ERROR_NOT_FOUND; + *data_size = 0; + goto done; + } + + size_in = *data_size; + *data_size = stored_data->size; + if (!data) + { + hr = S_OK; + goto done; + } + if (size_in < stored_data->size) + { + hr = DXGI_ERROR_MORE_DATA; + goto done; + } + + if (stored_data->flags & WINED3DSPD_IUNKNOWN) + IUnknown_AddRef(stored_data->content.object); + memcpy(data, stored_data->content.data, stored_data->size); + hr = S_OK; + +done: + LeaveCriticalSection(&dxgi_cs); + + return hr; +} + HRESULT dxgi_set_private_data(struct wined3d_private_store *store, REFGUID guid, UINT data_size, const void *data) {