[PATCH 2/4] d3d8: Cleanup the stateblock test callbacks a bit.

Henri Verbeet hverbeet at codeweavers.com
Mon Oct 12 03:10:24 CDT 2009


This mostly just makes the naming more conistent with what we use in other D3D
code, but also passes the device to the init() and cleanup() callbacks to
allow device resources to be created there. Future tests require this.
---
 dlls/d3d8/tests/stateblock.c |   98 ++++++++++++++++++------------------------
 1 files changed, 42 insertions(+), 56 deletions(-)

diff --git a/dlls/d3d8/tests/stateblock.c b/dlls/d3d8/tests/stateblock.c
index 423a1eb..0e88ff4 100644
--- a/dlls/d3d8/tests/stateblock.c
+++ b/dlls/d3d8/tests/stateblock.c
@@ -123,14 +123,12 @@ struct state_test
     const void *test_data_out_vertex;
     const void *test_data_out_pixel;
 
-    /* Test resource management handlers */
-    HRESULT (*setup_handler)(struct state_test *test);
-    void (*teardown_handler)(struct state_test *test);
-
-    /* Test data handlers */
-    void (*set_handler)(IDirect3DDevice8 *device, const struct state_test *test, const void *data_in);
-    void (*check_data)(IDirect3DDevice8 *device, unsigned int chain_stage,
-            const struct state_test *test, const void *data_expected);
+    HRESULT (*init)(IDirect3DDevice8 *device, struct state_test *test);
+    void (*cleanup)(IDirect3DDevice8 *device, struct state_test *test);
+    void (*apply_data)(IDirect3DDevice8 *device, const struct state_test *test,
+            const void *data);
+    void (*check_data)(IDirect3DDevice8 *device, const struct state_test *test,
+            const void *data_expected, unsigned int chain_stage);
 
     /* Test arguments */
     const void *test_arg;
@@ -223,7 +221,7 @@ static void execute_test_chain(IDirect3DDevice8 *device, struct state_test *test
             for (i = 0; i < ntests; ++i)
             {
                 data = get_event_data(&test[i], event[j].check);
-                test[i].check_data(device, j, &test[i], data);
+                test[i].check_data(device, &test[i], data, j);
             }
         }
 
@@ -232,15 +230,15 @@ static void execute_test_chain(IDirect3DDevice8 *device, struct state_test *test
             for (i = 0; i < ntests; ++i)
             {
                 data = get_event_data(&test[i], event[j].apply);
-                test[i].set_handler(device, &test[i], data);
+                test[i].apply_data(device, &test[i], data);
             }
         }
     }
 
-     /* Attempt to reset any changes made */
-    for (i=0; i < ntests; i++)
+    /* Attempt to reset any changes made. */
+    for (i = 0; i < ntests; ++i)
     {
-        test[i].set_handler(device, &test[i], test[i].default_data);
+        test[i].apply_data(device, &test[i], test[i].default_data);
     }
 }
 
@@ -486,7 +484,7 @@ static void execute_test_chain_all(IDirect3DDevice8 *device, struct state_test *
     /* Setup each test for execution */
     for (i = 0; i < ntests; ++i)
     {
-        hr = test[i].setup_handler(&test[i]);
+        hr = test[i].init(device, &test[i]);
         ok(SUCCEEDED(hr), "Test \"%s\" failed setup, aborting\n", test[i].test_name);
         if (FAILED(hr)) return;
     }
@@ -533,7 +531,7 @@ static void execute_test_chain_all(IDirect3DDevice8 *device, struct state_test *
     /* Cleanup resources */
     for (i = 0; i < ntests; ++i)
     {
-        test[i].teardown_handler(&test[i]);
+        if (test[i].cleanup) test[i].cleanup(device, &test[i]);
     }
 }
 
@@ -565,7 +563,7 @@ static const struct shader_constant_data shader_constant_test_data =
     {5.0f, 6.0f, 7.0f, 8.0f},
 };
 
