[PATCH 4/9] d3d10core: Implement d3d10_buffer_GetDevice().
Henri Verbeet
hverbeet at codeweavers.com
Thu Feb 13 03:14:21 CST 2014
---
dlls/d3d10core/buffer.c | 20 +++++++++++++++++++-
dlls/d3d10core/d3d10core_private.h | 1 +
dlls/d3d10core/tests/device.c | 14 ++++++++++++--
3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d10core/buffer.c b/dlls/d3d10core/buffer.c
index 90ff0e8..b9ac6e1 100644
--- a/dlls/d3d10core/buffer.c
+++ b/dlls/d3d10core/buffer.c
@@ -59,7 +59,10 @@ static ULONG STDMETHODCALLTYPE d3d10_buffer_AddRef(ID3D10Buffer *iface)
TRACE("%p increasing refcount to %u.\n", buffer, refcount);
if (refcount == 1)
+ {
+ ID3D10Device1_AddRef(buffer->device);
wined3d_buffer_incref(buffer->wined3d_buffer);
+ }
return refcount;
}
@@ -72,7 +75,14 @@ static ULONG STDMETHODCALLTYPE d3d10_buffer_Release(ID3D10Buffer *iface)
TRACE("%p decreasing refcount to %u.\n", buffer, refcount);
if (!refcount)
+ {
+ ID3D10Device1 *device = buffer->device;
+
wined3d_buffer_decref(buffer->wined3d_buffer);
+ /* Release the device last, it may cause the wined3d device to be
+ * destroyed. */
+ ID3D10Device1_Release(device);
+ }
return refcount;
}
@@ -81,7 +91,12 @@ static ULONG STDMETHODCALLTYPE d3d10_buffer_Release(ID3D10Buffer *iface)
static void STDMETHODCALLTYPE d3d10_buffer_GetDevice(ID3D10Buffer *iface, ID3D10Device **device)
{
- FIXME("iface %p, device %p stub!\n", iface, device);
+ struct d3d10_buffer *buffer = impl_from_ID3D10Buffer(iface);
+
+ TRACE("iface %p, device %p.\n", iface, device);
+
+ *device = (ID3D10Device *)buffer->device;
+ ID3D10Device_AddRef(*device);
}
static HRESULT STDMETHODCALLTYPE d3d10_buffer_GetPrivateData(ID3D10Buffer *iface,
@@ -226,5 +241,8 @@ HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *devi
return hr;
}
+ buffer->device = &device->ID3D10Device1_iface;
+ ID3D10Device1_AddRef(buffer->device);
+
return S_OK;
}
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h
index eb95f42..012c884 100644
--- a/dlls/d3d10core/d3d10core_private.h
+++ b/dlls/d3d10core/d3d10core_private.h
@@ -108,6 +108,7 @@ struct d3d10_buffer
LONG refcount;
struct wined3d_buffer *wined3d_buffer;
+ ID3D10Device1 *device;
};
HRESULT d3d10_buffer_init(struct d3d10_buffer *buffer, struct d3d10_device *device,
diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c
index 6014a93..429869d 100644
--- a/dlls/d3d10core/tests/device.c
+++ b/dlls/d3d10core/tests/device.c
@@ -260,12 +260,12 @@ static void test_create_rendertarget_view(void)
{
D3D10_RENDER_TARGET_VIEW_DESC rtv_desc;
D3D10_TEXTURE2D_DESC texture_desc;
+ ULONG refcount, expected_refcount;
D3D10_BUFFER_DESC buffer_desc;
ID3D10RenderTargetView *rtview;
+ ID3D10Device *device, *tmp;
ID3D10Texture2D *texture;
ID3D10Buffer *buffer;
- ID3D10Device *device;
- ULONG refcount;
HRESULT hr;
if (!(device = create_device()))
@@ -280,8 +280,18 @@ static void test_create_rendertarget_view(void)
buffer_desc.CPUAccessFlags = 0;
buffer_desc.MiscFlags = 0;
+ expected_refcount = get_refcount((IUnknown *)device) + 1;
hr = ID3D10Device_CreateBuffer(device, &buffer_desc, NULL, &buffer);
ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x\n", hr);
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount);
+ tmp = NULL;
+ expected_refcount = refcount + 1;
+ ID3D10Buffer_GetDevice(buffer, &tmp);
+ ok(tmp == device, "Got unexpected device %p, expected %p.\n", tmp, device);
+ refcount = get_refcount((IUnknown *)device);
+ ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount);
+ ID3D10Device_Release(tmp);
rtv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
rtv_desc.ViewDimension = D3D10_RTV_DIMENSION_BUFFER;
--
1.7.10.4
More information about the wine-patches
mailing list