d3d9: Implement IDirect3DVertexBuffer9 private data handling on top of wined3d_resource.

This commit is contained in:
Henri Verbeet 2011-06-16 22:38:26 +02:00 committed by Alexandre Julliard
parent 45a0e95962
commit 469eba24c0
9 changed files with 43 additions and 27 deletions

View File

@ -23,6 +23,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
static inline IDirect3DVertexBuffer9Impl *impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface)
{
return CONTAINING_RECORD(iface, IDirect3DVertexBuffer9Impl, lpVtbl);
}
static HRESULT WINAPI d3d9_vertexbuffer_QueryInterface(IDirect3DVertexBuffer9 *iface, REFIID riid, void **object)
{
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
@ -97,14 +102,16 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetDevice(IDirect3DVertexBuffer9 *iface,
static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *iface,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
IDirect3DVertexBuffer9Impl *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();
hr = wined3d_buffer_set_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size, flags);
resource = wined3d_buffer_get_resource(buffer->wineD3DVertexBuffer);
hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
wined3d_mutex_unlock();
return hr;
@ -113,14 +120,16 @@ static HRESULT WINAPI d3d9_vertexbuffer_SetPrivateData(IDirect3DVertexBuffer9 *i
static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *iface,
REFGUID guid, void *data, DWORD *data_size)
{
IDirect3DVertexBuffer9Impl *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();
hr = wined3d_buffer_get_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer,
guid, data, data_size);
resource = wined3d_buffer_get_resource(buffer->wineD3DVertexBuffer);
hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
wined3d_mutex_unlock();
return hr;
@ -128,12 +137,15 @@ static HRESULT WINAPI d3d9_vertexbuffer_GetPrivateData(IDirect3DVertexBuffer9 *i
static HRESULT WINAPI d3d9_vertexbuffer_FreePrivateData(IDirect3DVertexBuffer9 *iface, REFGUID guid)
{
IDirect3DVertexBuffer9Impl *buffer = impl_from_IDirect3DVertexBuffer9(iface);
struct wined3d_resource *resource;
HRESULT hr;
TRACE("iface %p, guid %s.\n", iface, debugstr_guid(guid));
wined3d_mutex_lock();
hr = wined3d_buffer_free_private_data(((IDirect3DVertexBuffer9Impl *)iface)->wineD3DVertexBuffer, guid);
resource = wined3d_buffer_get_resource(buffer->wineD3DVertexBuffer);
hr = wined3d_resource_free_private_data(resource, guid);
wined3d_mutex_unlock();
return hr;

View File

@ -588,18 +588,18 @@ void * CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
HRESULT CDECL wined3d_buffer_set_private_data(struct wined3d_buffer *buffer,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
return wined3d_resource_set_private_data(&buffer->resource, guid, data, data_size, flags);
}
HRESULT CDECL wined3d_buffer_get_private_data(const struct wined3d_buffer *buffer,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&buffer->resource, guid, data, data_size);
return wined3d_resource_get_private_data(&buffer->resource, guid, data, data_size);
}
HRESULT CDECL wined3d_buffer_free_private_data(struct wined3d_buffer *buffer, REFGUID guid)
{
return resource_free_private_data(&buffer->resource, guid);
return wined3d_resource_free_private_data(&buffer->resource, guid);
}
DWORD CDECL wined3d_buffer_set_priority(struct wined3d_buffer *buffer, DWORD priority)

View File

@ -158,7 +158,7 @@ void resource_cleanup(struct wined3d_resource *resource)
LIST_FOR_EACH_SAFE(e1, e2, &resource->privateData)
{
data = LIST_ENTRY(e1, struct private_data, entry);
hr = resource_free_private_data(resource, &data->tag);
hr = wined3d_resource_free_private_data(resource, &data->tag);
if (FAILED(hr))
ERR("Failed to free private data when destroying resource %p, hr = %#x.\n", resource, hr);
}
@ -195,7 +195,7 @@ static struct private_data *resource_find_private_data(const struct wined3d_reso
return NULL;
}
HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID guid,
HRESULT CDECL wined3d_resource_set_private_data(struct wined3d_resource *resource, REFGUID guid,
const void *data, DWORD data_size, DWORD flags)
{
struct private_data *d;
@ -203,7 +203,7 @@ HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID gui
TRACE("resource %p, riid %s, data %p, data_size %u, flags %#x.\n",
resource, debugstr_guid(guid), data, data_size, flags);
resource_free_private_data(resource, guid);
wined3d_resource_free_private_data(resource, guid);
d = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d));
if (!d) return E_OUTOFMEMORY;
@ -239,7 +239,8 @@ HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID gui
return WINED3D_OK;
}
HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid, void *data, DWORD *data_size)
HRESULT CDECL wined3d_resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid,
void *data, DWORD *data_size)
{
const struct private_data *d;
@ -273,7 +274,7 @@ HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGU
return WINED3D_OK;
}
HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid)
HRESULT CDECL wined3d_resource_free_private_data(struct wined3d_resource *resource, REFGUID guid)
{
struct private_data *data;

View File

@ -2707,18 +2707,18 @@ ULONG CDECL wined3d_surface_decref(struct wined3d_surface *surface)
HRESULT CDECL wined3d_surface_set_private_data(struct wined3d_surface *surface,
REFGUID riid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&surface->resource, riid, data, data_size, flags);
return wined3d_resource_set_private_data(&surface->resource, riid, data, data_size, flags);
}
HRESULT CDECL wined3d_surface_get_private_data(const struct wined3d_surface *surface,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&surface->resource, guid, data, data_size);
return wined3d_resource_get_private_data(&surface->resource, guid, data, data_size);
}
HRESULT CDECL wined3d_surface_free_private_data(struct wined3d_surface *surface, REFGUID refguid)
{
return resource_free_private_data(&surface->resource, refguid);
return wined3d_resource_free_private_data(&surface->resource, refguid);
}
DWORD CDECL wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD priority)