-static void shader_constant_set_handler(IDirect3DDevice8* device, const struct state_test *test, const void *data)
+static void shader_constant_apply_data(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
 {
     const struct shader_constant_data *scdata = data;
     const struct shader_constant_arg *scarg = test->test_arg;
@@ -584,8 +582,8 @@ static void shader_constant_set_handler(IDirect3DDevice8* device, const struct s
     }
 }
 
-static void shader_constant_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
-        const struct state_test *test, const void *expected_data)
+static void shader_constant_check_data(IDirect3DDevice8 *device, const struct state_test *test,
+        const void *expected_data, unsigned int chain_stage)
 {
     const struct shader_constant_data *scdata = expected_data;
     const struct shader_constant_arg *scarg = test->test_arg;
@@ -614,7 +612,7 @@ static void shader_constant_check_data(IDirect3DDevice8 *device, unsigned int ch
             value.float_constant[2], value.float_constant[3]);
 }
 
-static HRESULT shader_constant_setup_handler(struct state_test *test)
+static HRESULT shader_constant_test_init(IDirect3DDevice8 *device, struct state_test *test)
 {
     const struct shader_constant_arg *test_arg = test->test_arg;
 
@@ -637,15 +635,11 @@ static HRESULT shader_constant_setup_handler(struct state_test *test)
     return D3D_OK;
 }
 
-static void shader_constant_teardown_handler(struct state_test *test)
-{
-}
-
 static void shader_constants_queue_test(struct state_test *test, const struct shader_constant_arg *test_arg)
 {
-    test->setup_handler = shader_constant_setup_handler;
-    test->teardown_handler = shader_constant_teardown_handler;
-    test->set_handler = shader_constant_set_handler;
+    test->init = shader_constant_test_init;
+    test->cleanup = NULL;
+    test->apply_data = shader_constant_apply_data;
     test->check_data = shader_constant_check_data;
     test->test_name = test_arg->pshader ? "set_get_pshader_constants" : "set_get_vshader_constants";
     test->test_arg = test_arg;
@@ -749,7 +743,7 @@ static const struct light_data light_test_data_out =
     D3D_OK,
 };
 
-static void light_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
+static void light_apply_data(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
 {
     const struct light_data *ldata = data;
     const struct light_arg *larg = test->test_arg;
@@ -763,8 +757,8 @@ static void light_set_handler(IDirect3DDevice8 *device, const struct state_test
     ok(SUCCEEDED(hr), "SetLightEnable returned %#x.\n", hr);
 }
 
-static void light_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
-        const struct state_test *test, const void *expected_data)
+static void light_check_data(IDirect3DDevice8 *device, const struct state_test *test,
+        const void *expected_data, unsigned int chain_stage)
 {
     const struct light_arg *larg = test->test_arg;
     const struct light_data *ldata = expected_data;
@@ -840,7 +834,7 @@ static void light_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
             chain_stage, ldata->light.Phi, value.light.Phi);
 }
 
-static HRESULT light_setup_handler(struct state_test *test)
+static HRESULT light_test_init(IDirect3DDevice8 *device, struct state_test *test)
 {
     test->test_context = NULL;
     test->test_data_in = &light_test_data_in;
@@ -853,15 +847,11 @@ static HRESULT light_setup_handler(struct state_test *test)
     return D3D_OK;
 }
 
-static void light_teardown_handler(struct state_test *test)
-{
-}
-
 static void lights_queue_test(struct state_test *test, const struct light_arg *test_arg)
 {
-    test->setup_handler = light_setup_handler;
-    test->teardown_handler = light_teardown_handler;
-    test->set_handler = light_set_handler;
+    test->init = light_test_init;
+    test->cleanup = NULL;
+    test->apply_data = light_apply_data;
     test->check_data = light_check_data;
     test->test_name = "set_get_light";
     test->test_arg = test_arg;
@@ -1001,7 +991,7 @@ static const struct transform_data transform_test_data =
 };
 
 
