From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Add a GetBlendState(..., 1, ...) test.
dlls/d3d10/effect.c | 12 +++++------- dlls/d3d10/tests/effect.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 96fd994fe77..e3c261d0270 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8531,17 +8531,15 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_blend_variable_GetBlendState(ID3D1
TRACE("iface %p, index %u, blend_state %p.\n", iface, index, blend_state);
- if (v->type->element_count) - v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index)); - else if (index) - return E_FAIL; - - if (v->type->basetype != D3D10_SVT_BLEND) + if (!iface->lpVtbl->IsValid(iface)) { - WARN("Variable is not a blend state.\n"); + WARN("Invalid variable.\n"); return E_FAIL; }
+ if (!(v = d3d10_get_state_variable(v, index, &v->effect->blend_states))) + return E_FAIL; + if ((*blend_state = v->u.state.object.blend)) ID3D10BlendState_AddRef(*blend_state);
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 5c2e7766767..b4ea4402a05 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -4530,8 +4530,22 @@ static void test_effect_state_groups(void) blend_desc.RenderTargetWriteMask[0]); ok(blend_desc.RenderTargetWriteMask[7] == 0x7, "Got unexpected RenderTargetWriteMask[7] %#x.\n", blend_desc.RenderTargetWriteMask[7]); + hr = b->lpVtbl->GetBlendState(b, 0, &blend_state); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ID3D10BlendState_GetDesc(blend_state, &blend_desc); + ok(blend_desc.SrcBlend == D3D10_BLEND_ONE, "Got unexpected SrcBlend %#x.\n", blend_desc.SrcBlend); + ID3D10BlendState_Release(blend_state); b->lpVtbl->GetBackingStore(b, 1, &blend_desc); ok(blend_desc.SrcBlend == D3D10_BLEND_SRC_COLOR, "Got unexpected SrcBlend %#x.\n", blend_desc.SrcBlend); + hr = b->lpVtbl->GetBlendState(b, 1, &blend_state); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ID3D10BlendState_GetDesc(blend_state, &blend_desc); + /* We can't check the SrcBlend value from the ID3D10BlendState object + * descriptor because BlendEnable[0] is effectively false, which forces + * normalization of all the other descriptor values. We can at least + * confirm that we got blend_state2 by checking BlendEnable[0] itself. */ + ok(!blend_desc.BlendEnable[0], "Got unexpected BlendEnable[0] %#x.\n", blend_desc.BlendEnable[0]); + ID3D10BlendState_Release(blend_state);
v = effect->lpVtbl->GetVariableByName(effect, "ds_state"); d = v->lpVtbl->AsDepthStencil(v);