Commit 3b860a03 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11: Correctly handle optional arguments in OMGetDepthStencilState().

parent 349d0d9c
......@@ -5696,6 +5696,17 @@ float4 main(float4 color : COLOR) : SV_TARGET
ok(tmp_ds_state == ds_state, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state, ds_state);
ID3D10DepthStencilState_Release(tmp_ds_state);
ok(stencil_ref == 3, "Got unexpected stencil ref %u.\n", stencil_ref);
/* For OMGetDepthStencilState() both arguments are optional. */
ID3D10Device_OMGetDepthStencilState(device, NULL, NULL);
stencil_ref = 0;
ID3D10Device_OMGetDepthStencilState(device, NULL, &stencil_ref);
ok(stencil_ref == 3, "Got unexpected stencil ref %u.\n", stencil_ref);
tmp_ds_state = NULL;
ID3D10Device_OMGetDepthStencilState(device, &tmp_ds_state, NULL);
ok(stencil_ref == 3, "Got unexpected stencil ref %u.\n", stencil_ref);
ok(tmp_ds_state == ds_state, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state, ds_state);
ID3D10DepthStencilState_Release(tmp_ds_state);
ID3D10Device_OMGetRenderTargets(device, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT, tmp_rtv, &tmp_dsv);
for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
{
......
......@@ -2216,19 +2216,25 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMGetDepthStencilState(ID3D11
struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface);
struct wined3d_depth_stencil_state *wined3d_state;
struct d3d_depthstencil_state *state_impl;
UINT stencil_ref_tmp;
TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
iface, depth_stencil_state, stencil_ref);
wined3d_mutex_lock();
if ((wined3d_state = wined3d_device_context_get_depth_stencil_state(context->wined3d_context, stencil_ref)))
if (!stencil_ref) stencil_ref = &stencil_ref_tmp;
wined3d_state = wined3d_device_context_get_depth_stencil_state(context->wined3d_context, stencil_ref);
if (depth_stencil_state)
{
state_impl = wined3d_depth_stencil_state_get_parent(wined3d_state);
ID3D11DepthStencilState_AddRef(*depth_stencil_state = &state_impl->ID3D11DepthStencilState_iface);
}
else
{
*depth_stencil_state = NULL;
if (wined3d_state)
{
state_impl = wined3d_depth_stencil_state_get_parent(wined3d_state);
ID3D11DepthStencilState_AddRef(*depth_stencil_state = &state_impl->ID3D11DepthStencilState_iface);
}
else
{
*depth_stencil_state = NULL;
}
}
wined3d_mutex_unlock();
}
......@@ -5554,7 +5560,7 @@ static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1
ID3D10DepthStencilState **depth_stencil_state, UINT *stencil_ref)
{
struct d3d_device *device = impl_from_ID3D10Device(iface);
ID3D11DepthStencilState *d3d11_iface;
ID3D11DepthStencilState *d3d11_iface = NULL;
TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n",
iface, depth_stencil_state, stencil_ref);
......@@ -5562,10 +5568,19 @@ static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1
d3d11_device_context_OMGetDepthStencilState(&device->immediate_context.ID3D11DeviceContext1_iface,
&d3d11_iface, stencil_ref);
if (depth_stencil_state)
{
if (d3d11_iface)
{
*depth_stencil_state = &impl_from_ID3D11DepthStencilState(d3d11_iface)->ID3D10DepthStencilState_iface;
ID3D10DepthStencilState_AddRef(*depth_stencil_state);
}
else
*depth_stencil_state = NULL;
}
if (d3d11_iface)
*depth_stencil_state = &impl_from_ID3D11DepthStencilState(d3d11_iface)->ID3D10DepthStencilState_iface;
else
*depth_stencil_state = NULL;
ID3D11DepthStencilState_Release(d3d11_iface);
}
static void STDMETHODCALLTYPE d3d10_device_SOGetTargets(ID3D10Device1 *iface,
......
......@@ -12599,6 +12599,16 @@ static void test_clear_state(void)
ok(tmp_ds_state == ds_state, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state, ds_state);
ID3D11DepthStencilState_Release(tmp_ds_state);
ok(stencil_ref == 3, "Got unexpected stencil ref %u.\n", stencil_ref);
/* For OMGetDepthStencilState() both arguments are optional. */
ID3D11DeviceContext_OMGetDepthStencilState(context, NULL, NULL);
stencil_ref = 0;
ID3D11DeviceContext_OMGetDepthStencilState(context, NULL, &stencil_ref);
ok(stencil_ref == 3, "Got unexpected stencil ref %u.\n", stencil_ref);
tmp_ds_state = NULL;
ID3D11DeviceContext_OMGetDepthStencilState(context, &tmp_ds_state, NULL);
ok(tmp_ds_state == ds_state, "Got unexpected depth stencil state %p, expected %p.\n", tmp_ds_state, ds_state);
ID3D11DepthStencilState_Release(tmp_ds_state);
ID3D11DeviceContext_OMGetRenderTargets(context, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT, tmp_rtv, &tmp_dsv);
for (i = 0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT - 1; ++i)
{
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment