d3d11: Implement d3d11_device_CreateDepthStencilState().
Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
This commit is contained in:
parent
16e570f4a1
commit
a77015c795
|
@ -299,13 +299,13 @@ struct d3d_depthstencil_state
|
|||
LONG refcount;
|
||||
|
||||
struct wined3d_private_store private_store;
|
||||
D3D10_DEPTH_STENCIL_DESC desc;
|
||||
D3D11_DEPTH_STENCIL_DESC desc;
|
||||
struct wine_rb_entry entry;
|
||||
ID3D11Device *device;
|
||||
};
|
||||
|
||||
HRESULT d3d_depthstencil_state_init(struct d3d_depthstencil_state *state, struct d3d_device *device,
|
||||
const D3D10_DEPTH_STENCIL_DESC *desc) DECLSPEC_HIDDEN;
|
||||
const D3D11_DEPTH_STENCIL_DESC *desc) DECLSPEC_HIDDEN;
|
||||
struct d3d_depthstencil_state *unsafe_impl_from_ID3D10DepthStencilState(
|
||||
ID3D10DepthStencilState *iface) DECLSPEC_HIDDEN;
|
||||
|
||||
|
|
|
@ -313,9 +313,57 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *ifa
|
|||
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface,
|
||||
const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state)
|
||||
{
|
||||
FIXME("iface %p, desc %p, depth_stencil_state %p stub!\n", iface, desc, depth_stencil_state);
|
||||
struct d3d_device *device = impl_from_ID3D11Device(iface);
|
||||
struct d3d_depthstencil_state *object;
|
||||
D3D11_DEPTH_STENCIL_DESC tmp_desc;
|
||||
struct wine_rb_entry *entry;
|
||||
HRESULT hr;
|
||||
|
||||
return E_NOTIMPL;
|
||||
TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
|
||||
|
||||
if (!desc)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* D3D11_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
|
||||
* it as a key in the rbtree. */
|
||||
memset(&tmp_desc, 0, sizeof(tmp_desc));
|
||||
tmp_desc.DepthEnable = desc->DepthEnable;
|
||||
tmp_desc.DepthWriteMask = desc->DepthWriteMask;
|
||||
tmp_desc.DepthFunc = desc->DepthFunc;
|
||||
tmp_desc.StencilEnable = desc->StencilEnable;
|
||||
tmp_desc.StencilReadMask = desc->StencilReadMask;
|
||||
tmp_desc.StencilWriteMask = desc->StencilWriteMask;
|
||||
tmp_desc.FrontFace = desc->FrontFace;
|
||||
tmp_desc.BackFace = desc->BackFace;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
|
||||
{
|
||||
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
|
||||
|
||||
TRACE("Returning existing depthstencil state %p.\n", object);
|
||||
*depth_stencil_state = &object->ID3D11DepthStencilState_iface;
|
||||
ID3D11DepthStencilState_AddRef(*depth_stencil_state);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
|
||||
{
|
||||
WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created depthstencil state %p.\n", object);
|
||||
*depth_stencil_state = &object->ID3D11DepthStencilState_iface;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface,
|
||||
|
@ -2414,57 +2462,19 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateDepthStencilState(ID3D10Devi
|
|||
const D3D10_DEPTH_STENCIL_DESC *desc, ID3D10DepthStencilState **depth_stencil_state)
|
||||
{
|
||||
struct d3d_device *device = impl_from_ID3D10Device(iface);
|
||||
struct d3d_depthstencil_state *object;
|
||||
D3D10_DEPTH_STENCIL_DESC tmp_desc;
|
||||
struct wine_rb_entry *entry;
|
||||
ID3D11DepthStencilState *d3d11_depth_stencil_state;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("iface %p, desc %p, depth_stencil_state %p.\n", iface, desc, depth_stencil_state);
|
||||
|
||||
if (!desc)
|
||||
return E_INVALIDARG;
|
||||
|
||||
/* D3D10_DEPTH_STENCIL_DESC has a hole, which is a problem because we use
|
||||
* it as a key in the rbtree. */
|
||||
memset(&tmp_desc, 0, sizeof(tmp_desc));
|
||||
tmp_desc.DepthEnable = desc->DepthEnable;
|
||||
tmp_desc.DepthWriteMask = desc->DepthWriteMask;
|
||||
tmp_desc.DepthFunc = desc->DepthFunc;
|
||||
tmp_desc.StencilEnable = desc->StencilEnable;
|
||||
tmp_desc.StencilReadMask = desc->StencilReadMask;
|
||||
tmp_desc.StencilWriteMask = desc->StencilWriteMask;
|
||||
tmp_desc.FrontFace = desc->FrontFace;
|
||||
tmp_desc.BackFace = desc->BackFace;
|
||||
|
||||
wined3d_mutex_lock();
|
||||
if ((entry = wine_rb_get(&device->depthstencil_states, &tmp_desc)))
|
||||
{
|
||||
object = WINE_RB_ENTRY_VALUE(entry, struct d3d_depthstencil_state, entry);
|
||||
|
||||
TRACE("Returning existing depthstencil state %p.\n", object);
|
||||
*depth_stencil_state = &object->ID3D10DepthStencilState_iface;
|
||||
ID3D10DepthStencilState_AddRef(*depth_stencil_state);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
||||
if (!object)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = d3d_depthstencil_state_init(object, device, &tmp_desc)))
|
||||
{
|
||||
WARN("Failed to initialize depthstencil state, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
if (FAILED(hr = d3d11_device_CreateDepthStencilState(&device->ID3D11Device_iface,
|
||||
(const D3D11_DEPTH_STENCIL_DESC *)desc, &d3d11_depth_stencil_state)))
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created depthstencil state %p.\n", object);
|
||||
*depth_stencil_state = &object->ID3D10DepthStencilState_iface;
|
||||
|
||||
return S_OK;
|
||||
hr = ID3D11DepthStencilState_QueryInterface(d3d11_depth_stencil_state, &IID_ID3D10DepthStencilState,
|
||||
(void **)depth_stencil_state);
|
||||
ID3D11DepthStencilState_Release(d3d11_depth_stencil_state);
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d10_device_CreateRasterizerState(ID3D10Device1 *iface,
|
||||
|
@ -3094,8 +3104,8 @@ static const struct wine_rb_functions d3d10_blend_state_rb_ops =
|
|||
|
||||
static int d3d_depthstencil_state_compare(const void *key, const struct wine_rb_entry *entry)
|
||||
{
|
||||
const D3D10_DEPTH_STENCIL_DESC *ka = key;
|
||||
const D3D10_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
|
||||
const D3D11_DEPTH_STENCIL_DESC *ka = key;
|
||||
const D3D11_DEPTH_STENCIL_DESC *kb = &WINE_RB_ENTRY_VALUE(entry,
|
||||
const struct d3d_depthstencil_state, entry)->desc;
|
||||
|
||||
return memcmp(ka, kb, sizeof(*ka));
|
||||
|
|
|
@ -304,7 +304,11 @@ static HRESULT STDMETHODCALLTYPE d3d11_depthstencil_state_SetPrivateDataInterfac
|
|||
static void STDMETHODCALLTYPE d3d11_depthstencil_state_GetDesc(ID3D11DepthStencilState *iface,
|
||||
D3D11_DEPTH_STENCIL_DESC *desc)
|
||||
{
|
||||
FIXME("iface %p, desc %p stub!\n", iface, desc);
|
||||
struct d3d_depthstencil_state *state = impl_from_ID3D11DepthStencilState(iface);
|
||||
|
||||
TRACE("iface %p, desc %p.\n", iface, desc);
|
||||
|
||||
*desc = state->desc;
|
||||
}
|
||||
|
||||
static const struct ID3D11DepthStencilStateVtbl d3d11_depthstencil_state_vtbl =
|
||||
|
@ -411,7 +415,7 @@ static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDesc(ID3D10DepthStenci
|
|||
|
||||
TRACE("iface %p, desc %p.\n", iface, desc);
|
||||
|
||||
*desc = state->desc;
|
||||
memcpy(desc, &state->desc, sizeof(*desc));
|
||||
}
|
||||
|
||||
static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl =
|
||||
|
@ -430,7 +434,7 @@ static const struct ID3D10DepthStencilStateVtbl d3d10_depthstencil_state_vtbl =
|
|||
};
|
||||
|
||||
HRESULT d3d_depthstencil_state_init(struct d3d_depthstencil_state *state, struct d3d_device *device,
|
||||
const D3D10_DEPTH_STENCIL_DESC *desc)
|
||||
const D3D11_DEPTH_STENCIL_DESC *desc)
|
||||
{
|
||||
state->ID3D11DepthStencilState_iface.lpVtbl = &d3d11_depthstencil_state_vtbl;
|
||||
state->ID3D10DepthStencilState_iface.lpVtbl = &d3d10_depthstencil_state_vtbl;
|
||||
|
|
Loading…
Reference in New Issue