[PATCH v2 3/4] d3dx9/tests: Add more tests for ID3DXEffect::CloneEffect().

Zebediah Figura zfigura at codeweavers.com
Thu Feb 10 22:01:21 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/d3dx9_36/tests/effect.c | 221 +++++++++++++++++++++++++++++++++--
 1 file changed, 210 insertions(+), 11 deletions(-)

diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index 63321fba3b3..5a23819e28c 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -7413,20 +7413,91 @@ static void test_effect_null_shader(void)
 
 static void test_effect_clone(void)
 {
+    D3DXHANDLE parameter, parameter2, technique, technique2, block, annotation;
     IDirect3DDevice9 *device, *device2, *device3;
+    IDirect3DBaseTexture9 *texture, *texture2;
     ID3DXEffect *effect, *cloned;
+    unsigned int passes_count;
     HWND window, window2;
+    const char *string;
     ULONG refcount;
     HRESULT hr;
+    float f;
+
+    static const DWORD effect_code[] =
+    {
+#if 0
+        Texture2D tex;
+        float f <float a = 1.0>;
+
+        float4 vs_main(float4 pos : POSITION) : POSITION
+        {
+            return pos;
+        }
+
+        technique tech0 <float a = 1.0;>
+        {
+            pass p
+            {
+                VertexShader = compile vs_2_0 vs_main();
+            }
+        }
+
+        technique tech1
+        {
+            pass p
+            {
+                VertexShader = compile vs_2_0 vs_main();
+            }
+        }
+#endif
+        0xfeff0901, 0x00000114, 0x00000000, 0x00000007, 0x00000004, 0x0000001c, 0x00000000, 0x00000000,
+        0x00000001, 0x00000004, 0x00786574, 0x00000004, 0x00000004, 0x0000003c, 0x00000000, 0x00000000,
+        0x00000002, 0x00000002, 0x00000073, 0x00000003, 0x00000000, 0x0000008c, 0x00000000, 0x00000000,
+        0x00000001, 0x00000001, 0x00000000, 0x3f800000, 0x00000003, 0x00000000, 0x00000084, 0x00000000,
+        0x00000000, 0x00000001, 0x00000001, 0x00000002, 0x00000061, 0x00000002, 0x00000066, 0x3f800000,
+        0x00000003, 0x00000000, 0x000000b4, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x00000002,
+        0x00000061, 0x00000003, 0x00000010, 0x00000004, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+        0x00000070, 0x00000006, 0x68636574, 0x00000030, 0x00000004, 0x00000010, 0x00000004, 0x00000000,
+        0x00000000, 0x00000000, 0x00000002, 0x00000070, 0x00000006, 0x68636574, 0x00000031, 0x00000003,
+        0x00000002, 0x00000004, 0x00000005, 0x00000004, 0x00000018, 0x00000000, 0x00000000, 0x00000024,
+        0x00000038, 0x00000000, 0x00000000, 0x00000044, 0x00000060, 0x00000000, 0x00000001, 0x00000068,
+        0x00000064, 0x000000dc, 0x00000001, 0x00000001, 0x00000098, 0x00000094, 0x000000d4, 0x00000000,
+        0x00000001, 0x00000092, 0x00000000, 0x000000c0, 0x000000bc, 0x00000108, 0x00000000, 0x00000001,
+        0x00000100, 0x00000000, 0x00000001, 0x00000092, 0x00000000, 0x000000ec, 0x000000e8, 0x00000002,
+        0x00000002, 0x00000002, 0x00000000, 0x00000001, 0x00000000, 0x00000001, 0x00000000, 0xffffffff,
+        0x00000000, 0x00000000, 0x00000074, 0xfffe0200, 0x0014fffe, 0x42415443, 0x0000001c, 0x00000023,
+        0xfffe0200, 0x00000000, 0x00000000, 0x20000400, 0x0000001c, 0x325f7376, 0x4d00305f, 0x6f726369,
+        0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x30312072,
+        0xab00312e, 0x0200001f, 0x80000000, 0x900f0000, 0x02000001, 0xc00f0000, 0x90e40000, 0x0000ffff,
+        0x00000000, 0x00000000, 0xffffffff, 0x00000000, 0x00000000, 0x00000074, 0xfffe0200, 0x0014fffe,
+        0x42415443, 0x0000001c, 0x00000023, 0xfffe0200, 0x00000000, 0x00000000, 0x20000400, 0x0000001c,
+        0x325f7376, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461,
+        0x6d6f4320, 0x656c6970, 0x30312072, 0xab00312e, 0x0200001f, 0x80000000, 0x900f0000, 0x02000001,
+        0xc00f0000, 0x90e40000, 0x0000ffff,
+    };
 
     if (!(device = create_device(&window)))
         return;
 
+    hr = IDirect3DDevice9_CreateTexture(device, 16, 16, 1, 0, D3DFMT_X8R8G8B8,
+            D3DPOOL_DEFAULT, (IDirect3DTexture9 **)&texture, NULL);
+    ok(hr == D3D_OK, "Failed to create texture, hr %#x.\n", hr);
+
     /* D3DXFX_NOT_CLONEABLE */
-    hr = D3DXCreateEffect(device, test_effect_preshader_effect_blob, sizeof(test_effect_preshader_effect_blob),
+    hr = D3DXCreateEffect(device, effect_code, sizeof(effect_code),
             NULL, NULL, D3DXFX_NOT_CLONEABLE, NULL, &effect, NULL);
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
 
+    technique = effect->lpVtbl->GetTechniqueByName(effect, "tech0");
+    ok(!!technique, "Expected a technique.\n");
+
+    technique2 = effect->lpVtbl->GetCurrentTechnique(effect);
+    ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
+
+    hr = effect->lpVtbl->SetTechnique(effect, "tech1");
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
     hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
     ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
 
@@ -7445,10 +7516,33 @@ static void test_effect_clone(void)
 
     effect->lpVtbl->Release(effect);
 
-    hr = D3DXCreateEffect(device, test_effect_preshader_effect_blob, sizeof(test_effect_preshader_effect_blob),
+    hr = D3DXCreateEffect(device, effect_code, sizeof(effect_code),
             NULL, NULL, 0, NULL, &effect, NULL);
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
 
+    hr = effect->lpVtbl->SetTexture(effect, "tex", texture);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->SetFloat(effect, "f", 123.0f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->SetString(effect, "s", "tiny silver hammers");
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->SetFloat(effect, "f at a", 4.0f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    annotation = effect->lpVtbl->GetAnnotationByName(effect, "tech0", "a");
+    ok(!!annotation, "Failed to get annotation.\n");
+    hr = effect->lpVtbl->SetFloat(effect, annotation, 4.0f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex");
+    ok(!!parameter, "Failed to get parameter.\n");
+
+    hr = effect->lpVtbl->Begin(effect, &passes_count, 0);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
     hr = effect->lpVtbl->CloneEffect(effect, NULL, NULL);
     ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
 
@@ -7461,20 +7555,57 @@ static void test_effect_clone(void)
     ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
 
     hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
-todo_wine
-    ok(hr == D3D_OK, "Got result %#x.\n", hr);
-if (hr == D3D_OK)
-{
+    todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    if (hr != D3D_OK)
+        goto out;
     ok(cloned != effect, "Expected new effect instance.\n");
+
+    hr = cloned->lpVtbl->GetTexture(cloned, "tex", &texture2);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(texture2 == texture, "Expected the same texture.\n");
+    IDirect3DBaseTexture9_Release(texture2);
+
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, "f", &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 123.0f, "Got float %.8e.\n", f);
+
+    hr = cloned->lpVtbl->GetString(cloned, "s", &string);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(!strcmp(string, "tiny silver hammers"), "Got string %s.\n", debugstr_a(string));
+
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, "f at a", &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 4.0f, "Got float %.8e.\n", f);
+
+    annotation = cloned->lpVtbl->GetAnnotationByName(cloned, "tech0", "a");
+    ok(!!annotation, "Failed to get annotation.\n");
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, annotation, &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 4.0f, "Got float %.8e.\n", f);
+
+    parameter2 = cloned->lpVtbl->GetParameterByName(cloned, NULL, "tex");
+    ok(!!parameter2, "Failed to get parameter.\n");
+    ok(parameter2 != parameter, "Parameters should not match.\n");
+
+    hr = cloned->lpVtbl->BeginPass(cloned, 0);
+    ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
+
+    technique = cloned->lpVtbl->GetTechniqueByName(cloned, "tech0");
+    ok(!!technique, "Expected a technique.\n");
+
+    technique2 = cloned->lpVtbl->GetCurrentTechnique(cloned);
+    ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
+
     cloned->lpVtbl->Release(cloned);
-}
+
     /* Try with different device. */
     device2 = create_device(&window2);
+
     hr = effect->lpVtbl->CloneEffect(effect, device2, &cloned);
-todo_wine
     ok(hr == D3D_OK, "Got result %#x.\n", hr);
-if (hr == D3D_OK)
-{
     ok(cloned != effect, "Expected new effect instance.\n");
 
     hr = cloned->lpVtbl->GetDevice(cloned, &device3);
@@ -7482,11 +7613,79 @@ if (hr == D3D_OK)
     ok(device3 == device2, "Unexpected device instance.\n");
     IDirect3DDevice9_Release(device3);
 
+    hr = cloned->lpVtbl->GetTexture(cloned, "tex", &texture2);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(!texture2, "Expected a NULL texture.\n");
+
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, "f", &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 123.0f, "Got float %.8e.\n", f);
+
+    hr = cloned->lpVtbl->GetString(cloned, "s", &string);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(!strcmp(string, "tiny silver hammers"), "Got string %s.\n", debugstr_a(string));
+
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, "f at a", &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 4.0f, "Got float %.8e.\n", f);
+
+    annotation = cloned->lpVtbl->GetAnnotationByName(cloned, "tech0", "a");
+    ok(!!annotation, "Failed to get annotation.\n");
+    f = 0.0f;
+    hr = cloned->lpVtbl->GetFloat(cloned, annotation, &f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    ok(f == 4.0f, "Got float %.8e.\n", f);
+
+    parameter2 = cloned->lpVtbl->GetParameterByName(cloned, NULL, "tex");
+    ok(!!parameter2, "Failed to get parameter.\n");
+    ok(parameter2 != parameter, "Parameters should not match.\n");
+
+    hr = cloned->lpVtbl->BeginPass(cloned, 0);
+    ok(hr == D3DERR_INVALIDCALL, "Got result %#x.\n", hr);
+
+    technique = cloned->lpVtbl->GetTechniqueByName(cloned, "tech0");
+    ok(!!technique, "Expected a technique.\n");
+
+    technique2 = cloned->lpVtbl->GetCurrentTechnique(cloned);
+    ok(technique2 == technique, "Got unexpected technique %p.\n", technique2);
+
     cloned->lpVtbl->Release(cloned);
-}
+
+    hr = effect->lpVtbl->BeginPass(effect, 0);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->EndPass(effect);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->End(effect);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    /* Test parameter blocks (we can't do this above since we can't record a
+     * parameter block while started). */
+
+    hr = effect->lpVtbl->BeginParameterBlock(effect);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->SetFloat(effect, "f", 456.0f);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+
+    hr = effect->lpVtbl->CloneEffect(effect, device, &cloned);
+    ok(hr == D3D_OK, "Got result %#x.\n", hr);
+    block = cloned->lpVtbl->EndParameterBlock(cloned);
+    ok(!block, "Expected no active parameter block.\n");
+
+    cloned->lpVtbl->Release(cloned);
+
+    block = effect->lpVtbl->EndParameterBlock(effect);
+    ok(!!block, "Expected an active parameter block.\n");
+
     IDirect3DDevice9_Release(device2);
     DestroyWindow(window2);
+out:
     effect->lpVtbl->Release(effect);
+    IDirect3DBaseTexture9_Release(texture);
     refcount = IDirect3DDevice9_Release(device);
     ok(!refcount, "Device has %u references left.\n", refcount);
     DestroyWindow(window);
-- 
2.34.1




More information about the wine-devel mailing list