d3d10core: Implement d3d10_texture2d_SetPrivateData().

This commit is contained in:
Henri Verbeet 2015-02-23 17:59:42 +01:00 committed by Alexandre Julliard
parent 34f4c407b2
commit c2e6a7d0b1
4 changed files with 72 additions and 2 deletions

View file

@ -66,6 +66,9 @@ DWORD wined3d_usage_from_d3d10core(UINT bind_flags, enum D3D10_USAGE usage) DECL
struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN;
DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type) DECLSPEC_HIDDEN;
HRESULT d3d10_set_private_data(struct wined3d_private_store *store,
REFGUID guid, UINT data_size, const void *data) DECLSPEC_HIDDEN;
static inline void read_dword(const char **ptr, DWORD *d)
{
memcpy(d, *ptr, sizeof(*d));
@ -83,6 +86,7 @@ struct d3d10_texture2d
ID3D10Texture2D ID3D10Texture2D_iface;
LONG refcount;
struct wined3d_private_store private_store;
IUnknown *dxgi_surface;
struct wined3d_texture *wined3d_texture;
D3D10_TEXTURE2D_DESC desc;

View file

@ -2521,9 +2521,12 @@ static void test_texture(void)
static void test_private_data(void)
{
D3D10_TEXTURE2D_DESC texture_desc;
ULONG refcount, expected_refcount;
ID3D10Device *test_object;
ID3D10Texture2D *texture;
IDXGIDevice *dxgi_device;
IDXGISurface *surface;
ID3D10Device *device;
IUnknown *ptr;
HRESULT hr;
@ -2543,6 +2546,23 @@ static void test_private_data(void)
test_object = create_device();
texture_desc.Width = 512;
texture_desc.Height = 512;
texture_desc.MipLevels = 1;
texture_desc.ArraySize = 1;
texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texture_desc.SampleDesc.Count = 1;
texture_desc.SampleDesc.Quality = 0;
texture_desc.Usage = D3D10_USAGE_DEFAULT;
texture_desc.BindFlags = D3D10_BIND_RENDER_TARGET;
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
hr = ID3D10Device_CreateTexture2D(device, &texture_desc, NULL, &texture);
ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr);
hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface, (void **)&surface);
ok(SUCCEEDED(hr), "Failed to get IDXGISurface, hr %#x.\n", hr);
/* 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
@ -2651,6 +2671,18 @@ static void test_private_data(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
ok(ptr == (IUnknown *)0xdeadbeef, "Got unexpected pointer %p.\n", ptr);
hr = ID3D10Texture2D_SetPrivateDataInterface(texture, &test_guid, (IUnknown *)test_object);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
ptr = NULL;
size = sizeof(ptr);
hr = IDXGISurface_GetPrivateData(surface, &test_guid, &size, &ptr);
todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo_wine ok(ptr == (IUnknown *)test_object, "Got unexpected ptr %p, expected %p.\n", ptr, test_object);
if (ptr)
IUnknown_Release(ptr);
IDXGISurface_Release(surface);
ID3D10Texture2D_Release(texture);
refcount = ID3D10Device_Release(device);
ok(!refcount, "Device has %u references left.\n", refcount);
refcount = ID3D10Device_Release(test_object);

View file

@ -80,6 +80,7 @@ static void STDMETHODCALLTYPE d3d10_texture2d_wined3d_object_released(void *pare
struct d3d10_texture2d *This = parent;
if (This->dxgi_surface) IUnknown_Release(This->dxgi_surface);
wined3d_private_store_cleanup(&This->private_store);
HeapFree(GetProcessHeap(), 0, This);
}
@ -127,10 +128,22 @@ static HRESULT STDMETHODCALLTYPE d3d10_texture2d_GetPrivateData(ID3D10Texture2D
static HRESULT STDMETHODCALLTYPE d3d10_texture2d_SetPrivateData(ID3D10Texture2D *iface,
REFGUID guid, UINT data_size, const void *data)
{
FIXME("iface %p, guid %s, data_size %u, data %p stub!\n",
struct d3d10_texture2d *texture = impl_from_ID3D10Texture2D(iface);
IDXGISurface *dxgi_surface;
HRESULT hr;
TRACE("iface %p, guid %s, data_size %u, data %p.\n",
iface, debugstr_guid(guid), data_size, data);
return E_NOTIMPL;
if (texture->dxgi_surface
&& SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface)))
{
hr = IDXGISurface_SetPrivateData(dxgi_surface, guid, data_size, data);
IDXGISurface_Release(dxgi_surface);
return hr;
}
return d3d10_set_private_data(&texture->private_store, guid, data_size, data);
}
static HRESULT STDMETHODCALLTYPE d3d10_texture2d_SetPrivateDataInterface(ID3D10Texture2D *iface,
@ -256,6 +269,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl;
texture->refcount = 1;
wined3d_private_store_init(&texture->private_store);
texture->desc = *desc;
if (desc->MipLevels == 1 && desc->ArraySize == 1)
@ -267,6 +281,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
(void **)&wine_device)))
{
ERR("Device should implement IWineDXGIDevice.\n");
wined3d_private_store_cleanup(&texture->private_store);
return E_FAIL;
}
@ -281,6 +296,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
if (FAILED(hr))
{
ERR("Failed to create DXGI surface, returning %#x\n", hr);
wined3d_private_store_cleanup(&texture->private_store);
return hr;
}
}
@ -310,6 +326,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
WARN("Failed to create wined3d texture, hr %#x.\n", hr);
if (texture->dxgi_surface)
IUnknown_Release(texture->dxgi_surface);
wined3d_private_store_cleanup(&texture->private_store);
return hr;
}
texture->desc.MipLevels = levels;

View file

@ -411,6 +411,23 @@ DWORD wined3d_map_flags_from_d3d10_map_type(D3D10_MAP map_type)
}
}
HRESULT d3d10_set_private_data(struct wined3d_private_store *store,
REFGUID guid, UINT data_size, const void *data)
{
struct wined3d_private_data *entry;
if (!data)
{
if (!(entry = wined3d_private_store_get_private_data(store, guid)))
return S_FALSE;
wined3d_private_store_free_private_data(store, entry);
return S_OK;
}
return wined3d_private_store_set_private_data(store, guid, data, data_size, 0);
}
void skip_dword_unknown(const char **ptr, unsigned int count)
{
unsigned int i;