d3d8: Make the individual stateblock tests responsible for checking data.

This commit is contained in:
Henri Verbeet 2009-10-05 09:47:37 +02:00 committed by Alexandre Julliard
parent d818e4edf6
commit 6dd6074f60
1 changed files with 227 additions and 241 deletions

View File

@ -121,23 +121,14 @@ struct state_test
const void *test_data_in;
const void *test_data_out;
/* The poison data is the data to preinitialize the return buffer to */
const void *poison_data;
/* Return buffer */
void *return_data;
/* Size of the data samples above */
unsigned int data_size;
/* 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 (*get_handler)(IDirect3DDevice8 *device, const struct state_test *test, void *data_out);
void (*print_handler)(const struct state_test *test, const void *data);
void (*check_data)(IDirect3DDevice8 *device, unsigned int chain_stage,
const struct state_test *test, const void *data_expected);
/* Test arguments */
const void *test_arg;
@ -199,50 +190,17 @@ static void execute_test_chain(IDirect3DDevice8 *device, struct state_test *test
{
for (i = 0; i < ntests; ++i)
{
memcpy(test[i].return_data, test[i].poison_data, test[i].data_size);
test[i].get_handler(device, &test[i], test[i].return_data);
if (outcome & EVENT_CHECK_TEST)
{
BOOL test_failed = memcmp(test[i].test_data_out, test[i].return_data, test[i].data_size);
ok(!test_failed, "Test %s, Stage %u: returned data does not match test data [csize=%u]\n",
test[i].test_name, j, test[i].data_size);
if (test_failed && test[i].print_handler)
{
trace("Returned data was:\n");
test[i].print_handler(&test[i], test[i].return_data);
trace("Test data was:\n");
test[i].print_handler(&test[i], test[i].test_data_out);
}
test[i].check_data(device, j, &test[i], test[i].test_data_out);
}
else if (outcome & EVENT_CHECK_DEFAULT)
{
BOOL test_failed = memcmp(test[i].default_data, test[i].return_data, test[i].data_size);
ok(!test_failed, "Test %s, Stage %u: returned data does not match default data [csize=%u]\n",
test[i].test_name, j, test[i].data_size);
if (test_failed && test[i].print_handler)
{
trace("Returned data was:\n");
test[i].print_handler(&test[i], test[i].return_data);
trace("Default data was:\n");
test[i].print_handler(&test[i], test[i].default_data);
}
test[i].check_data(device, j, &test[i], test[i].default_data);
}
else if (outcome & EVENT_CHECK_INITIAL)
{
BOOL test_failed = memcmp(test[i].initial_data, test[i].return_data, test[i].data_size);
ok(!test_failed, "Test %s, Stage %u: returned data does not match initial data [csize=%u]\n",
test[i].test_name, j, test[i].data_size);
if (test_failed && test[i].print_handler)
{
trace("Returned data was:\n");
test[i].print_handler(&test[i], test[i].return_data);
trace("Initial data was:\n");
test[i].print_handler(&test[i], test[i].initial_data);
}
test[i].check_data(device, j, &test[i], test[i].initial_data);
}
}
}
@ -484,14 +442,20 @@ struct shader_constant_context
struct shader_constant_data return_data_buffer;
};
static void shader_constant_print_handler(const struct state_test *test, const void *data)
static const struct shader_constant_data shader_constant_poison_data =
{
const struct shader_constant_data *scdata = data;
{1.0f, 2.0f, 3.0f, 4.0f},
};
trace("Float constant = { %f, %f, %f, %f }\n",
scdata->float_constant[0], scdata->float_constant[1],
scdata->float_constant[2], scdata->float_constant[3]);
}
static const struct shader_constant_data shader_constant_default_data =
{
{0.0f, 0.0f, 0.0f, 0.0f},
};
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)
{
@ -512,55 +476,46 @@ static void shader_constant_set_handler(IDirect3DDevice8* device, const struct s
}
}
static void shader_constant_get_handler(IDirect3DDevice8* device, const struct state_test *test, void *data)
static void shader_constant_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
const struct state_test *test, const void *expected_data)
{
struct shader_constant_data *scdata = data;
const struct shader_constant_data *scdata = expected_data;
const struct shader_constant_arg *scarg = test->test_arg;
unsigned int index = scarg->idx;
struct shader_constant_data value;
HRESULT hr;
value = shader_constant_poison_data;
if (!scarg->pshader)
{
hr = IDirect3DDevice8_GetVertexShaderConstant(device, index, scdata->float_constant, 1);
hr = IDirect3DDevice8_GetVertexShaderConstant(device, scarg->idx, value.float_constant, 1);
ok(SUCCEEDED(hr), "GetVertexShaderConstant returned %#x.\n", hr);
}
else
{
hr = IDirect3DDevice8_GetPixelShaderConstant(device, index, scdata->float_constant, 1);
hr = IDirect3DDevice8_GetPixelShaderConstant(device, scarg->idx, value.float_constant, 1);
ok(SUCCEEDED(hr), "GetPixelShaderConstant returned %#x.\n", hr);
}
ok(!memcmp(value.float_constant, scdata->float_constant, sizeof(scdata->float_constant)),
"Chain stage %u, %s constant:\n\t{%.8e, %.8e, %.8e, %.8e} expected\n\t{%.8e, %.8e, %.8e, %.8e} received\n",
chain_stage, scarg->pshader ? "pixel shader" : "vertex shader",
scdata->float_constant[0], scdata->float_constant[1],
scdata->float_constant[2], scdata->float_constant[3],
value.float_constant[0], value.float_constant[1],
value.float_constant[2], value.float_constant[3]);
}
static const struct shader_constant_data shader_constant_poison_data =
{
{1.0f, 2.0f, 3.0f, 4.0f},
};
static const struct shader_constant_data shader_constant_default_data =
{
{0.0f, 0.0f, 0.0f, 0.0f},
};
static const struct shader_constant_data shader_constant_test_data =
{
{5.0f, 6.0f, 7.0f, 8.0f},
};
static HRESULT shader_constant_setup_handler(struct state_test *test)
{
struct shader_constant_context *ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx));
if (!ctx) return E_FAIL;
test->test_context = ctx;
test->return_data = &ctx->return_data_buffer;
test->test_data_in = &shader_constant_test_data;
test->test_data_out = &shader_constant_test_data;
test->default_data = &shader_constant_default_data;
test->initial_data = &shader_constant_default_data;
test->poison_data = &shader_constant_poison_data;
test->data_size = sizeof(struct shader_constant_data);
return D3D_OK;
}
@ -575,8 +530,7 @@ static void shader_constants_queue_test(struct state_test *test, const struct sh
test->setup_handler = shader_constant_setup_handler;
test->teardown_handler = shader_constant_teardown_handler;
test->set_handler = shader_constant_set_handler;
test->get_handler = shader_constant_get_handler;
test->print_handler = shader_constant_print_handler;
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;
}
@ -601,65 +555,6 @@ struct light_context
struct light_data return_data_buffer;
};
static void light_print_handler(const struct state_test *test, const void *data)
{
const struct light_data *ldata = data;
trace("Get Light return value: %#x\n", ldata->get_light_result);
trace("Get Light enable return value: %#x\n", ldata->get_enabled_result);
trace("Light Enabled = %u\n", ldata->enabled);
trace("Light Type = %u\n", ldata->light.Type);
trace("Light Diffuse = { %f, %f, %f, %f }\n",
ldata->light.Diffuse.r, ldata->light.Diffuse.g,
ldata->light.Diffuse.b, ldata->light.Diffuse.a);
trace("Light Specular = { %f, %f, %f, %f}\n",
ldata->light.Specular.r, ldata->light.Specular.g,
ldata->light.Specular.b, ldata->light.Specular.a);
trace("Light Ambient = { %f, %f, %f, %f }\n",
ldata->light.Ambient.r, ldata->light.Ambient.g,
ldata->light.Ambient.b, ldata->light.Ambient.a);
trace("Light Position = { %f, %f, %f }\n",
ldata->light.Position.x, ldata->light.Position.y, ldata->light.Position.z);
trace("Light Direction = { %f, %f, %f }\n",
ldata->light.Direction.x, ldata->light.Direction.y, ldata->light.Direction.z);
trace("Light Range = %f\n", ldata->light.Range);
trace("Light Fallof = %f\n", ldata->light.Falloff);
trace("Light Attenuation0 = %f\n", ldata->light.Attenuation0);
trace("Light Attenuation1 = %f\n", ldata->light.Attenuation1);
trace("Light Attenuation2 = %f\n", ldata->light.Attenuation2);
trace("Light Theta = %f\n", ldata->light.Theta);
trace("Light Phi = %f\n", ldata->light.Phi);
}
static void light_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
{
const struct light_data *ldata = data;
const struct light_arg *larg = test->test_arg;
unsigned int index = larg->idx;
HRESULT hr;
hr = IDirect3DDevice8_SetLight(device, index, &ldata->light);
ok(SUCCEEDED(hr), "SetLight returned %#x.\n", hr);
hr = IDirect3DDevice8_LightEnable(device, index, ldata->enabled);
ok(SUCCEEDED(hr), "SetLightEnable returned %#x.\n", hr);
}
static void light_get_handler(IDirect3DDevice8 *device, const struct state_test *test, void *data)
{
struct light_data *ldata = data;
const struct light_arg *larg = test->test_arg;
unsigned int index = larg->idx;
HRESULT hr;
hr = IDirect3DDevice8_GetLightEnable(device, index, &ldata->enabled);
ldata->get_enabled_result = hr;
hr = IDirect3DDevice8_GetLight(device, index, &ldata->light);
ldata->get_light_result = hr;
}
static const struct light_data light_poison_data =
{
{
@ -743,20 +638,107 @@ 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)
{
const struct light_data *ldata = data;
const struct light_arg *larg = test->test_arg;
unsigned int index = larg->idx;
HRESULT hr;
hr = IDirect3DDevice8_SetLight(device, index, &ldata->light);
ok(SUCCEEDED(hr), "SetLight returned %#x.\n", hr);
hr = IDirect3DDevice8_LightEnable(device, index, ldata->enabled);
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)
{
const struct light_arg *larg = test->test_arg;
const struct light_data *ldata = expected_data;
struct light_data value;
value = light_poison_data;
value.get_enabled_result = IDirect3DDevice8_GetLightEnable(device, larg->idx, &value.enabled);
value.get_light_result = IDirect3DDevice8_GetLight(device, larg->idx, &value.light);
ok(value.get_enabled_result == ldata->get_enabled_result,
"Chain stage %u: expected get_enabled_result %#x, got %#x.\n",
chain_stage, ldata->get_enabled_result, value.get_enabled_result);
ok(value.get_light_result == ldata->get_light_result,
"Chain stage %u: expected get_light_result %#x, got %#x.\n",
chain_stage, ldata->get_light_result, value.get_light_result);
ok(value.enabled == ldata->enabled,
"Chain stage %u: expected enabled %#x, got %#x.\n",
chain_stage, ldata->enabled, value.enabled);
ok(value.light.Type == ldata->light.Type,
"Chain stage %u: expected light.Type %#x, got %#x.\n",
chain_stage, ldata->light.Type, value.light.Type);
ok(!memcmp(&value.light.Diffuse, &ldata->light.Diffuse, sizeof(value.light.Diffuse)),
"Chain stage %u, light.Diffuse:\n\t{%.8e, %.8e, %.8e, %.8e} expected\n"
"\t{%.8e, %.8e, %.8e, %.8e} received.\n", chain_stage,
ldata->light.Diffuse.r, ldata->light.Diffuse.g,
ldata->light.Diffuse.b, ldata->light.Diffuse.a,
value.light.Diffuse.r, value.light.Diffuse.g,
value.light.Diffuse.b, value.light.Diffuse.a);
ok(!memcmp(&value.light.Specular, &ldata->light.Specular, sizeof(value.light.Specular)),
"Chain stage %u, light.Specular:\n\t{%.8e, %.8e, %.8e, %.8e} expected\n"
"\t{%.8e, %.8e, %.8e, %.8e} received.\n", chain_stage,
ldata->light.Specular.r, ldata->light.Specular.g,
ldata->light.Specular.b, ldata->light.Specular.a,
value.light.Specular.r, value.light.Specular.g,
value.light.Specular.b, value.light.Specular.a);
ok(!memcmp(&value.light.Ambient, &ldata->light.Ambient, sizeof(value.light.Ambient)),
"Chain stage %u, light.Ambient:\n\t{%.8e, %.8e, %.8e, %.8e} expected\n"
"\t{%.8e, %.8e, %.8e, %.8e} received.\n", chain_stage,
ldata->light.Ambient.r, ldata->light.Ambient.g,
ldata->light.Ambient.b, ldata->light.Ambient.a,
value.light.Ambient.r, value.light.Ambient.g,
value.light.Ambient.b, value.light.Ambient.a);
ok(!memcmp(&value.light.Position, &ldata->light.Position, sizeof(value.light.Position)),
"Chain stage %u, light.Position:\n\t{%.8e, %.8e, %.8e} expected\n\t{%.8e, %.8e, %.8e} received.\n",
chain_stage, ldata->light.Position.x, ldata->light.Position.y, ldata->light.Position.z,
value.light.Position.x, value.light.Position.y, value.light.Position.z);
ok(!memcmp(&value.light.Direction, &ldata->light.Direction, sizeof(value.light.Direction)),
"Chain stage %u, light.Direction:\n\t{%.8e, %.8e, %.8e} expected\n\t{%.8e, %.8e, %.8e} received.\n",
chain_stage, ldata->light.Direction.x, ldata->light.Direction.y, ldata->light.Direction.z,
value.light.Direction.x, value.light.Direction.y, value.light.Direction.z);
ok(value.light.Range == ldata->light.Range,
"Chain stage %u: expected light.Range %.8e, got %.8e.\n",
chain_stage, ldata->light.Range, value.light.Range);
ok(value.light.Falloff == ldata->light.Falloff,
"Chain stage %u: expected light.Falloff %.8e, got %.8e.\n",
chain_stage, ldata->light.Falloff, value.light.Falloff);
ok(value.light.Attenuation0 == ldata->light.Attenuation0,
"Chain stage %u: expected light.Attenuation0 %.8e, got %.8e.\n",
chain_stage, ldata->light.Attenuation0, value.light.Attenuation0);
ok(value.light.Attenuation1 == ldata->light.Attenuation1,
"Chain stage %u: expected light.Attenuation1 %.8e, got %.8e.\n",
chain_stage, ldata->light.Attenuation1, value.light.Attenuation1);
ok(value.light.Attenuation2 == ldata->light.Attenuation2,
"Chain stage %u: expected light.Attenuation2 %.8e, got %.8e.\n",
chain_stage, ldata->light.Attenuation2, value.light.Attenuation2);
ok(value.light.Theta == ldata->light.Theta,
"Chain stage %u: expected light.Theta %.8e, got %.8e.\n",
chain_stage, ldata->light.Theta, value.light.Theta);
ok(value.light.Phi == ldata->light.Phi,
"Chain stage %u: expected light.Phi %.8e, got %.8e.\n",
chain_stage, ldata->light.Phi, value.light.Phi);
}
static HRESULT light_setup_handler(struct state_test *test)
{
struct light_context *ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx));
if (!ctx) return E_FAIL;
test->test_context = ctx;
test->return_data = &ctx->return_data_buffer;
test->test_data_in = &light_test_data_in;
test->test_data_out = &light_test_data_out;
test->default_data = &light_default_data;
test->initial_data = &light_initial_data;
test->poison_data = &light_poison_data;
test->data_size = sizeof(struct light_data);
return D3D_OK;
}
@ -771,8 +753,7 @@ static void lights_queue_test(struct state_test *test, const struct light_arg *t
test->setup_handler = light_setup_handler;
test->teardown_handler = light_teardown_handler;
test->set_handler = light_set_handler;
test->get_handler = light_get_handler;
test->print_handler = light_print_handler;
test->check_data = light_check_data;
test->test_name = "set_get_light";
test->test_arg = test_arg;
}
@ -794,76 +775,6 @@ struct transform_context
struct transform_data return_data_buffer;
};
static inline void print_matrix(const char *name, const D3DMATRIX *matrix)
{
trace("%s Matrix =\n{\n", name);
trace(" %f %f %f %f\n", U(*matrix).m[0][0], U(*matrix).m[1][0], U(*matrix).m[2][0], U(*matrix).m[3][0]);
trace(" %f %f %f %f\n", U(*matrix).m[0][1], U(*matrix).m[1][1], U(*matrix).m[2][1], U(*matrix).m[3][1]);
trace(" %f %f %f %f\n", U(*matrix).m[0][2], U(*matrix).m[1][2], U(*matrix).m[2][2], U(*matrix).m[3][2]);
trace(" %f %f %f %f\n", U(*matrix).m[0][3], U(*matrix).m[1][3], U(*matrix).m[2][3], U(*matrix).m[3][3]);
trace("}\n");
}
static void transform_print_handler(const struct state_test *test, const void *data)
{
const struct transform_data *tdata = data;
print_matrix("View", &tdata->view);
print_matrix("Projection", &tdata->projection);
print_matrix("Texture0", &tdata->texture0);
print_matrix("Texture7", &tdata->texture7);
print_matrix("World0", &tdata->world0);
print_matrix("World255", &tdata->world255);
}
static void transform_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
{
const struct transform_data *tdata = data;
HRESULT hr;
hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &tdata->view);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &tdata->projection);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0, &tdata->texture0);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &tdata->texture7);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &tdata->world0);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(255), &tdata->world255);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
}
static void transform_get_handler(IDirect3DDevice8 *device, const struct state_test *test, void *data)
{
struct transform_data *tdata = data;
HRESULT hr;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_VIEW, &tdata->view);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_GetTransform(device, D3DTS_PROJECTION, &tdata->projection);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_GetTransform(device, D3DTS_TEXTURE0, &tdata->texture0);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_GetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &tdata->texture7);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_GetTransform(device, D3DTS_WORLD, &tdata->world0);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_GetTransform(device, D3DTS_WORLDMATRIX(255), &tdata->world255);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
}
static const struct transform_data transform_default_data =
{
{{{
@ -985,20 +896,107 @@ static const struct transform_data transform_test_data =
}}},
};
static void transform_set_handler(IDirect3DDevice8 *device, const struct state_test *test, const void *data)
{
const struct transform_data *tdata = data;
HRESULT hr;
hr = IDirect3DDevice8_SetTransform(device, D3DTS_VIEW, &tdata->view);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_PROJECTION, &tdata->projection);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0, &tdata->texture0);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &tdata->texture7);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLD, &tdata->world0);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
hr = IDirect3DDevice8_SetTransform(device, D3DTS_WORLDMATRIX(255), &tdata->world255);
ok(SUCCEEDED(hr), "SetTransform returned %#x.\n", hr);
}
static void compare_matrix(const char *name, unsigned int chain_stage,
const D3DMATRIX *received, const D3DMATRIX *expected)
{
ok(!memcmp(expected, received, sizeof(*expected)),
"Chain stage %u, matrix %s:\n"
"\t{\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t} expected\n"
"\t{\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t\t%.8e, %.8e, %.8e, %.8e,\n"
"\t} received\n",
chain_stage, name,
U(*expected).m[0][0], U(*expected).m[1][0], U(*expected).m[2][0], U(*expected).m[3][0],
U(*expected).m[0][1], U(*expected).m[1][1], U(*expected).m[2][1], U(*expected).m[3][1],
U(*expected).m[0][2], U(*expected).m[1][2], U(*expected).m[2][2], U(*expected).m[3][2],
U(*expected).m[0][3], U(*expected).m[1][3], U(*expected).m[2][3], U(*expected).m[3][3],
U(*received).m[0][0], U(*received).m[1][0], U(*received).m[2][0], U(*received).m[3][0],
U(*received).m[0][1], U(*received).m[1][1], U(*received).m[2][1], U(*received).m[3][1],
U(*received).m[0][2], U(*received).m[1][2], U(*received).m[2][2], U(*received).m[3][2],
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)
{
const struct transform_data *tdata = expected_data;
D3DMATRIX value;
HRESULT hr;
value = transform_poison_data.view;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_VIEW, &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("View", chain_stage, &value, &tdata->view);
value = transform_poison_data.projection;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_PROJECTION, &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("Projection", chain_stage, &value, &tdata->projection);
value = transform_poison_data.texture0;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_TEXTURE0, &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("Texture0", chain_stage, &value, &tdata->texture0);
value = transform_poison_data.texture7;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_TEXTURE0 + texture_stages - 1, &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("Texture7", chain_stage, &value, &tdata->texture7);
value = transform_poison_data.world0;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_WORLD, &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("World0", chain_stage, &value, &tdata->world0);
value = transform_poison_data.world255;
hr = IDirect3DDevice8_GetTransform(device, D3DTS_WORLDMATRIX(255), &value);
ok(SUCCEEDED(hr), "GetTransform returned %#x.\n", hr);
compare_matrix("World255", chain_stage, &value, &tdata->world255);
}
static HRESULT transform_setup_handler(struct state_test *test)
{
struct transform_context *ctx = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ctx));
if (!ctx) return E_FAIL;
test->test_context = ctx;
test->return_data = &ctx->return_data_buffer;
test->test_data_in = &transform_test_data;
test->test_data_out = &transform_test_data;
test->default_data = &transform_default_data;
test->initial_data = &transform_default_data;
test->poison_data = &transform_poison_data;
test->data_size = sizeof(struct transform_data);
return D3D_OK;
}
@ -1013,8 +1011,7 @@ 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->get_handler = transform_get_handler;
test->print_handler = transform_print_handler;
test->check_data = transform_check_data;
test->test_name = "set_get_transforms";
test->test_arg = NULL;
}
@ -1127,27 +1124,21 @@ static void render_state_set_handler(IDirect3DDevice8 *device, const struct stat
}
}
static void render_state_get_handler(IDirect3DDevice8 *device, const struct state_test *test, void *data)
static void render_state_check_data(IDirect3DDevice8 *device, unsigned int chain_stage,
const struct state_test *test, const void *expected_data)
{
struct render_state_data* rsdata = data;
const struct render_state_context *ctx = test->test_context;
const struct render_state_data *rsdata = expected_data;
unsigned int i;
HRESULT hr;
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
{
hr = IDirect3DDevice8_GetRenderState(device, render_state_indices[i], &rsdata->states[i]);
DWORD value = ctx->poison_data_buffer.states[i];
hr = IDirect3DDevice8_GetRenderState(device, render_state_indices[i], &value);
ok(SUCCEEDED(hr), "GetRenderState returned %#x.\n", hr);
}
}
static void render_state_print_handler(const struct state_test *test, const void *data)
{
const struct render_state_data *rsdata = data;
unsigned int i;
for (i = 0; i < sizeof(render_state_indices) / sizeof(*render_state_indices); ++i)
{
trace("Index = %u, Value = %#x\n", i, rsdata->states[i]);
ok(value == rsdata->states[i], "Chain stage %u, render state %#x: expected %#x, got %#x.\n",
chain_stage, render_state_indices[i], rsdata->states[i], value);
}
}
@ -1326,19 +1317,15 @@ static HRESULT render_state_setup_handler(struct state_test *test)
if (!ctx) return E_FAIL;
test->test_context = ctx;
test->return_data = &ctx->return_data_buffer;
test->default_data = &ctx->default_data_buffer;
test->initial_data = &ctx->default_data_buffer;
test->test_data_in = &ctx->test_data_buffer;
test->test_data_out = &ctx->test_data_buffer;
test->poison_data = &ctx->poison_data_buffer;
render_state_default_data_init(rsarg, &ctx->default_data_buffer);
render_state_test_data_init(&ctx->test_data_buffer);
render_state_poison_data_init(&ctx->poison_data_buffer);
test->data_size = sizeof(struct render_state_data);
return D3D_OK;
}
@ -1352,8 +1339,7 @@ static void render_states_queue_test(struct state_test *test, const struct rende
test->setup_handler = render_state_setup_handler;
test->teardown_handler = render_state_teardown_handler;
test->set_handler = render_state_set_handler;
test->get_handler = render_state_get_handler;
test->print_handler = render_state_print_handler;
test->check_data = render_state_check_data;
test->test_name = "set_get_render_states";
test->test_arg = test_arg;
}