d3d11: Implement ID3D11BlendState interface.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c2a171850f
commit
abf6b7422d
|
@ -275,16 +275,17 @@ struct d3d_pixel_shader *unsafe_impl_from_ID3D10PixelShader(ID3D10PixelShader *i
|
|||
HRESULT shader_parse_signature(const char *data, DWORD data_size, struct wined3d_shader_signature *s) DECLSPEC_HIDDEN;
|
||||
void shader_free_signature(struct wined3d_shader_signature *s) DECLSPEC_HIDDEN;
|
||||
|
||||
/* ID3D10BlendState */
|
||||
/* ID3D11BlendState, ID3D10BlendState */
|
||||
struct d3d_blend_state
|
||||
{
|
||||
ID3D11BlendState ID3D11BlendState_iface;
|
||||
ID3D10BlendState ID3D10BlendState_iface;
|
||||
LONG refcount;
|
||||
|
||||
struct wined3d_private_store private_store;
|
||||
D3D10_BLEND_DESC desc;
|
||||
struct wine_rb_entry entry;
|
||||
ID3D10Device1 *device;
|
||||
ID3D11Device *device;
|
||||
};
|
||||
|
||||
HRESULT d3d_blend_state_init(struct d3d_blend_state *state, struct d3d_device *device,
|
||||
|
|
|
@ -30,6 +30,137 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d11);
|
|||
#define D3D10_FILTER_ANISO_MASK 0x40
|
||||
#define D3D10_FILTER_COMPARE_MASK 0x80
|
||||
|
||||
/* ID3D11BlendState methods */
|
||||
|
||||
static inline struct d3d_blend_state *impl_from_ID3D11BlendState(ID3D11BlendState *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct d3d_blend_state, ID3D11BlendState_iface);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d11_blend_state_QueryInterface(ID3D11BlendState *iface,
|
||||
REFIID riid, void **object)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(iface);
|
||||
|
||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_ID3D11BlendState)
|
||||
|| IsEqualGUID(riid, &IID_ID3D11DeviceChild)
|
||||
|| IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
ID3D11BlendState_AddRef(iface);
|
||||
*object = iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (IsEqualGUID(riid, &IID_ID3D10BlendState)
|
||||
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
|
||||
{
|
||||
ID3D10BlendState_AddRef(&state->ID3D10BlendState_iface);
|
||||
*object = &state->ID3D10BlendState_iface;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
|
||||
|
||||
*object = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE d3d11_blend_state_AddRef(ID3D11BlendState *iface)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(iface);
|
||||
ULONG refcount = InterlockedIncrement(&state->refcount);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", state, refcount);
|
||||
|
||||
return refcount;
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(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->blend_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_blend_state_GetDevice(ID3D11BlendState *iface,
|
||||
ID3D11Device **device)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(iface);
|
||||
|
||||
TRACE("iface %p, device %p.\n", iface, device);
|
||||
|
||||
*device = state->device;
|
||||
ID3D11Device_AddRef(*device);
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d11_blend_state_GetPrivateData(ID3D11BlendState *iface,
|
||||
REFGUID guid, UINT *data_size, void *data)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(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_blend_state_SetPrivateData(ID3D11BlendState *iface,
|
||||
REFGUID guid, UINT data_size, const void *data)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(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_blend_state_SetPrivateDataInterface(ID3D11BlendState *iface,
|
||||
REFGUID guid, const IUnknown *data)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D11BlendState(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_blend_state_GetDesc(ID3D11BlendState *iface, D3D11_BLEND_DESC *desc)
|
||||
{
|
||||
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
||||
}
|
||||
|
||||
static const struct ID3D11BlendStateVtbl d3d11_blend_state_vtbl =
|
||||
{
|
||||
/* IUnknown methods */
|
||||
d3d11_blend_state_QueryInterface,
|
||||
d3d11_blend_state_AddRef,
|
||||
d3d11_blend_state_Release,
|
||||
/* ID3D11DeviceChild methods */
|
||||
d3d11_blend_state_GetDevice,
|
||||
d3d11_blend_state_GetPrivateData,
|
||||
d3d11_blend_state_SetPrivateData,
|
||||
d3d11_blend_state_SetPrivateDataInterface,
|
||||
/* ID3D11BlendState methods */
|
||||
d3d11_blend_state_GetDesc,
|
||||
};
|
||||
|
||||
/* ID3D10BlendState methods */
|
||||
|
||||
static inline struct d3d_blend_state *impl_from_ID3D10BlendState(ID3D10BlendState *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct d3d_blend_state, ID3D10BlendState_iface);
|
||||
|
@ -40,52 +171,29 @@ static inline struct d3d_blend_state *impl_from_ID3D10BlendState(ID3D10BlendStat
|
|||
static HRESULT STDMETHODCALLTYPE d3d10_blend_state_QueryInterface(ID3D10BlendState *iface,
|
||||
REFIID riid, void **object)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D10BlendState(iface);
|
||||
|
||||
TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object);
|
||||
|
||||
if (IsEqualGUID(riid, &IID_ID3D10BlendState)
|
||||
|| 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_blend_state_QueryInterface(&state->ID3D11BlendState_iface, riid, object);
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE d3d10_blend_state_AddRef(ID3D10BlendState *iface)
|
||||
{
|
||||
struct d3d_blend_state *This = impl_from_ID3D10BlendState(iface);
|
||||
ULONG refcount = InterlockedIncrement(&This->refcount);
|
||||
struct d3d_blend_state *state = impl_from_ID3D10BlendState(iface);
|
||||
|
||||
TRACE("%p increasing refcount to %u.\n", This, refcount);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
return refcount;
|
||||
return d3d11_blend_state_AddRef(&state->ID3D11BlendState_iface);
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE d3d10_blend_state_Release(ID3D10BlendState *iface)
|
||||
{
|
||||
struct d3d_blend_state *state = impl_from_ID3D10BlendState(iface);
|
||||
ULONG refcount = InterlockedDecrement(&state->refcount);
|
||||
|
||||
TRACE("%p decreasing refcount to %u.\n", state, refcount);
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if (!refcount)
|
||||
{
|
||||
struct d3d_device *device = impl_from_ID3D10Device(state->device);
|
||||
wined3d_mutex_lock();
|
||||
wine_rb_remove(&device->blend_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_blend_state_Release(&state->ID3D11BlendState_iface);
|
||||
}
|
||||
|
||||
/* ID3D10DeviceChild methods */
|
||||
|
@ -96,8 +204,7 @@ static void STDMETHODCALLTYPE d3d10_blend_state_GetDevice(ID3D10BlendState *ifac
|
|||
|
||||
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_blend_state_GetPrivateData(ID3D10BlendState *iface,
|
||||
|
@ -162,6 +269,7 @@ static const struct ID3D10BlendStateVtbl d3d10_blend_state_vtbl =
|
|||
HRESULT d3d_blend_state_init(struct d3d_blend_state *state, struct d3d_device *device,
|
||||
const D3D10_BLEND_DESC *desc)
|
||||
{
|
||||
state->ID3D11BlendState_iface.lpVtbl = &d3d11_blend_state_vtbl;
|
||||
state->ID3D10BlendState_iface.lpVtbl = &d3d10_blend_state_vtbl;
|
||||
state->refcount = 1;
|
||||
wined3d_mutex_lock();
|
||||
|
@ -177,8 +285,8 @@ HRESULT d3d_blend_state_init(struct d3d_blend_state *state, struct d3d_device *d
|
|||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
state->device = &device->ID3D10Device1_iface;
|
||||
ID3D10Device1_AddRef(state->device);
|
||||
state->device = &device->ID3D11Device_iface;
|
||||
ID3D11Device_AddRef(state->device);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue