From c7fb7ba53975d1ec2fc9df736328a9fdb8c0714f Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Mon, 17 Feb 2014 11:24:31 +0100 Subject: [PATCH] d3d10core: Implement d3d10_depthstencil_state_GetDevice(). --- dlls/d3d10core/d3d10core_private.h | 2 +- dlls/d3d10core/state.c | 15 ++++++++++++--- dlls/d3d10core/tests/device.c | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 3cf329387c0..312ca7bc0d7 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -241,9 +241,9 @@ struct d3d10_depthstencil_state ID3D10DepthStencilState ID3D10DepthStencilState_iface; LONG refcount; - struct d3d10_device *device; D3D10_DEPTH_STENCIL_DESC desc; struct wine_rb_entry entry; + ID3D10Device1 *device; }; HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state, struct d3d10_device *device, diff --git a/dlls/d3d10core/state.c b/dlls/d3d10core/state.c index 376bf0bdf1d..53a78ea9518 100644 --- a/dlls/d3d10core/state.c +++ b/dlls/d3d10core/state.c @@ -218,7 +218,9 @@ static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_Release(ID3D10DepthStenc if (!refcount) { - wine_rb_remove(&state->device->depthstencil_states, &state->desc); + struct d3d10_device *device = impl_from_ID3D10Device(state->device); + wine_rb_remove(&device->depthstencil_states, &state->desc); + ID3D10Device1_Release(state->device); HeapFree(GetProcessHeap(), 0, state); } @@ -229,7 +231,12 @@ static ULONG STDMETHODCALLTYPE d3d10_depthstencil_state_Release(ID3D10DepthStenc static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDevice(ID3D10DepthStencilState *iface, ID3D10Device **device) { - FIXME("iface %p, device %p stub!\n", iface, device); + struct d3d10_depthstencil_state *state = impl_from_ID3D10DepthStencilState(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + *device = (ID3D10Device *)state->device; + ID3D10Device_AddRef(*device); } static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_GetPrivateData(ID3D10DepthStencilState *iface, @@ -290,7 +297,6 @@ HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state, st { state->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl; state->refcount = 1; - state->device = device; state->desc = *desc; if (wine_rb_put(&device->depthstencil_states, desc, &state->entry) == -1) @@ -299,6 +305,9 @@ HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state, st return E_FAIL; } + state->device = &device->ID3D10Device1_iface; + ID3D10Device1_AddRef(state->device); + return S_OK; } diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index d23c24d08dd..61154a0484a 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -727,9 +727,9 @@ static void test_create_blend_state(void) static void test_create_depthstencil_state(void) { ID3D10DepthStencilState *ds_state1, *ds_state2; + ULONG refcount, expected_refcount; D3D10_DEPTH_STENCIL_DESC ds_desc; - ID3D10Device *device; - ULONG refcount; + ID3D10Device *device, *tmp; HRESULT hr; if (!(device = create_device())) @@ -756,11 +756,21 @@ static void test_create_depthstencil_state(void) ds_desc.BackFace.StencilPassOp = D3D10_STENCIL_OP_KEEP; ds_desc.BackFace.StencilFunc = D3D10_COMPARISON_ALWAYS; + expected_refcount = get_refcount((IUnknown *)device) + 1; hr = ID3D10Device_CreateDepthStencilState(device, &ds_desc, &ds_state1); ok(SUCCEEDED(hr), "Failed to create depthstencil state, hr %#x.\n", hr); hr = ID3D10Device_CreateDepthStencilState(device, &ds_desc, &ds_state2); ok(SUCCEEDED(hr), "Failed to create depthstencil state, hr %#x.\n", hr); ok(ds_state1 == ds_state2, "Got different depthstencil state objects.\n"); + 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; + ID3D10DepthStencilState_GetDevice(ds_state1, &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); refcount = ID3D10DepthStencilState_Release(ds_state2); ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);