Module: wine Branch: master Commit: 3363d4923675d0f54278065a4923df78f002b77d URL: http://source.winehq.org/git/wine.git/?a=commit;h=3363d4923675d0f54278065a49...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Mon Feb 17 11:24:29 2014 +0100
d3d10core: Implement d3d10_sampler_state_GetDevice().
---
dlls/d3d10core/d3d10core_private.h | 7 ++++++- dlls/d3d10core/device.c | 5 ----- dlls/d3d10core/state.c | 16 +++++++++++++--- dlls/d3d10core/tests/device.c | 14 ++++++++++++-- 4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d10core/d3d10core_private.h b/dlls/d3d10core/d3d10core_private.h index 8fdef8a..4f5abad 100644 --- a/dlls/d3d10core/d3d10core_private.h +++ b/dlls/d3d10core/d3d10core_private.h @@ -272,10 +272,10 @@ struct d3d10_sampler_state ID3D10SamplerState ID3D10SamplerState_iface; LONG refcount;
- struct d3d10_device *device; struct wined3d_sampler *wined3d_sampler; D3D10_SAMPLER_DESC desc; struct wine_rb_entry entry; + ID3D10Device1 *device; };
HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, struct d3d10_device *device, @@ -319,6 +319,11 @@ struct d3d10_device struct d3d10_rasterizer_state *rasterizer_state; };
+static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device1 *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device1_iface); +} + HRESULT d3d10_device_init(struct d3d10_device *device, void *outer_unknown) DECLSPEC_HIDDEN;
/* Layered device */ diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c index 8085e56..0bd9883 100644 --- a/dlls/d3d10core/device.c +++ b/dlls/d3d10core/device.c @@ -101,11 +101,6 @@ static ULONG STDMETHODCALLTYPE d3d10_device_inner_Release(IUnknown *iface)
/* IUnknown methods */
-static inline struct d3d10_device *impl_from_ID3D10Device(ID3D10Device1 *iface) -{ - return CONTAINING_RECORD(iface, struct d3d10_device, ID3D10Device1_iface); -} - static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid, void **ppv) { diff --git a/dlls/d3d10core/state.c b/dlls/d3d10core/state.c index f0d162b..3e4e8ef 100644 --- a/dlls/d3d10core/state.c +++ b/dlls/d3d10core/state.c @@ -487,8 +487,11 @@ static ULONG STDMETHODCALLTYPE d3d10_sampler_state_Release(ID3D10SamplerState *i
if (!refcount) { + struct d3d10_device *device = impl_from_ID3D10Device(state->device); + wined3d_sampler_decref(state->wined3d_sampler); - wine_rb_remove(&state->device->sampler_states, &state->desc); + wine_rb_remove(&device->sampler_states, &state->desc); + ID3D10Device1_Release(state->device); HeapFree(GetProcessHeap(), 0, state); }
@@ -499,7 +502,12 @@ static ULONG STDMETHODCALLTYPE d3d10_sampler_state_Release(ID3D10SamplerState *i
static void STDMETHODCALLTYPE d3d10_sampler_state_GetDevice(ID3D10SamplerState *iface, ID3D10Device **device) { - FIXME("iface %p, device %p stub!\n", iface, device); + struct d3d10_sampler_state *state = impl_from_ID3D10SamplerState(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + *device = (ID3D10Device *)state->device; + ID3D10Device_AddRef(*device); }
static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_GetPrivateData(ID3D10SamplerState *iface, @@ -562,7 +570,6 @@ HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, struct d3d10
state->ID3D10SamplerState_iface.lpVtbl = &d3d10_sampler_state_vtbl; state->refcount = 1; - state->device = device; state->desc = *desc;
if (FAILED(hr = wined3d_sampler_create(state, &state->wined3d_sampler))) @@ -578,6 +585,9 @@ HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, struct d3d10 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 7eef19a..d0ad0c4 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -605,9 +605,9 @@ float4 main(const float4 color : COLOR) : SV_TARGET static void test_create_sampler_state(void) { ID3D10SamplerState *sampler_state1, *sampler_state2; + ULONG refcount, expected_refcount; D3D10_SAMPLER_DESC sampler_desc; - ID3D10Device *device; - ULONG refcount; + ID3D10Device *device, *tmp; HRESULT hr;
if (!(device = create_device())) @@ -633,11 +633,21 @@ static void test_create_sampler_state(void) sampler_desc.MinLOD = 0.0f; sampler_desc.MaxLOD = 16.0f;
+ expected_refcount = get_refcount((IUnknown *)device) + 1; hr = ID3D10Device_CreateSamplerState(device, &sampler_desc, &sampler_state1); ok(SUCCEEDED(hr), "Failed to create sampler state, hr %#x.\n", hr); hr = ID3D10Device_CreateSamplerState(device, &sampler_desc, &sampler_state2); ok(SUCCEEDED(hr), "Failed to create sampler state, hr %#x.\n", hr); ok(sampler_state1 == sampler_state2, "Got different sampler 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; + ID3D10SamplerState_GetDevice(sampler_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 = ID3D10SamplerState_Release(sampler_state2); ok(refcount == 1, "Got unexpected refcount %u.\n", refcount);