View File

@ -453,18 +453,18 @@ ULONG CDECL wined3d_texture_decref(struct wined3d_texture *texture)
HRESULT CDECL wined3d_texture_set_private_data(struct wined3d_texture *texture,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&texture->resource, guid, data, data_size, flags);
return wined3d_resource_set_private_data(&texture->resource, guid, data, data_size, flags);
}
HRESULT CDECL wined3d_texture_get_private_data(const struct wined3d_texture *texture,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&texture->resource, guid, data, data_size);
return wined3d_resource_get_private_data(&texture->resource, guid, data, data_size);
}
HRESULT CDECL wined3d_texture_free_private_data(struct wined3d_texture *texture, REFGUID guid)
{
return resource_free_private_data(&texture->resource, guid);
return wined3d_resource_free_private_data(&texture->resource, guid);
}
DWORD CDECL wined3d_texture_set_priority(struct wined3d_texture *texture, DWORD priority)

View File

@ -176,18 +176,18 @@ void * CDECL wined3d_volume_get_parent(const struct wined3d_volume *volume)
HRESULT CDECL wined3d_volume_set_private_data(struct wined3d_volume *volume,
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
{
return resource_set_private_data(&volume->resource, guid, data, data_size, flags);
return wined3d_resource_set_private_data(&volume->resource, guid, data, data_size, flags);
}
HRESULT CDECL wined3d_volume_get_private_data(const struct wined3d_volume *volume,
REFGUID guid, void *data, DWORD *data_size)
{
return resource_get_private_data(&volume->resource, guid, data, data_size);
return wined3d_resource_get_private_data(&volume->resource, guid, data, data_size);
}
HRESULT CDECL wined3d_volume_free_private_data(struct wined3d_volume *volume, REFGUID guid)
{
return resource_free_private_data(&volume->resource, guid);
return wined3d_resource_free_private_data(&volume->resource, guid);
}
DWORD CDECL wined3d_volume_set_priority(struct wined3d_volume *volume, DWORD priority)

View File

@ -180,8 +180,11 @@
@ cdecl wined3d_query_incref(ptr)
@ cdecl wined3d_query_issue(ptr long)
@ cdecl wined3d_resource_free_private_data(ptr ptr)
@ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_resource_get_private_data(ptr ptr ptr ptr)
@ cdecl wined3d_resource_set_private_data(ptr ptr ptr long long)
@ cdecl wined3d_rendertarget_view_create(ptr ptr ptr)
@ cdecl wined3d_rendertarget_view_decref(ptr)

View File

@ -1850,10 +1850,7 @@ struct wined3d_resource
};
void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_free_private_data(struct wined3d_resource *resource, REFGUID guid) DECLSPEC_HIDDEN;
DWORD resource_get_priority(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
HRESULT resource_get_private_data(const struct wined3d_resource *resource, REFGUID guid,
void *data, DWORD *data_size) DECLSPEC_HIDDEN;
HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
WINED3DRESOURCETYPE resource_type, const struct wined3d_format *format,
WINED3DMULTISAMPLE_TYPE multisample_type, UINT multisample_quality,
@ -1861,8 +1858,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) DECLSPEC_HIDDEN;
HRESULT resource_set_private_data(struct wined3d_resource *resource, REFGUID guid,
const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
/* Tests show that the start address of resources is 32 byte aligned */

View File

@ -2375,9 +2375,14 @@ WINED3DQUERYTYPE __cdecl wined3d_query_get_type(const struct wined3d_query *quer
ULONG __cdecl wined3d_query_incref(struct wined3d_query *query);
HRESULT __cdecl wined3d_query_issue(struct wined3d_query *query, DWORD flags);
HRESULT __cdecl wined3d_resource_free_private_data(struct wined3d_resource *resource, REFGUID guid);
void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
struct wined3d_resource_desc *desc);
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
HRESULT __cdecl wined3d_resource_get_private_data(const struct wined3d_resource *resource,
REFGUID guid, void *data, DWORD *data_size);
HRESULT __cdecl wined3d_resource_set_private_data(struct wined3d_resource *resource,
REFGUID guid, const void *data, DWORD data_size, DWORD flags);
HRESULT __cdecl wined3d_rendertarget_view_create(struct wined3d_resource *resource,
void *parent, struct wined3d_rendertarget_view **rendertarget_view);