Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 15 +++++++++----- dlls/d3d10/tests/effect.c | 43 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index fbfe8d0113a..6e429c32b2d 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -7082,19 +7082,24 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetGeometryShader( ID3D10EffectShaderVariable *iface, UINT index, ID3D10GeometryShader **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_GEOMETRYSHADER) + if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype))) + return hr; + + if (basetype != D3D10_SVT_GEOMETRYSHADER) { WARN("Shader is not a geometry shader.\n"); - return E_FAIL; + return D3DERR_INVALIDCALL; }
- if ((*shader = v->u.shader.shader.gs)) + if ((*shader = s->shader.gs)) ID3D10GeometryShader_AddRef(*shader);
return S_OK; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 603f3dd049a..df9777491b6 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6013,6 +6013,7 @@ static void test_effect_shader_description(void) static void test_effect_shader_object(void) { ID3D10EffectShaderVariable *s; + ID3D10GeometryShader *gs; ID3D10EffectVariable *v; ID3D10VertexShader *vs; ID3D10PixelShader *ps; @@ -6092,6 +6093,48 @@ static void test_effect_shader_object(void) ok(!!ps, "Unexpected shader object.\n"); ID3D10PixelShader_Release(ps);
+ gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 0, &gs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 1, &gs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 2, &gs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 3, &gs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 4, &gs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetGeometryShader(s, 5, &gs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!gs, "Unexpected shader object.\n"); + + gs = NULL; + hr = s->lpVtbl->GetGeometryShader(s, 6, &gs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!gs, "Unexpected shader object.\n"); + ID3D10GeometryShader_Release(gs); + + gs = NULL; + hr = s->lpVtbl->GetGeometryShader(s, 7, &gs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!gs, "Unexpected shader object.\n"); + ID3D10GeometryShader_Release(gs); + effect->lpVtbl->Release(effect);
refcount = ID3D10Device_Release(device);