d3d10core: Implement d3d10_buffer_GetDevice().

This commit is contained in:
Henri Verbeet 2014-02-13 10:14:21 +01:00 committed by Alexandre Julliard
parent 6e3619c42b
commit 82fc81b644
3 changed files with 32 additions and 3 deletions

View file

@ -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;
}

View file

@ -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,

View file

@ -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;