Commit f266c87b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11: Correctly handle optional arguments in OMGetBlendState().

parent 3be3f0c0
......@@ -5533,6 +5533,20 @@ float4 main(float4 color : COLOR) : SV_TARGET
blend_factor[2] = 0.3f;
blend_factor[3] = 0.4f;
ID3D10Device_OMSetBlendState(device, blend_state, blend_factor, D3D10_DEFAULT_SAMPLE_MASK);
/* OMGetBlendState() arguments are optional */
ID3D10Device_OMGetBlendState(device, NULL, NULL, NULL);
ID3D10Device_OMGetBlendState(device, &tmp_blend_state, NULL, NULL);
ID3D10BlendState_Release(tmp_blend_state);
sample_mask = 0;
ID3D10Device_OMGetBlendState(device, NULL, NULL, &sample_mask);
ok(sample_mask == D3D10_DEFAULT_SAMPLE_MASK, "Unexpected sample mask %#x.\n", sample_mask);
memset(tmp_blend_factor, 0, sizeof(tmp_blend_factor));
ID3D10Device_OMGetBlendState(device, NULL, tmp_blend_factor, NULL);
ok(tmp_blend_factor[0] == 0.1f && tmp_blend_factor[1] == 0.2f
&& tmp_blend_factor[2] == 0.3f && tmp_blend_factor[3] == 0.4f,
"Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
tmp_blend_factor[0], tmp_blend_factor[1], tmp_blend_factor[2], tmp_blend_factor[3]);
ID3D10Device_OMGetBlendState(device, &tmp_blend_state, tmp_blend_factor, &sample_mask);
ok(tmp_blend_factor[0] == 0.1f && tmp_blend_factor[1] == 0.2f
&& tmp_blend_factor[2] == 0.3f && tmp_blend_factor[3] == 0.4f,
......
......@@ -2190,19 +2190,25 @@ static void STDMETHODCALLTYPE d3d11_device_context_OMGetBlendState(ID3D11DeviceC
struct d3d11_device_context *context = impl_from_ID3D11DeviceContext1(iface);
struct wined3d_blend_state *wined3d_state;
struct d3d_blend_state *blend_state_impl;
unsigned int tmp_sample_mask;
float tmp_blend_factor[4];
TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n",
iface, blend_state, blend_factor, sample_mask);
wined3d_mutex_lock();
if ((wined3d_state = wined3d_device_context_get_blend_state(context->wined3d_context,
(struct wined3d_color *)blend_factor, sample_mask)))
if (!blend_factor) blend_factor = tmp_blend_factor;
if (!sample_mask) sample_mask = &tmp_sample_mask;
wined3d_state = wined3d_device_context_get_blend_state(context->wined3d_context,
(struct wined3d_color *)blend_factor, sample_mask);
if (blend_state)
{
if (wined3d_state)
{
blend_state_impl = wined3d_blend_state_get_parent(wined3d_state);
ID3D11BlendState_AddRef(*blend_state = &blend_state_impl->ID3D11BlendState_iface);
}
else
{
*blend_state = NULL;
}
wined3d_mutex_unlock();
......@@ -5541,10 +5547,19 @@ static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface,
d3d11_device_context_OMGetBlendState(&device->immediate_context.ID3D11DeviceContext1_iface,
&d3d11_blend_state, blend_factor, sample_mask);
if (blend_state)
{
if (d3d11_blend_state)
{
*blend_state = (ID3D10BlendState *)&impl_from_ID3D11BlendState(d3d11_blend_state)->ID3D10BlendState1_iface;
ID3D10BlendState_AddRef(*blend_state);
}
else
*blend_state = NULL;
}
if (d3d11_blend_state)
ID3D11BlendState_Release(d3d11_blend_state);
}
static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
......
......@@ -12608,6 +12608,20 @@ static void test_clear_state(void)
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);
/* OMGetBlendState() arguments are optional */
ID3D11DeviceContext_OMGetBlendState(context, NULL, NULL, NULL);
ID3D11DeviceContext_OMGetBlendState(context, &tmp_blend_state, NULL, NULL);
ok(tmp_blend_state == blend_state, "Got unexpected blend state %p, expected %p.\n", tmp_blend_state, blend_state);
ID3D11BlendState_Release(tmp_blend_state);
sample_mask = 0;
ID3D11DeviceContext_OMGetBlendState(context, NULL, NULL, &sample_mask);
ok(sample_mask == 0xff00ff00, "Got unexpected sample mask %#x.\n", sample_mask);
memset(blend_factor, 0, sizeof(blend_factor));
ID3D11DeviceContext_OMGetBlendState(context, NULL, blend_factor, NULL);
ok(blend_factor[0] == 0.1f && blend_factor[1] == 0.2f
&& blend_factor[2] == 0.3f && blend_factor[3] == 0.4f,
"Got unexpected blend factor {%.8e, %.8e, %.8e, %.8e}.\n",
blend_factor[0], blend_factor[1], blend_factor[2], blend_factor[3]);
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