[PATCH 0/1] MR8147: d3dx9/tests: Add an effect compiler test for accessing functions.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8147
From: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/d3dx9_36/tests/effect.c | 74 +++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 028b112cb0b..a5d886ffb71 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -361,11 +361,18 @@ static void test_create_effect_and_pool(IDirect3DDevice9 *device) static void test_create_effect_compiler(void) { + static const char shader1[] = + "float4 main() : COLOR { return 0; }\n" + "float4 func2() : COLOR { return 0; }\n" + "float4 func() : COLOR { return 0; }\n"; HRESULT hr; ID3DXEffectCompiler *compiler, *compiler2; + D3DXFUNCTION_DESC func_desc; ID3DXBaseEffect *base; + D3DXEFFECT_DESC desc; IUnknown *unknown; - ULONG count; + D3DXHANDLE hfunc; + ULONG refcount; hr = D3DXCreateEffectCompiler(NULL, 0, NULL, NULL, 0, &compiler, NULL); ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); @@ -381,8 +388,8 @@ static void test_create_effect_compiler(void) return; } - count = compiler->lpVtbl->Release(compiler); - ok(count == 0, "Release failed %lu\n", count); + refcount = compiler->lpVtbl->Release(compiler); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); hr = D3DXCreateEffectCompiler(effect_desc, 0, NULL, NULL, 0, NULL, NULL); ok(hr == D3DERR_INVALIDCALL, "Got result %lx, expected %lx (D3D_INVALIDCALL)\n", hr, D3DERR_INVALIDCALL); @@ -408,14 +415,63 @@ static void test_create_effect_compiler(void) hr = compiler->lpVtbl->QueryInterface(compiler, &IID_IUnknown, (void **)&unknown); ok(hr == D3D_OK, "QueryInterface failed, got %lx, expected %lx (D3D_OK)\n", hr, D3D_OK); - count = unknown->lpVtbl->Release(unknown); - ok(count == 2, "Release failed, got %lu, expected %u\n", count, 2); + refcount = unknown->lpVtbl->Release(unknown); + ok(refcount == 2, "Got unexpected refcount %lu.\n", refcount); - count = compiler2->lpVtbl->Release(compiler2); - ok(count == 1, "Release failed, got %lu, expected %u\n", count, 1); + refcount = compiler2->lpVtbl->Release(compiler2); + ok(refcount == 1, "Got unexpected refcount %lu.\n", refcount); - count = compiler->lpVtbl->Release(compiler); - ok(count == 0, "Release failed %lu\n", count); + refcount = compiler->lpVtbl->Release(compiler); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); + + /* Accessing functions. */ + hr = D3DXCreateEffectCompiler(shader1, sizeof(shader1), NULL, NULL, 0, &compiler, NULL); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = compiler->lpVtbl->GetDesc(compiler, &desc); + todo_wine + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + if (SUCCEEDED(hr)) + { + ok(!desc.Creator, "Unexpected creator %p.\n", desc.Creator); + ok(!desc.Parameters, "Unexpected parameter count %u.\n", desc.Parameters); + ok(!desc.Techniques, "Unexpected technique count %u.\n", desc.Techniques); + ok(desc.Functions == 3, "Unexpected function count %u.\n", desc.Functions); + } + + hfunc = compiler->lpVtbl->GetFunction(compiler, 0); + todo_wine + ok(!!hfunc, "Unexpected handle %p.\n", hfunc); + if (!hfunc) goto done; + + hr = compiler->lpVtbl->GetFunctionDesc(compiler, hfunc, &func_desc); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!strcmp(func_desc.Name, "main"), "Unexpected name %s.\n", func_desc.Name); + ok(!func_desc.Annotations, "Unexpected value %u.\n", func_desc.Annotations); + + hfunc = compiler->lpVtbl->GetFunction(compiler, 1); + ok(!!hfunc, "Unexpected handle %p.\n", hfunc); + + hr = compiler->lpVtbl->GetFunctionDesc(compiler, hfunc, &func_desc); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!strcmp(func_desc.Name, "func2"), "Unexpected name %s.\n", func_desc.Name); + ok(!func_desc.Annotations, "Unexpected value %u.\n", func_desc.Annotations); + + hfunc = compiler->lpVtbl->GetFunction(compiler, 2); + ok(!!hfunc, "Unexpected handle %p.\n", hfunc); + + hr = compiler->lpVtbl->GetFunctionDesc(compiler, hfunc, &func_desc); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(!strcmp(func_desc.Name, "func"), "Unexpected name %s.\n", func_desc.Name); + ok(!func_desc.Annotations, "Unexpected value %u.\n", func_desc.Annotations); + + hfunc = compiler->lpVtbl->GetFunction(compiler, 3); + ok(!hfunc, "Unexpected handle %p.\n", hfunc); + +done: + + refcount = compiler->lpVtbl->Release(compiler); + ok(!refcount, "Got unexpected refcount %lu.\n", refcount); } /* -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8147
This merge request was approved by Matteo Bruni. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/8147
participants (3)
-
Matteo Bruni (@Mystral) -
Nikolay Sivov -
Nikolay Sivov (@nsivov)