dxgi: Implement dxgi_device_SetPrivateData().

This commit is contained in:
Henri Verbeet 2015-02-12 09:34:57 +01:00 committed by Alexandre Julliard
parent e7b7d1ef45
commit 4e93a02aaf
4 changed files with 47 additions and 7 deletions

View File

@ -84,6 +84,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
wined3d_device_decref(This->wined3d_device);
LeaveCriticalSection(&dxgi_cs);
IDXGIFactory1_Release(This->factory);
wined3d_private_store_cleanup(&This->private_store);
HeapFree(GetProcessHeap(), 0, This);
}
@ -95,9 +96,11 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateData(IWineDXGIDevice *iface,
REFGUID guid, UINT data_size, const void *data)
{
FIXME("iface %p, guid %s, data_size %u, 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 %u, data %p.\n", iface, debugstr_guid(guid), data_size, data);
return dxgi_set_private_data(&device->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE dxgi_device_SetPrivateDataInterface(IWineDXGIDevice *iface,
@ -357,6 +360,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
device->refcount = 1;
wined3d_private_store_init(&device->private_store);
layer_base = device + 1;
@ -364,6 +368,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
device, &IID_IUnknown, (void **)&device->child_layer)))
{
WARN("Failed to create device, returning %#x.\n", hr);
wined3d_private_store_cleanup(&device->private_store);
return hr;
}
@ -372,6 +377,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
{
ERR("DXGI device should implement IWineD3DDeviceParent.\n");
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
return hr;
}
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
@ -386,6 +392,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
if (SUCCEEDED(hr))
hr = E_FAIL;
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
return hr;
}
@ -397,6 +404,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
{
WARN("Failed to create a wined3d device, returning %#x.\n", hr);
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
return hr;
}
@ -409,6 +417,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
ERR("Failed to initialize 3D, hr %#x.\n", hr);
wined3d_device_decref(device->wined3d_device);
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
return hr;
}

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_set_private_data(struct wined3d_private_store *store,
REFGUID guid, UINT data_size, const void *data) DECLSPEC_HIDDEN;
/* IDXGIFactory */
struct dxgi_factory
@ -99,6 +101,7 @@ struct dxgi_device
IWineDXGIDevice IWineDXGIDevice_iface;
IUnknown *child_layer;
LONG refcount;
struct wined3d_private_store private_store;
struct wined3d_device *wined3d_device;
IDXGIFactory1 *factory;
};

View File

@ -621,13 +621,13 @@ static void test_private_data(void)
* NULL interface is not considered a clear but as setting an interface pointer that
* happens to be NULL. */
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 0, NULL);
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, ~0U, NULL);
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid, NULL);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
@ -662,13 +662,13 @@ static void test_private_data(void)
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
size = sizeof(data);
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, size, data);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
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 = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateData(device, &dxgi_private_data_test_guid, 42, NULL);
todo_wine ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
ok(hr == S_FALSE, "Got unexpected hr %#x.\n", hr);
hr = IDXGIDevice_SetPrivateDataInterface(device, &dxgi_private_data_test_guid,
(IUnknown *)test_object);

View File

@ -324,3 +324,31 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format)
return WINED3DFMT_UNKNOWN;
}
}
HRESULT dxgi_set_private_data(struct wined3d_private_store *store,
REFGUID guid, UINT data_size, const void *data)
{
struct wined3d_private_data *entry;
HRESULT hr;
if (!data)
{
EnterCriticalSection(&dxgi_cs);
if (!(entry = wined3d_private_store_get_private_data(store, guid)))
{
LeaveCriticalSection(&dxgi_cs);
return S_FALSE;
}
wined3d_private_store_free_private_data(store, entry);
LeaveCriticalSection(&dxgi_cs);
return S_OK;
}
EnterCriticalSection(&dxgi_cs);
hr = wined3d_private_store_set_private_data(store, guid, data, data_size, 0);
LeaveCriticalSection(&dxgi_cs);
return hr;
}