Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 24 +++++++++++------ dlls/d3d10/tests/effect.c | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index aacf2fcbfaf..218c4ad888a 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -6983,7 +6983,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue( /* ID3D10EffectShaderVariable methods */
static HRESULT d3d10_get_shader_variable(struct d3d10_effect_variable *v, UINT shader_index, - struct d3d10_effect_shader_variable **s) + struct d3d10_effect_shader_variable **s, D3D10_SHADER_VARIABLE_TYPE *basetype) { unsigned int i;
@@ -6993,6 +6993,7 @@ static HRESULT d3d10_get_shader_variable(struct d3d10_effect_variable *v, UINT s if (!shader_index) { *s = &v->u.shader; + if (basetype) *basetype = v->type->basetype; return S_OK; }
@@ -7010,6 +7011,8 @@ static HRESULT d3d10_get_shader_variable(struct d3d10_effect_variable *v, UINT s }
*s = &v->effect->used_shaders[i + shader_index]->u.shader; + if (basetype) *basetype = v->effect->used_shaders[i + shader_index]->type->basetype; + return S_OK; }
@@ -7023,7 +7026,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc(
TRACE("iface %p, index %u, desc %p.\n", iface, index, desc);
- if (FAILED(hr = d3d10_get_shader_variable(v, index, &s))) + if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, NULL))) return hr;
memset(desc, 0, sizeof(*desc)); @@ -7052,19 +7055,24 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader( ID3D10EffectShaderVariable *iface, UINT index, ID3D10VertexShader **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_VERTEXSHADER) + if (FAILED(hr = d3d10_get_shader_variable(v, index, &s, &basetype))) + return hr; + + if (basetype != D3D10_SVT_VERTEXSHADER) { WARN("Shader is not a vertex shader.\n"); - return E_FAIL; + return D3DERR_INVALIDCALL; }
- if ((*shader = v->u.shader.shader.vs)) + if ((*shader = s->shader.vs)) ID3D10VertexShader_AddRef(*shader);
return S_OK; @@ -7120,7 +7128,7 @@ static HRESULT d3d10_get_shader_variable_signature(struct d3d10_effect_variable struct d3d10_effect_shader_variable *s; HRESULT hr;
- if (FAILED(hr = d3d10_get_shader_variable(v, shader_index, &s))) + if (FAILED(hr = d3d10_get_shader_variable(v, shader_index, &s, NULL))) return hr;
if (!s->reflection) diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index a9d077566e0..4583863d59b 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6010,6 +6010,62 @@ static void test_effect_shader_description(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+static void test_effect_shader_object(void) +{ + ID3D10EffectShaderVariable *s; + ID3D10EffectVariable *v; + ID3D10VertexShader *vs; + ID3D10Effect* effect; + ID3D10Device *device; + ULONG refcount; + HRESULT hr; + + if (!(device = create_device())) + { + skip("Failed to create device, skipping tests.\n"); + return; + } + + hr = create_effect(fx_local_shader, 0, device, NULL, &effect); + ok(SUCCEEDED(hr), "Failed to create an effect!\n"); + + v = effect->lpVtbl->GetVariableByName(effect, "v0"); + + s = v->lpVtbl->AsShader(v); + + vs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetVertexShader(s, 0, &vs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!vs, "Unexpected shader object.\n"); + + vs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetVertexShader(s, 1, &vs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!vs, "Unexpected shader object.\n"); + + vs = (void *)0xdeadbeef; + hr = s->lpVtbl->GetVertexShader(s, 2, &vs); + ok(hr == D3DERR_INVALIDCALL, "Unexpected hr %#x.\n", hr); + ok(!vs, "Unexpected shader object.\n"); + + vs = NULL; + hr = s->lpVtbl->GetVertexShader(s, 3, &vs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!vs, "Unexpected shader object.\n"); + ID3D10VertexShader_Release(vs); + + vs = NULL; + hr = s->lpVtbl->GetVertexShader(s, 4, &vs); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!vs, "Unexpected shader object.\n"); + ID3D10VertexShader_Release(vs); + + effect->lpVtbl->Release(effect); + + refcount = ID3D10Device_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +} + START_TEST(effect) { test_effect_constant_buffer_type(); @@ -6028,4 +6084,5 @@ START_TEST(effect) test_effect_resource_variable(); test_effect_optimize(); test_effect_shader_description(); + test_effect_shader_object(); }