From e006be15b9694a15d03fe03d7fac9c12ab9b2921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Sun, 27 Sep 2015 18:49:56 +0200 Subject: [PATCH] d3d11: Implement ID3D11RasterizerState interface. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia --- dlls/d3d11/d3d11_private.h | 10 ++- dlls/d3d11/device.c | 5 -- dlls/d3d11/state.c | 179 +++++++++++++++++++++++++++++-------- 3 files changed, 152 insertions(+), 42 deletions(-) diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 13126a12d6c..07431232b47 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -306,16 +306,17 @@ HRESULT d3d10_depthstencil_state_init(struct d3d10_depthstencil_state *state, st struct d3d10_depthstencil_state *unsafe_impl_from_ID3D10DepthStencilState( ID3D10DepthStencilState *iface) DECLSPEC_HIDDEN; -/* ID3D10RasterizerState */ +/* ID3D11RasterizerState, ID3D10RasterizerState */ struct d3d_rasterizer_state { + ID3D11RasterizerState ID3D11RasterizerState_iface; ID3D10RasterizerState ID3D10RasterizerState_iface; LONG refcount; struct wined3d_private_store private_store; D3D10_RASTERIZER_DESC desc; struct wine_rb_entry entry; - ID3D10Device1 *device; + ID3D11Device *device; }; HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device, @@ -381,6 +382,11 @@ struct d3d_device struct d3d_rasterizer_state *rasterizer_state; }; +static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_device, ID3D11Device_iface); +} + static inline struct d3d_device *impl_from_ID3D10Device(ID3D10Device1 *iface) { return CONTAINING_RECORD(iface, struct d3d_device, ID3D10Device1_iface); diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index 73ff58e33ee..4d4cd6cdc20 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -34,11 +34,6 @@ const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops = /* ID3D11Device methods */ -static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface) -{ - return CONTAINING_RECORD(iface, struct d3d_device, ID3D11Device_iface); -} - static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out) { struct d3d_device *device = impl_from_ID3D11Device(iface); diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index 0ab9e988e22..ac50acfc0b1 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -354,6 +354,138 @@ struct d3d10_depthstencil_state *unsafe_impl_from_ID3D10DepthStencilState(ID3D10 return impl_from_ID3D10DepthStencilState(iface); } +/* ID3D11RasterizerState methods */ + +static inline struct d3d_rasterizer_state *impl_from_ID3D11RasterizerState(ID3D11RasterizerState *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_rasterizer_state, ID3D11RasterizerState_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d11_rasterizer_state_QueryInterface(ID3D11RasterizerState *iface, + REFIID riid, void **object) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D11RasterizerState) + || IsEqualGUID(riid, &IID_ID3D11DeviceChild) + || IsEqualGUID(riid, &IID_IUnknown)) + { + ID3D11RasterizerState_AddRef(iface); + *object = iface; + return S_OK; + } + + if (IsEqualGUID(riid, &IID_ID3D10RasterizerState) + || IsEqualGUID(riid, &IID_ID3D10DeviceChild)) + { + ID3D10RasterizerState_AddRef(&state->ID3D10RasterizerState_iface); + *object = &state->ID3D10RasterizerState_iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_AddRef(ID3D11RasterizerState *iface) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + ULONG refcount = InterlockedIncrement(&state->refcount); + + TRACE("%p increasing refcount to %u.\n", state, refcount); + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_Release(ID3D11RasterizerState *iface) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + ULONG refcount = InterlockedDecrement(&state->refcount); + + TRACE("%p decreasing refcount to %u.\n", state, refcount); + + if (!refcount) + { + struct d3d_device *device = impl_from_ID3D11Device(state->device); + wined3d_mutex_lock(); + wine_rb_remove(&device->rasterizer_states, &state->desc); + ID3D11Device_Release(state->device); + wined3d_private_store_cleanup(&state->private_store); + wined3d_mutex_unlock(); + HeapFree(GetProcessHeap(), 0, state); + } + + return refcount; +} + +static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDevice(ID3D11RasterizerState *iface, + ID3D11Device **device) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + *device = state->device; + ID3D11Device_AddRef(*device); +} + +static HRESULT STDMETHODCALLTYPE d3d11_rasterizer_state_GetPrivateData(ID3D11RasterizerState *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d_get_private_data(&state->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_rasterizer_state_SetPrivateData(ID3D11RasterizerState *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d_set_private_data(&state->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_rasterizer_state_SetPrivateDataInterface(ID3D11RasterizerState *iface, + REFGUID guid, const IUnknown *data) +{ + struct d3d_rasterizer_state *state = impl_from_ID3D11RasterizerState(iface); + + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + return d3d_set_private_data_interface(&state->private_store, guid, data); +} + +static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDesc(ID3D11RasterizerState *iface, + D3D11_RASTERIZER_DESC *desc) +{ + FIXME("iface %p, desc %p stub!\n", iface, desc); +} + +static const struct ID3D11RasterizerStateVtbl d3d11_rasterizer_state_vtbl = +{ + /* IUnknown methods */ + d3d11_rasterizer_state_QueryInterface, + d3d11_rasterizer_state_AddRef, + d3d11_rasterizer_state_Release, + /* ID3D11DeviceChild methods */ + d3d11_rasterizer_state_GetDevice, + d3d11_rasterizer_state_GetPrivateData, + d3d11_rasterizer_state_SetPrivateData, + d3d11_rasterizer_state_SetPrivateDataInterface, + /* ID3D11RasterizerState methods */ + d3d11_rasterizer_state_GetDesc, +}; + +/* ID3D10RasterizerState methods */ + static inline struct d3d_rasterizer_state *impl_from_ID3D10RasterizerState(ID3D10RasterizerState *iface) { return CONTAINING_RECORD(iface, struct d3d_rasterizer_state, ID3D10RasterizerState_iface); @@ -364,52 +496,29 @@ static inline struct d3d_rasterizer_state *impl_from_ID3D10RasterizerState(ID3D1 static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_QueryInterface(ID3D10RasterizerState *iface, REFIID riid, void **object) { + struct d3d_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface); + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); - if (IsEqualGUID(riid, &IID_ID3D10RasterizerState) - || IsEqualGUID(riid, &IID_ID3D10DeviceChild) - || IsEqualGUID(riid, &IID_IUnknown)) - { - IUnknown_AddRef(iface); - *object = iface; - return S_OK; - } - - WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); - - *object = NULL; - return E_NOINTERFACE; + return d3d11_rasterizer_state_QueryInterface(&state->ID3D11RasterizerState_iface, riid, object); } static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_AddRef(ID3D10RasterizerState *iface) { - struct d3d_rasterizer_state *This = impl_from_ID3D10RasterizerState(iface); - ULONG refcount = InterlockedIncrement(&This->refcount); + struct d3d_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface); - TRACE("%p increasing refcount to %u.\n", This, refcount); + TRACE("iface %p.\n", iface); - return refcount; + return d3d11_rasterizer_state_AddRef(&state->ID3D11RasterizerState_iface); } static ULONG STDMETHODCALLTYPE d3d10_rasterizer_state_Release(ID3D10RasterizerState *iface) { struct d3d_rasterizer_state *state = impl_from_ID3D10RasterizerState(iface); - ULONG refcount = InterlockedDecrement(&state->refcount); - TRACE("%p decreasing refcount to %u.\n", state, refcount); + TRACE("iface %p.\n", state); - if (!refcount) - { - struct d3d_device *device = impl_from_ID3D10Device(state->device); - wined3d_mutex_lock(); - wine_rb_remove(&device->rasterizer_states, &state->desc); - ID3D10Device1_Release(state->device); - wined3d_private_store_cleanup(&state->private_store); - wined3d_mutex_unlock(); - HeapFree(GetProcessHeap(), 0, state); - } - - return refcount; + return d3d11_rasterizer_state_Release(&state->ID3D11RasterizerState_iface); } /* ID3D10DeviceChild methods */ @@ -420,8 +529,7 @@ static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerS TRACE("iface %p, device %p.\n", iface, device); - *device = (ID3D10Device *)state->device; - ID3D10Device_AddRef(*device); + ID3D11Device_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface, @@ -486,6 +594,7 @@ static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl = HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d_device *device, const D3D10_RASTERIZER_DESC *desc) { + state->ID3D11RasterizerState_iface.lpVtbl = &d3d11_rasterizer_state_vtbl; state->ID3D10RasterizerState_iface.lpVtbl = &d3d10_rasterizer_state_vtbl; state->refcount = 1; wined3d_mutex_lock(); @@ -501,8 +610,8 @@ HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, struct d3d } wined3d_mutex_unlock(); - state->device = &device->ID3D10Device1_iface; - ID3D10Device1_AddRef(state->device); + state->device = &device->ID3D11Device_iface; + ID3D11Device_AddRef(state->device); return S_OK; }