d3d8: Use the private store api for buffers.

This commit is contained in:
Stefan Dösinger 2014-03-21 11:46:20 +01:00 committed by Alexandre Julliard
parent 97b5525888
commit 1db2bdcf8a
3 changed files with 81 additions and 54 deletions

View file

@ -104,52 +104,28 @@ static HRESULT WINAPI d3d8_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer8 *i
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
}
static HRESULT WINAPI d3d8_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer8 *iface,
REFGUID guid, void *data, DWORD *data_size)
{
struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_get_private_data(&buffer->resource, guid, data, data_size);
}
static HRESULT WINAPI d3d8_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer8 *iface, REFGUID guid)
{
struct d3d8_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_free_private_data(resource, guid);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_free_private_data(&buffer->resource, guid);
}
static DWORD WINAPI d3d8_vertexbuffer_SetPriority(IDirect3DVertexBuffer8 *iface, DWORD priority)
@ -401,52 +377,28 @@ static HRESULT WINAPI d3d8_indexbuffer_SetPrivateData(IDirect3DIndexBuffer8 *ifa
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %u, flags %#x.\n",
iface, debugstr_guid(guid), data, data_size, flags);
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
}
static HRESULT WINAPI d3d8_indexbuffer_GetPrivateData(IDirect3DIndexBuffer8 *iface,
REFGUID guid, void *data, DWORD *data_size)
{
struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s, data %p, data_size %p.\n",
iface, debugstr_guid(guid), data, data_size);
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_get_private_data(&buffer->resource, guid, data, data_size);
}
static HRESULT WINAPI d3d8_indexbuffer_FreePrivateData(IDirect3DIndexBuffer8 *iface, REFGUID guid)
{
struct d3d8_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer8(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
hr = wined3d_resource_free_private_data(resource, guid);
wined3d_mutex_unlock();
return hr;
return d3d8_resource_free_private_data(&buffer->resource, guid);
}
static DWORD WINAPI d3d8_indexbuffer_SetPriority(IDirect3DIndexBuffer8 *iface, DWORD priority)

View file

@ -140,9 +140,78 @@ HRESULT WINAPI ValidatePixelShader(DWORD* pixelshader, DWORD* reserved1, BOOL bo
void d3d8_resource_cleanup(struct d3d8_resource *resource)
{
wined3d_private_store_cleanup(&resource->private_store);
}
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid)
{
struct wined3d_private_data *entry;
wined3d_mutex_lock();
entry = wined3d_private_store_get_private_data(&resource->private_store, guid);
if (!entry)
{
wined3d_mutex_unlock();
return D3DERR_NOTFOUND;
}
wined3d_private_store_free_private_data(&resource->private_store, entry);
wined3d_mutex_unlock();
return D3D_OK;
}
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid,
void *data, DWORD *data_size)
{
const struct wined3d_private_data *stored_data;
DWORD size_in;
HRESULT hr;
wined3d_mutex_lock();
stored_data = wined3d_private_store_get_private_data(&resource->private_store, guid);
if (!stored_data)
{
hr = D3DERR_NOTFOUND;
goto done;
}
size_in = *data_size;
*data_size = stored_data->size;
if (!data)
{
hr = D3D_OK;
goto done;
}
if (size_in < stored_data->size)
{
hr = D3DERR_MOREDATA;
goto done;
}
if (stored_data->flags & WINED3DSPD_IUNKNOWN)
IUnknown_AddRef(stored_data->content.object);
memcpy(data, stored_data->content.data, stored_data->size);
hr = D3D_OK;
done:
wined3d_mutex_unlock();
return hr;
}
void d3d8_resource_init(struct d3d8_resource *resource)
{
resource->refcount = 1;
wined3d_private_store_init(&resource->private_store);
}
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid,
const void *data, DWORD data_size, DWORD flags)
{
HRESULT hr;
wined3d_mutex_lock();
hr = wined3d_private_store_set_private_data(&resource->private_store, guid, data, data_size, flags);
wined3d_mutex_unlock();
return hr;
}

View file

@ -177,10 +177,16 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
struct d3d8_resource
{
LONG refcount;
struct wined3d_private_store private_store;
};
void d3d8_resource_cleanup(struct d3d8_resource *resource) DECLSPEC_HIDDEN;
HRESULT d3d8_resource_free_private_data(struct d3d8_resource *resource, const GUID *guid) DECLSPEC_HIDDEN;
HRESULT d3d8_resource_get_private_data(struct d3d8_resource *resource, const GUID *guid,
void *data, DWORD *data_size) DECLSPEC_HIDDEN;
void d3d8_resource_init(struct d3d8_resource *resource) DECLSPEC_HIDDEN;
HRESULT d3d8_resource_set_private_data(struct d3d8_resource *resource, const GUID *guid,
const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
struct d3d8_volume
{