Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 15 ++++++++++----- dlls/d3d10/tests/effect.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 180d36ce65b..fbfe8d0113a 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -7104,19 +7104,24 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetPixelShader( ID3D10EffectShaderVariable *iface, UINT index, ID3D10PixelShader **shader) { struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface); + struct d3d10_effect_shader_variable *s; + D3D10_SHADER_VARIABLE_TYPE basetype; + HRESULT hr;
TRACE("iface %p, index %u, shader %p.\n", iface, index, shader);
- if (v->type->element_count) - v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index)); + *shader = NULL;
- if (v->type->basetype != D3D10_SVT_PIXELSHADER) + if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype))) + return hr; + + if (basetype != D3D10_SVT_PIXELSHADER) { WARN("Shader is not a pixel shader.\n"); - return E_FAIL; + return D3DERR_INVALIDCALL; }
- if ((*shader = v->u.shader.shader.ps)) + if ((*shader = s->shader.ps)) ID3D10PixelShader_AddRef(*shader);
return S_OK; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 4583863d59b..603f3dd049a 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6015,6 +6015,7 @@ static void test_effect_shader_object(void) ID3D10EffectShaderVariable *s; ID3D10EffectVariable *v; ID3D10VertexShader *vs; + ID3D10PixelShader *ps; ID3D10Effect* effect; ID3D10Device *device; ULONG refcount; @@ -6060,6 +6061,37 @@ static void test_effect_shader_object(void) ok(!!vs, "Unexpected shader object.\n"); ID3D10VertexShader_Release(vs);
+ ps = (void *)0xdeadbeef; + hr = s->lpVtbl->GetPixelShader(s, 0, &ps); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!ps, "Unexpected shader object.\n"); + + ps = (void *)0xdeadbeef; + hr = s->lpVtbl->GetPixelShader(s, 1, &ps); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!ps, "Unexpected shader object.\n"); + + ps = (void *)0xdeadbeef; + hr = s->lpVtbl->GetPixelShader(s, 2, &ps); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!ps, "Unexpected shader object.\n"); + + ps = (void *)0xdeadbeef; + hr = s->lpVtbl->GetPixelShader(s, 3, &ps); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!ps, "Unexpected shader object.\n"); + + ps = (void *)0xdeadbeef; + hr = s->lpVtbl->GetPixelShader(s, 4, &ps); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!ps, "Unexpected shader object.\n"); + + ps = NULL; + hr = s->lpVtbl->GetPixelShader(s, 5, &ps); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!ps, "Unexpected shader object.\n"); + ID3D10PixelShader_Release(ps); + effect->lpVtbl->Release(effect);
refcount = ID3D10Device_Release(device);