d3d9: Get rid of IDirect3DIndexBuffer9Impl.
This commit is contained in:
parent
503b16392b
commit
6341389fe4
|
@ -317,42 +317,42 @@ struct d3d9_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer9(IDirect3DVerte
|
|||
return impl_from_IDirect3DVertexBuffer9(iface);
|
||||
}
|
||||
|
||||
static inline IDirect3DIndexBuffer9Impl *impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
|
||||
static inline struct d3d9_indexbuffer *impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, IDirect3DIndexBuffer9Impl, IDirect3DIndexBuffer9_iface);
|
||||
return CONTAINING_RECORD(iface, struct d3d9_indexbuffer, IDirect3DIndexBuffer9_iface);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_QueryInterface(IDirect3DIndexBuffer9 *iface, REFIID riid, void **object)
|
||||
static HRESULT WINAPI d3d9_indexbuffer_QueryInterface(IDirect3DIndexBuffer9 *iface, REFIID riid, void **out)
|
||||
{
|
||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
||||
TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IDirect3DIndexBuffer9)
|
||||
|| IsEqualGUID(riid, &IID_IDirect3DResource9)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
IDirect3DIndexBuffer9_AddRef(iface);
|
||||
*object = iface;
|
||||
*out = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||
|
||||
*object = NULL;
|
||||
*out = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI d3d9_indexbuffer_AddRef(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
ULONG refcount = InterlockedIncrement(&buffer->ref);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
ULONG refcount = InterlockedIncrement(&buffer->refcount);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", iface, refcount);
|
||||
|
||||
if (refcount == 1)
|
||||
{
|
||||
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
|
||||
IDirect3DDevice9Ex_AddRef(buffer->parent_device);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_buffer_incref(buffer->wineD3DIndexBuffer);
|
||||
wined3d_buffer_incref(buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
|
@ -361,17 +361,17 @@ static ULONG WINAPI d3d9_indexbuffer_AddRef(IDirect3DIndexBuffer9 *iface)
|
|||
|
||||
static ULONG WINAPI d3d9_indexbuffer_Release(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
ULONG refcount = InterlockedDecrement(&buffer->ref);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
ULONG refcount = InterlockedDecrement(&buffer->refcount);
|
||||
|
||||
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
IDirect3DDevice9Ex *device = buffer->parentDevice;
|
||||
IDirect3DDevice9Ex *device = buffer->parent_device;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_buffer_decref(buffer->wineD3DIndexBuffer);
|
||||
wined3d_buffer_decref(buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
/* Release the device last, as it may cause the device to be destroyed. */
|
||||
|
@ -381,14 +381,13 @@ static ULONG WINAPI d3d9_indexbuffer_Release(IDirect3DIndexBuffer9 *iface)
|
|||
return refcount;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_GetDevice(IDirect3DIndexBuffer9 *iface,
|
||||
IDirect3DDevice9 **device)
|
||||
static HRESULT WINAPI d3d9_indexbuffer_GetDevice(IDirect3DIndexBuffer9 *iface, IDirect3DDevice9 **device)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
|
||||
TRACE("iface %p, device %p.\n", iface, device);
|
||||
|
||||
*device = (IDirect3DDevice9 *)buffer->parentDevice;
|
||||
*device = (IDirect3DDevice9 *)buffer->parent_device;
|
||||
IDirect3DDevice9_AddRef(*device);
|
||||
|
||||
TRACE("Returning device %p.\n", *device);
|
||||
|
@ -399,7 +398,7 @@ static HRESULT WINAPI d3d9_indexbuffer_GetDevice(IDirect3DIndexBuffer9 *iface,
|
|||
static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *iface,
|
||||
REFGUID guid, const void *data, DWORD data_size, DWORD flags)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct wined3d_resource *resource;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -407,7 +406,7 @@ static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *ifa
|
|||
iface, debugstr_guid(guid), data, data_size, flags);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
resource = wined3d_buffer_get_resource(buffer->wineD3DIndexBuffer);
|
||||
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
|
||||
hr = wined3d_resource_set_private_data(resource, guid, data, data_size, flags);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -417,7 +416,7 @@ static HRESULT WINAPI d3d9_indexbuffer_SetPrivateData(IDirect3DIndexBuffer9 *ifa
|
|||
static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *iface,
|
||||
REFGUID guid, void *data, DWORD *data_size)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct wined3d_resource *resource;
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -425,7 +424,7 @@ static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *ifa
|
|||
iface, debugstr_guid(guid), data, data_size);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
resource = wined3d_buffer_get_resource(buffer->wineD3DIndexBuffer);
|
||||
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
|
||||
hr = wined3d_resource_get_private_data(resource, guid, data, data_size);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -434,14 +433,14 @@ static HRESULT WINAPI d3d9_indexbuffer_GetPrivateData(IDirect3DIndexBuffer9 *ifa
|
|||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *iface, REFGUID guid)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
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->wineD3DIndexBuffer);
|
||||
resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
|
||||
hr = wined3d_resource_free_private_data(resource, guid);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -450,13 +449,13 @@ static HRESULT WINAPI d3d9_indexbuffer_FreePrivateData(IDirect3DIndexBuffer9 *if
|
|||
|
||||
static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, DWORD priority)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
DWORD previous;
|
||||
|
||||
TRACE("iface %p, priority %u.\n", iface, priority);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
previous = wined3d_buffer_set_priority(buffer->wineD3DIndexBuffer, priority);
|
||||
previous = wined3d_buffer_set_priority(buffer->wined3d_buffer, priority);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return previous;
|
||||
|
@ -464,13 +463,13 @@ static DWORD WINAPI d3d9_indexbuffer_SetPriority(IDirect3DIndexBuffer9 *iface, D
|
|||
|
||||
static DWORD WINAPI d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
DWORD priority;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
priority = wined3d_buffer_get_priority(buffer->wineD3DIndexBuffer);
|
||||
priority = wined3d_buffer_get_priority(buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return priority;
|
||||
|
@ -478,12 +477,12 @@ static DWORD WINAPI d3d9_indexbuffer_GetPriority(IDirect3DIndexBuffer9 *iface)
|
|||
|
||||
static void WINAPI d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_buffer_preload(buffer->wineD3DIndexBuffer);
|
||||
wined3d_buffer_preload(buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
}
|
||||
|
||||
|
@ -497,14 +496,14 @@ static D3DRESOURCETYPE WINAPI d3d9_indexbuffer_GetType(IDirect3DIndexBuffer9 *if
|
|||
static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
|
||||
UINT offset, UINT size, void **data, DWORD flags)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, offset %u, size %u, data %p, flags %#x.\n",
|
||||
iface, offset, size, data, flags);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_buffer_map(buffer->wineD3DIndexBuffer, offset, size, (BYTE **)data, flags);
|
||||
hr = wined3d_buffer_map(buffer->wined3d_buffer, offset, size, (BYTE **)data, flags);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
|
@ -512,28 +511,27 @@ static HRESULT WINAPI d3d9_indexbuffer_Lock(IDirect3DIndexBuffer9 *iface,
|
|||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_Unlock(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_buffer_unmap(buffer->wineD3DIndexBuffer);
|
||||
wined3d_buffer_unmap(buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface,
|
||||
D3DINDEXBUFFER_DESC *desc)
|
||||
static HRESULT WINAPI d3d9_indexbuffer_GetDesc(IDirect3DIndexBuffer9 *iface, D3DINDEXBUFFER_DESC *desc)
|
||||
{
|
||||
IDirect3DIndexBuffer9Impl *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct d3d9_indexbuffer *buffer = impl_from_IDirect3DIndexBuffer9(iface);
|
||||
struct wined3d_resource_desc wined3d_desc;
|
||||
struct wined3d_resource *wined3d_resource;
|
||||
|
||||
TRACE("iface %p, desc %p.\n", iface, desc);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
wined3d_resource = wined3d_buffer_get_resource(buffer->wineD3DIndexBuffer);
|
||||
wined3d_resource = wined3d_buffer_get_resource(buffer->wined3d_buffer);
|
||||
wined3d_resource_get_desc(wined3d_resource, &wined3d_desc);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -577,18 +575,18 @@ static const struct wined3d_parent_ops d3d9_indexbuffer_wined3d_parent_ops =
|
|||
d3d9_indexbuffer_wined3d_object_destroyed,
|
||||
};
|
||||
|
||||
HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, struct d3d9_device *device,
|
||||
HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device,
|
||||
UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
buffer->IDirect3DIndexBuffer9_iface.lpVtbl = &d3d9_indexbuffer_vtbl;
|
||||
buffer->ref = 1;
|
||||
buffer->refcount = 1;
|
||||
buffer->format = wined3dformat_from_d3dformat(format);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_buffer_create_ib(device->wined3d_device, size, usage & WINED3DUSAGE_MASK,
|
||||
(enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wineD3DIndexBuffer);
|
||||
(enum wined3d_pool)pool, buffer, &d3d9_indexbuffer_wined3d_parent_ops, &buffer->wined3d_buffer);
|
||||
wined3d_mutex_unlock();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
|
@ -596,13 +594,13 @@ HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, struct d3d9_device *
|
|||
return hr;
|
||||
}
|
||||
|
||||
buffer->parentDevice = &device->IDirect3DDevice9Ex_iface;
|
||||
IDirect3DDevice9Ex_AddRef(buffer->parentDevice);
|
||||
buffer->parent_device = &device->IDirect3DDevice9Ex_iface;
|
||||
IDirect3DDevice9Ex_AddRef(buffer->parent_device);
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
||||
IDirect3DIndexBuffer9Impl *unsafe_impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
|
||||
struct d3d9_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface)
|
||||
{
|
||||
if (!iface)
|
||||
return NULL;
|
||||
|
|
|
@ -216,25 +216,18 @@ HRESULT vertexbuffer_init(struct d3d9_vertexbuffer *buffer, struct d3d9_device *
|
|||
UINT size, UINT usage, DWORD fvf, D3DPOOL pool) DECLSPEC_HIDDEN;
|
||||
struct d3d9_vertexbuffer *unsafe_impl_from_IDirect3DVertexBuffer9(IDirect3DVertexBuffer9 *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
/* --------------------- */
|
||||
/* IDirect3DIndexBuffer9 */
|
||||
/* --------------------- */
|
||||
|
||||
/*****************************************************************************
|
||||
* IDirect3DIndexBuffer9 implementation structure
|
||||
*/
|
||||
typedef struct IDirect3DIndexBuffer9Impl
|
||||
struct d3d9_indexbuffer
|
||||
{
|
||||
IDirect3DIndexBuffer9 IDirect3DIndexBuffer9_iface;
|
||||
LONG ref;
|
||||
struct wined3d_buffer *wineD3DIndexBuffer;
|
||||
IDirect3DDevice9Ex *parentDevice;
|
||||
LONG refcount;
|
||||
struct wined3d_buffer *wined3d_buffer;
|
||||
IDirect3DDevice9Ex *parent_device;
|
||||
enum wined3d_format_id format;
|
||||
} IDirect3DIndexBuffer9Impl;
|
||||
};
|
||||
|
||||
HRESULT indexbuffer_init(IDirect3DIndexBuffer9Impl *buffer, struct d3d9_device *device,
|
||||
HRESULT indexbuffer_init(struct d3d9_indexbuffer *buffer, struct d3d9_device *device,
|
||||
UINT size, DWORD usage, D3DFORMAT format, D3DPOOL pool) DECLSPEC_HIDDEN;
|
||||
IDirect3DIndexBuffer9Impl *unsafe_impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface) DECLSPEC_HIDDEN;
|
||||
struct d3d9_indexbuffer *unsafe_impl_from_IDirect3DIndexBuffer9(IDirect3DIndexBuffer9 *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
struct d3d9_texture
|
||||
{
|
||||
|
|
|
@ -831,7 +831,7 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
|
|||
HANDLE *shared_handle)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
IDirect3DIndexBuffer9Impl *object;
|
||||
struct d3d9_indexbuffer *object;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, size %u, usage %#x, format %#x, pool %#x, buffer %p, shared_handle %p.\n",
|
||||
|
@ -2497,14 +2497,14 @@ static HRESULT WINAPI d3d9_device_GetStreamSourceFreq(IDirect3DDevice9Ex *iface,
|
|||
static HRESULT WINAPI d3d9_device_SetIndices(IDirect3DDevice9Ex *iface, IDirect3DIndexBuffer9 *buffer)
|
||||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
IDirect3DIndexBuffer9Impl *ib = unsafe_impl_from_IDirect3DIndexBuffer9(buffer);
|
||||
struct d3d9_indexbuffer *ib = unsafe_impl_from_IDirect3DIndexBuffer9(buffer);
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, buffer %p.\n", iface, buffer);
|
||||
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_device_set_index_buffer(device->wined3d_device,
|
||||
ib ? ib->wineD3DIndexBuffer : NULL,
|
||||
ib ? ib->wined3d_buffer : NULL,
|
||||
ib ? ib->format : WINED3DFMT_UNKNOWN);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
|
@ -2515,7 +2515,7 @@ static HRESULT WINAPI d3d9_device_GetIndices(IDirect3DDevice9Ex *iface, IDirect3
|
|||
{
|
||||
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
|
||||
struct wined3d_buffer *retIndexData = NULL;
|
||||
IDirect3DIndexBuffer9Impl *buffer_impl;
|
||||
struct d3d9_indexbuffer *buffer_impl;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, buffer %p.\n", iface, buffer);
|
||||
|
|
Loading…
Reference in New Issue