Commit 9fc481c3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d10/effect: Fix index access in GetSampler().

parent 3ec14923
......@@ -9254,17 +9254,15 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_sampler_variable_GetSampler(ID3D10
TRACE("iface %p, index %u, sampler %p.\n", iface, index, sampler);
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_SAMPLER)
if (!iface->lpVtbl->IsValid(iface))
{
WARN("Variable is not a sampler state.\n");
WARN("Invalid variable.\n");
return E_FAIL;
}
if (!(v = d3d10_get_state_variable(v, index, &v->effect->samplers)))
return E_FAIL;
if ((*sampler = v->u.state.object.sampler))
ID3D10SamplerState_AddRef(*sampler);
......
......@@ -4446,6 +4446,7 @@ static void test_effect_state_groups(void)
ID3D10EffectBlendVariable *b;
D3D10_BLEND_DESC blend_desc;
D3D10_STATE_BLOCK_MASK mask;
ID3D10SamplerState *sampler;
D3D10_PASS_DESC pass_desc;
ID3D10EffectVariable *v;
ID3D10EffectPass *pass;
......@@ -4496,9 +4497,19 @@ static void test_effect_state_groups(void)
ok(sampler_desc.BorderColor[3] == 4.0f, "Got unexpected BorderColor[3] %.8e.\n", sampler_desc.BorderColor[3]);
ok(sampler_desc.MinLOD == 6.0f, "Got unexpected MinLOD %.8e.\n", sampler_desc.MinLOD);
ok(sampler_desc.MaxLOD == 5.0f, "Got unexpected MaxLOD %.8e.\n", sampler_desc.MaxLOD);
hr = s->lpVtbl->GetSampler(s, 0, &sampler);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3D10SamplerState_GetDesc(sampler, &sampler_desc);
ok(sampler_desc.Filter == D3D10_FILTER_MIN_MAG_MIP_LINEAR, "Got unexpected Filter %#x.\n", sampler_desc.Filter);
ID3D10SamplerState_Release(sampler);
s->lpVtbl->GetBackingStore(s, 1, &sampler_desc);
ok(sampler_desc.AddressU == D3D10_TEXTURE_ADDRESS_MIRROR, "Got unexpected AddressU %#x.\n", sampler_desc.AddressU);
hr = s->lpVtbl->GetSampler(s, 1, &sampler);
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
ID3D10SamplerState_GetDesc(sampler, &sampler_desc);
ok(sampler_desc.AddressU == D3D10_TEXTURE_ADDRESS_MIRROR, "Got unexpected AddressU %#x.\n", sampler_desc.AddressU);
ID3D10SamplerState_Release(sampler);
v = effect->lpVtbl->GetVariableByName(effect, "blend_state");
b = v->lpVtbl->AsBlend(v);
......
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