-static void transform_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
+static void transform_apply_data(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
 {
     const struct transform_data *tdata = data;
     HRESULT hr;
@@ -1053,8 +1043,8 @@ static void compare_matrix(const char *name, unsigned int chain_stage,
             U(*received).m[0][3], U(*received).m[1][3], U(*received).m[2][3], U(*received).m[3][3]);
 }
 
-static void transform_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
-        const struct state_test *test, const void *expected_data)
+static void transform_check_data(IDirect3DDevice8 *device, const struct state_test *test,
+        const void *expected_data, unsigned int chain_stage)
 {
     const struct transform_data *tdata = expected_data;
     D3DMATRIX value;
@@ -1091,7 +1081,7 @@ static void transform_check_data(IDirect3DDevice8 *device, unsigned int chain_st
     compare_matrix("World255", chain_stage, &value, &tdata->world255);
 }
 
-static HRESULT transform_setup_handler(struct state_test *test)
+static HRESULT transform_test_init(IDirect3DDevice8 *device, struct state_test *test)
 {
     test->test_context = NULL;
     test->test_data_in = &transform_test_data;
@@ -1104,15 +1094,11 @@ static HRESULT transform_setup_handler(struct state_test *test)
     return D3D_OK;
 }
 
-static void transform_teardown_handler(struct state_test *test)
-{
-}
-
 static void transform_queue_test(struct state_test *test)
 {
-    test->setup_handler = transform_setup_handler;
-    test->teardown_handler = transform_teardown_handler;
-    test->set_handler = transform_set_handler;
+    test->init = transform_test_init;
+    test->cleanup = NULL;
+    test->apply_data = transform_apply_data;
     test->check_data = transform_check_data;
     test->test_name = "set_get_transforms";
     test->test_arg = NULL;
@@ -1216,7 +1202,7 @@ struct render_state_context
     struct render_state_data poison_data_buffer;
 };
 
-static void render_state_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
+static void render_state_apply_data(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
 {
     const struct render_state_data *rsdata = data;
     unsigned int i;
@@ -1229,8 +1215,8 @@ static void render_state_set_handler(IDirect3DDevice8 *device, const struct stat
     }
 }
 
-static void render_state_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
-        const struct state_test *test, const void *expected_data)
+static void render_state_check_data(IDirect3DDevice8 *device, const struct state_test *test,
+        const void *expected_data, unsigned int chain_stage)
 {
     const struct render_state_context *ctx = test->test_context;
     const struct render_state_data *rsdata = expected_data;
@@ -1414,7 +1400,7 @@ static void render_state_test_data_init(struct render_state_data *data)
     data->states[idx++] = D3DBLENDOP_REVSUBTRACT;/* BLENDOP */
 }
 
-static HRESULT render_state_setup_handler(struct state_test *test)
+static HRESULT render_state_test_init(IDirect3DDevice8 *device, struct state_test *test)
 {
     static const DWORD states_vertex[] =
     {
@@ -1539,16 +1525,16 @@ static HRESULT render_state_setup_handler(struct state_test *test)
     return D3D_OK;
 }
 
-static void render_state_teardown_handler(struct state_test *test)
+static void render_state_test_cleanup(IDirect3DDevice8 *device, struct state_test *test)
 {
     HeapFree(GetProcessHeap(), 0, test->test_context);
 }
 
 static void render_states_queue_test(struct state_test *test, const struct render_state_arg *test_arg)
 {
-    test->setup_handler = render_state_setup_handler;
-    test->teardown_handler = render_state_teardown_handler;
-    test->set_handler = render_state_set_handler;
+    test->init = render_state_test_init;
+    test->cleanup = render_state_test_cleanup;
+    test->apply_data = render_state_apply_data;
     test->check_data = render_state_check_data;
     test->test_name = "set_get_render_states";
     test->test_arg = test_arg;
-- 
1.6.4.4




More information about the wine-patches mailing list