dxgi: Implement dxgi_device_GetPrivateData().

This commit is contained in:
Henri Verbeet 2015-02-12 09:34:59 +01:00 committed by Alexandre Julliard
parent 2190f0266f
commit 2d18cf57ac
4 changed files with 64 additions and 18 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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);

View File

@ -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)
{