Paul Gofman : d3dx9/tests: Factor out test_effect_preshader_compare_shader_bytecode() function.

Alexandre Julliard julliard at winehq.org
Thu May 4 18:06:27 CDT 2017


Module: wine
Branch: master
Commit: f525c218967e116bf28c2858ec61c5eff17e8fe1
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f525c218967e116bf28c2858ec61c5eff17e8fe1

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Fri May  5 00:03:48 2017 +0200

d3dx9/tests: Factor out test_effect_preshader_compare_shader_bytecode() function.

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3dx9_36/tests/effect.c | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c
index 3e9d255..baa2a7a 100644
--- a/dlls/d3dx9_36/tests/effect.c
+++ b/dlls/d3dx9_36/tests/effect.c
@@ -3987,6 +3987,33 @@ static const DWORD test_effect_preshader_effect_blob[] =
 #define TEST_EFFECT_PRESHADER_VSHADER_POS 2710
 #define TEST_EFFECT_PRESHADER_VSHADER_LEN 13
 
+#define test_effect_preshader_compare_shader_bytecode(a, b, c, d) \
+        test_effect_preshader_compare_shader_bytecode_(__LINE__, a, b, c, d)
+static void test_effect_preshader_compare_shader_bytecode_(unsigned int line,
+        const DWORD *bytecode, unsigned int bytecode_size, int expected_shader_index, BOOL todo)
+{
+    unsigned int i = 0;
+
+    todo_wine_if(todo)
+    ok_(__FILE__, line)(!!bytecode, "NULL shader bytecode.\n");
+
+    if (!bytecode)
+        return;
+
+    while (bytecode[i++] != 0x0000ffff)
+        ;
+
+    if (!bytecode_size)
+        bytecode_size = i * sizeof(*bytecode);
+    else
+        ok(i * sizeof(*bytecode) == bytecode_size, "Unexpected byte code size %u.\n", bytecode_size);
+
+    todo_wine_if(todo)
+    ok_(__FILE__, line)(!memcmp(bytecode, &test_effect_preshader_effect_blob[TEST_EFFECT_PRESHADER_VSHADER_POS
+            + expected_shader_index * TEST_EFFECT_PRESHADER_VSHADER_LEN], bytecode_size),
+            "Incorrect shader selected.\n");
+}
+
 #define test_effect_preshader_compare_shader(a, b, c) \
         test_effect_preshader_compare_shader_(__LINE__, a, b, c)
 static void test_effect_preshader_compare_shader_(unsigned int line, IDirect3DDevice9 *device,
@@ -4013,10 +4040,9 @@ static void test_effect_preshader_compare_shader_(unsigned int line, IDirect3DDe
     hr = IDirect3DVertexShader9_GetFunction(vshader, byte_code, &byte_code_size);
     ok_(__FILE__, line)(hr == D3D_OK, "Got result %#x.\n", hr);
 
-    todo_wine_if(todo)
-    ok_(__FILE__, line)(!memcmp(byte_code, &test_effect_preshader_effect_blob[TEST_EFFECT_PRESHADER_VSHADER_POS
-            + expected_shader_index * TEST_EFFECT_PRESHADER_VSHADER_LEN], byte_code_size),
-            "Incorrect shader selected.\n");
+    test_effect_preshader_compare_shader_bytecode_(line, byte_code,
+            byte_code_size, expected_shader_index, todo);
+
     HeapFree(GetProcessHeap(), 0, byte_code);
     IDirect3DVertexShader9_Release(vshader);
  }




More information about the wine-cvs mailing list