[v2 PATCH] d3d11: Correctly handle optional arguments in OMGetBlendState().
Nikolay Sivov
nsivov at codeweavers.com
Mon Nov 1 09:45:34 CDT 2021
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
dlls/d3d10core/tests/d3d10core.c | 14 ++++++++++++
dlls/d3d11/device.c | 37 ++++++++++++++++++++++----------
dlls/d3d11/tests/d3d11.c | 14 ++++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/dlls/d3d10core/tests/d3d10core.c b/dlls/d3d10core/tests/d3d10core.c
index 6ec398269fa..b8338152bb7 100644
--- a/dlls/d3d10core/tests/d3d10core.c
+++ b/dlls/d3d10core/tests/d3d10core.c
@@ -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,
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 8d88ee26222..417638bf314 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -2190,20 +2190,26 @@ 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)
{
- blend_state_impl = wined3d_blend_state_get_parent(wined3d_state);
- ID3D11BlendState_AddRef(*blend_state = &blend_state_impl->ID3D11BlendState_iface);
- }
- else
- {
- *blend_state = NULL;
+ 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)
- *blend_state = (ID3D10BlendState *)&impl_from_ID3D11BlendState(d3d11_blend_state)->ID3D10BlendState1_iface;
- else
- *blend_state = NULL;
+ ID3D11BlendState_Release(d3d11_blend_state);
}
static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 *iface,
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index 553caa10e46..2ed9aed490e 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -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)
--
2.33.0
More information about the wine-devel
mailing list