Commit 0a9ac7e9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: COM cleanup for the ID3D10Buffer interface.

parent bcd85854
...@@ -24,11 +24,16 @@ ...@@ -24,11 +24,16 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core); WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
static inline struct d3d10_buffer *impl_from_ID3D10Buffer(ID3D10Buffer *iface)
{
return CONTAINING_RECORD(iface, struct d3d10_buffer, ID3D10Buffer_iface);
}
/* IUnknown methods */ /* IUnknown methods */
static HRESULT STDMETHODCALLTYPE d3d10_buffer_QueryInterface(ID3D10Buffer *iface, REFIID riid, void **object) static HRESULT STDMETHODCALLTYPE d3d10_buffer_QueryInterface(ID3D10Buffer *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_ID3D10Buffer) if (IsEqualGUID(riid, &IID_ID3D10Buffer)
|| IsEqualGUID(riid, &IID_ID3D10Resource) || IsEqualGUID(riid, &IID_ID3D10Resource)
...@@ -36,40 +41,38 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_QueryInterface(ID3D10Buffer *iface ...@@ -36,40 +41,38 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_QueryInterface(ID3D10Buffer *iface
|| IsEqualGUID(riid, &IID_IUnknown)) || IsEqualGUID(riid, &IID_IUnknown))
{ {
IUnknown_AddRef(iface); IUnknown_AddRef(iface);
*object = iface; *out = iface;
return S_OK; return S_OK;
} }
WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
*object = NULL; *out = NULL;
return E_NOINTERFACE; return E_NOINTERFACE;
} }
static ULONG STDMETHODCALLTYPE d3d10_buffer_AddRef(ID3D10Buffer *iface) static ULONG STDMETHODCALLTYPE d3d10_buffer_AddRef(ID3D10Buffer *iface)
{ {
struct d3d10_buffer *This = (struct d3d10_buffer *)iface; struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
ULONG refcount = InterlockedIncrement(&This->refcount); ULONG refcount = InterlockedIncrement(&buffer->refcount);
TRACE("%p increasing refcount to %u\n", This, refcount); TRACE("%p increasing refcount to %u.\n", buffer, refcount);
if (refcount == 1) if (refcount == 1)
wined3d_buffer_incref(This->wined3d_buffer); wined3d_buffer_incref(buffer->wined3d_buffer);
return refcount; return refcount;
} }
static ULONG STDMETHODCALLTYPE d3d10_buffer_Release(ID3D10Buffer *iface) static ULONG STDMETHODCALLTYPE d3d10_buffer_Release(ID3D10Buffer *iface)
{ {
struct d3d10_buffer *This = (struct d3d10_buffer *)iface; struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
ULONG refcount = InterlockedDecrement(&This->refcount); ULONG refcount = InterlockedDecrement(&buffer->refcount);
TRACE("%p decreasing refcount to %u\n", This, refcount); TRACE("%p decreasing refcount to %u.\n", buffer, refcount);
if (!refcount) if (!refcount)
{ wined3d_buffer_decref(buffer->wined3d_buffer);
wined3d_buffer_decref(This->wined3d_buffer);
}
return refcount; return refcount;
} }
...@@ -132,7 +135,7 @@ static UINT STDMETHODCALLTYPE d3d10_buffer_GetEvictionPriority(ID3D10Buffer *ifa ...@@ -132,7 +135,7 @@ static UINT STDMETHODCALLTYPE d3d10_buffer_GetEvictionPriority(ID3D10Buffer *ifa
static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP map_type, UINT map_flags, void **data) static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP map_type, UINT map_flags, void **data)
{ {
struct d3d10_buffer *buffer = (struct d3d10_buffer *)iface; struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
TRACE("iface %p, map_type %u, map_flags %#x, data %p.\n", iface, map_type, map_flags, data); TRACE("iface %p, map_type %u, map_flags %#x, data %p.\n", iface, map_type, map_flags, data);
...@@ -146,9 +149,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP ...@@ -146,9 +149,11 @@ static HRESULT STDMETHODCALLTYPE d3d10_buffer_Map(ID3D10Buffer *iface, D3D10_MAP
static void STDMETHODCALLTYPE d3d10_buffer_Unmap(ID3D10Buffer *iface) static void STDMETHODCALLTYPE d3d10_buffer_Unmap(ID3D10Buffer *iface)
{ {
struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_buffer_unmap(((struct d3d10_buffer *)iface)->wined3d_buffer); wined3d_buffer_unmap(buffer->wined3d_buffer);
} }
static void STDMETHODCALLTYPE d3d10_buffer_GetDesc(ID3D10Buffer *iface, D3D10_BUFFER_DESC *desc) static void STDMETHODCALLTYPE d3d10_buffer_GetDesc(ID3D10Buffer *iface, D3D10_BUFFER_DESC *desc)
...@@ -177,6 +182,14 @@ static const struct ID3D10BufferVtbl d3d10_buffer_vtbl = ...@@ -177,6 +182,14 @@ static const struct ID3D10BufferVtbl d3d10_buffer_vtbl =
d3d10_buffer_GetDesc, d3d10_buffer_GetDesc,
}; };
struct d3d10_buffer *unsafe_impl_from_ID3D10Buffer(ID3D10Buffer *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &d3d10_buffer_vtbl);
return CONTAINING_RECORD(iface, struct d3d10_buffer, ID3D10Buffer_iface);
}
static void STDMETHODCALLTYPE d3d10_buffer_wined3d_object_released(void *parent) static void STDMETHODCALLTYPE d3d10_buffer_wined3d_object_released(void *parent)
{ {
HeapFree(GetProcessHeap(), 0, parent); HeapFree(GetProcessHeap(), 0, parent);
...@@ -193,7 +206,7 @@ HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *devi ...@@ -193,7 +206,7 @@ HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *devi
struct wined3d_buffer_desc wined3d_desc; struct wined3d_buffer_desc wined3d_desc;
HRESULT hr; HRESULT hr;
buffer->vtbl = &d3d10_buffer_vtbl; buffer->ID3D10Buffer_iface.lpVtbl = &d3d10_buffer_vtbl;
buffer->refcount = 1; buffer->refcount = 1;
FIXME("Implement DXGI<->wined3d usage conversion\n"); FIXME("Implement DXGI<->wined3d usage conversion\n");
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "wine/debug.h" #include "wine/debug.h"
#include <assert.h>
#define COBJMACROS #define COBJMACROS
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
...@@ -111,7 +113,7 @@ HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_devic ...@@ -111,7 +113,7 @@ HRESULT d3d10_texture3d_init(struct d3d10_texture3d *texture, struct d3d10_devic
/* ID3D10Buffer */ /* ID3D10Buffer */
struct d3d10_buffer struct d3d10_buffer
{ {
const struct ID3D10BufferVtbl *vtbl; ID3D10Buffer ID3D10Buffer_iface;
LONG refcount; LONG refcount;
struct wined3d_buffer *wined3d_buffer; struct wined3d_buffer *wined3d_buffer;
...@@ -119,6 +121,7 @@ struct d3d10_buffer ...@@ -119,6 +121,7 @@ struct d3d10_buffer
HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *device, HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *device,
const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data) DECLSPEC_HIDDEN; const D3D10_BUFFER_DESC *desc, const D3D10_SUBRESOURCE_DATA *data) DECLSPEC_HIDDEN;
struct d3d10_buffer *unsafe_impl_from_ID3D10Buffer(ID3D10Buffer *iface) DECLSPEC_HIDDEN;
/* ID3D10DepthStencilView */ /* ID3D10DepthStencilView */
struct d3d10_depthstencil_view struct d3d10_depthstencil_view
......
...@@ -203,9 +203,10 @@ static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *ifac ...@@ -203,9 +203,10 @@ static void STDMETHODCALLTYPE d3d10_device_IASetVertexBuffers(ID3D10Device *ifac
for (i = 0; i < buffer_count; ++i) for (i = 0; i < buffer_count; ++i)
{ {
struct d3d10_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]);
wined3d_device_set_stream_source(This->wined3d_device, start_slot, wined3d_device_set_stream_source(This->wined3d_device, start_slot,
buffers[i] ? ((struct d3d10_buffer *)buffers[i])->wined3d_buffer : NULL, buffer ? buffer->wined3d_buffer : NULL, offsets[i], strides[i]);
offsets[i], strides[i]);
} }
} }
...@@ -213,12 +214,13 @@ static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface, ...@@ -213,12 +214,13 @@ static void STDMETHODCALLTYPE d3d10_device_IASetIndexBuffer(ID3D10Device *iface,
ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset) ID3D10Buffer *buffer, DXGI_FORMAT format, UINT offset)
{ {
struct d3d10_device *This = impl_from_ID3D10Device(iface); struct d3d10_device *This = impl_from_ID3D10Device(iface);
struct d3d10_buffer *buffer_impl = unsafe_impl_from_ID3D10Buffer(buffer);
TRACE("iface %p, buffer %p, format %s, offset %u.\n", TRACE("iface %p, buffer %p, format %s, offset %u.\n",
iface, buffer, debug_dxgi_format(format), offset); iface, buffer, debug_dxgi_format(format), offset);
wined3d_device_set_index_buffer(This->wined3d_device, wined3d_device_set_index_buffer(This->wined3d_device,
buffer ? ((struct d3d10_buffer *)buffer)->wined3d_buffer : NULL, buffer_impl ? buffer_impl->wined3d_buffer : NULL,
wined3dformat_from_dxgi_format(format)); wined3dformat_from_dxgi_format(format));
if (offset) FIXME("offset %u not supported.\n", offset); if (offset) FIXME("offset %u not supported.\n", offset);
} }
...@@ -644,7 +646,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface, ...@@ -644,7 +646,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device *iface,
return hr; return hr;
} }
*buffer = (ID3D10Buffer *)object; *buffer = &object->ID3D10Buffer_iface;
TRACE("Created ID3D10Buffer %p\n", object); TRACE("Created ID3D10Buffer %p\n", object);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <assert.h>
#include "d3d10core_private.h" #include "d3d10core_private.h"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <assert.h>
#include "d3d10core_private.h" #include "d3d10core_private.h"
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "config.h" #include "config.h"
#include "wine/port.h" #include "wine/port.h"
#include <assert.h>
#define NONAMELESSUNION #define NONAMELESSUNION
#include "d3d10core_private.h" #include "d3d10core_private.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment