Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 25 +++++++++++++-- dlls/d3d10/tests/effect.c | 66 ++++++++++++++++++++++++++++++++++----- 2 files changed, 82 insertions(+), 9 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index acc7199138b..aa0eef8852d 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -6783,9 +6783,30 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetRawValue( static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetShaderDesc( ID3D10EffectShaderVariable *iface, UINT index, D3D10_EFFECT_SHADER_DESC *desc) { - FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc); + struct d3d10_effect_variable *v = impl_from_ID3D10EffectShaderVariable(iface); + D3D10_SHADER_DESC shader_desc; + HRESULT hr = S_OK;
- return E_NOTIMPL; + FIXME("iface %p, index %u, desc %p semi-stub.\n", iface, index, desc); + + if (v->type->element_count) + v = impl_from_ID3D10EffectVariable(iface->lpVtbl->GetElement(iface, index)); + + memset(desc, 0, sizeof(*desc)); + if (v->u.shader.input_signature) + desc->pInputSignature = ID3D10Blob_GetBufferPointer(v->u.shader.input_signature); + desc->SODecl = v->u.shader.stream_output_declaration; + if (v->u.shader.reflection) + { + if (SUCCEEDED(hr = v->u.shader.reflection->lpVtbl->GetDesc(v->u.shader.reflection, + &shader_desc))) + { + desc->NumInputSignatureEntries = shader_desc.InputParameters; + desc->NumOutputSignatureEntries = shader_desc.OutputParameters; + } + } + + return hr; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_shader_variable_GetVertexShader( diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 5fcece4695b..17ebafcec37 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -3642,14 +3642,10 @@ if (0) v = effect->lpVtbl->GetVariableByName(effect, "g_so"); gs = v->lpVtbl->AsShader(v); hr = gs->lpVtbl->GetShaderDesc(gs, 0, &shaderdesc); -todo_wine ok(hr == S_OK, "Failed to get shader description, hr %#x.\n", hr); - if (hr == S_OK) - { - ok(!shaderdesc.IsInline, "Unexpected inline flag.\n"); - ok(!strcmp(shaderdesc.SODecl, "SV_POSITION.x"), "Unexpected stream output declaration %s.\n", - shaderdesc.SODecl); - } + ok(!shaderdesc.IsInline, "Unexpected inline flag.\n"); + ok(!strcmp(shaderdesc.SODecl, "SV_POSITION.x"), "Unexpected stream output declaration %s.\n", + shaderdesc.SODecl);
/* Signature description */ v = effect->lpVtbl->GetVariableByName(effect, "p"); @@ -5865,6 +5861,61 @@ static void test_effect_resource_variable(void) ok(!refcount, "Device has %u references left.\n", refcount); }
+static void test_effect_optimize(void) +{ + D3D10_EFFECT_SHADER_DESC shaderdesc; + ID3D10EffectShaderVariable *gs; + ID3D10EffectVariable *v; + 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, "g_so"); + + gs = v->lpVtbl->AsShader(v); + hr = gs->lpVtbl->GetShaderDesc(gs, 0, &shaderdesc); + ok(hr == S_OK, "Failed to get shader description, hr %#x.\n", hr); + ok(!!shaderdesc.pInputSignature, "Expected input signature.\n"); + ok(!shaderdesc.IsInline, "Unexpected inline flag.\n"); +todo_wine { + ok(!!shaderdesc.pBytecode, "Expected bytecode.\n"); + ok(shaderdesc.BytecodeLength != 0, "Unexpected bytecode length.\n"); +} + ok(!strcmp(shaderdesc.SODecl, "SV_POSITION.x"), "Unexpected stream output declaration %s.\n", shaderdesc.SODecl); + ok(shaderdesc.NumInputSignatureEntries != 0, "Unexpected input signature count.\n"); + ok(shaderdesc.NumOutputSignatureEntries != 0, "Unexpected input signature count.\n"); + + hr = effect->lpVtbl->Optimize(effect); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = gs->lpVtbl->GetShaderDesc(gs, 0, &shaderdesc); + ok(hr == S_OK, "Failed to get shader description, hr %#x.\n", hr); + ok(!!shaderdesc.pInputSignature, "Expected input signature.\n"); + ok(!shaderdesc.IsInline, "Unexpected inline flag.\n"); + ok(!shaderdesc.pBytecode, "Unexpected bytecode.\n"); + ok(shaderdesc.BytecodeLength == 0, "Unexpected bytecode length.\n"); +todo_wine { + ok(!shaderdesc.SODecl, "Unexpected stream output declaration %p.\n", shaderdesc.SODecl); + ok(shaderdesc.NumInputSignatureEntries == 0, "Unexpected input signature count.\n"); + ok(shaderdesc.NumOutputSignatureEntries == 0, "Unexpected output signature count.\n"); +} + 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(); @@ -5881,4 +5932,5 @@ START_TEST(effect) test_effect_vector_variable(); test_effect_matrix_variable(); test_effect_resource_variable(); + test_effect_optimize(); }