d3d9: Use the private store api for buffers.
This commit is contained in:
parent
96a74e0cf7
commit
f2b5bf26b7
|
@ -105,52 +105,28 @@ static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *i
|
|||
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
|
||||
{
|
||||
struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(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 d3d9_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *iface,
|
||||
REFGUID guid, void *data, DWORD *data_size)
|
||||
{
|
||||
struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(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 d3d9_resource_get_private_data(&buffer->resource, guid, data, data_size);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *iface, REFGUID guid)
|
||||
{
|
||||
struct d3d9_vertexbuffer *buffer = impl_from_IDirect3DVertexBuffer9(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 d3d9_resource_free_private_data(&buffer->resource, guid);
|
||||
}
|
||||
|
||||
static DWORD WINAPI d3d9_vertexbuffer_SetPriority(IDirect3DVertexBuffer9 *iface, DWORD priority)
|
||||
|
@ -401,52 +377,28 @@ static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *ifa
|
|||
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
|
||||
{
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *iface,
|
||||
REFGUID guid, void *data, DWORD *data_size)
|
||||
{
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_resource_get_private_data(&buffer->resource, guid, data, data_size);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *iface, REFGUID guid)
|
||||
{
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(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 d3d9_resource_free_private_data(&buffer->resource, guid);
|
||||
}
|
||||
|
||||
static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, DWORD priority)
|
||||
|
|
|
@ -165,9 +165,78 @@ void WINAPI D3DPERF_SetRegion(D3DCOLOR color, const WCHAR *name)
|
|||
|
||||
void d3d9_resource_cleanup(struct d3d9_resource *resource)
|
||||
{
|
||||
wined3d_private_store_cleanup(&resource->private_store);
|
||||
}
|
||||
|
||||
HRESULT d3d9_resource_free_private_data(struct d3d9_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 d3d9_resource_get_private_data(struct d3d9_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 d3d9_resource_init(struct d3d9_resource *resource)
|
||||
{
|
||||
resource->refcount = 1;
|
||||
wined3d_private_store_init(&resource->private_store);
|
||||
}
|
||||
|
||||
HRESULT d3d9_resource_set_private_data(struct d3d9_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;
|
||||
}
|
||||
|
|
|
@ -169,10 +169,16 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
|
|||
struct d3d9_resource
|
||||
{
|
||||
LONG refcount;
|
||||
struct wined3d_private_store private_store;
|
||||
};
|
||||
|
||||
void d3d9_resource_cleanup(struct d3d9_resource *resource) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d9_resource_free_private_data(struct d3d9_resource *resource, const GUID *guid) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d9_resource_get_private_data(struct d3d9_resource *resource, const GUID *guid,
|
||||
void *data, DWORD *data_size) DECLSPEC_HIDDEN;
|
||||
void d3d9_resource_init(struct d3d9_resource *resource) DECLSPEC_HIDDEN;
|
||||
HRESULT d3d9_resource_set_private_data(struct d3d9_resource *resource, const GUID *guid,
|
||||
const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
|
||||
|
||||
struct d3d9_volume
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue