Commit 3660176e authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dx9/tests: Clean up GetMatrixPointerArray() tests.

Inspired by a patch from Eric Pouech. Signed-off-by: 's avatarMatteo Bruni <mbruni@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent fd6315eb
...@@ -1470,20 +1470,28 @@ static void test_effect_parameter_value_GetMatrixArray(const struct test_effect_ ...@@ -1470,20 +1470,28 @@ static void test_effect_parameter_value_GetMatrixArray(const struct test_effect_
static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_effect_parameter_value_result *res, static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_effect_parameter_value_result *res,
ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i) ID3DXEffect *effect, const DWORD *res_value, D3DXHANDLE parameter, UINT i)
{ {
union
{
float f[sizeof(D3DXMATRIX) / sizeof(float)];
D3DXMATRIX m;
} fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE * sizeof(float) / sizeof(D3DXMATRIX)];
const D3DXPARAMETER_DESC *res_desc = &res->desc; const D3DXPARAMETER_DESC *res_desc = &res->desc;
const char *res_full_name = res->full_name; const char *res_full_name = res->full_name;
HRESULT hr; HRESULT hr;
DWORD cmp = 0xabababab; D3DXMATRIX *matrix_pointer_array[ARRAY_SIZE(fvalue)];
FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE];
D3DXMATRIX *matrix_pointer_array[sizeof(fvalue)/sizeof(D3DXMATRIX)];
UINT l, k, m, element, err = 0; UINT l, k, m, element, err = 0;
union
{
DWORD d;
float f;
} cmp = {0xabababab};
for (element = 0; element <= res_desc->Elements + 1; ++element) for (element = 0; element <= res_desc->Elements + 1; ++element)
{ {
memset(fvalue, 0xab, sizeof(fvalue)); memset(fvalue, 0xab, sizeof(fvalue));
for (l = 0; l < element; ++l) for (l = 0; l < element; ++l)
{ {
matrix_pointer_array[l] = (D3DXMATRIX *)&fvalue[l * sizeof(**matrix_pointer_array) / sizeof(FLOAT)]; matrix_pointer_array[l] = &fvalue[l].m;
} }
hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, matrix_pointer_array, element); hr = effect->lpVtbl->GetMatrixPointerArray(effect, parameter, matrix_pointer_array, element);
if (!element) if (!element)
...@@ -1491,7 +1499,10 @@ static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_ ...@@ -1491,7 +1499,10 @@ static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_
ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n", ok(hr == D3D_OK, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n",
i, res_full_name, element, hr, D3D_OK); i, res_full_name, element, hr, D3D_OK);
for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
for (l = 0; l < ARRAY_SIZE(fvalue[l].f); ++l)
if (fvalue[m].f[l] != cmp.f)
++err;
} }
else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS) else if (element <= res_desc->Elements && res_desc->Class == D3DXPC_MATRIX_ROWS)
{ {
...@@ -1506,20 +1517,27 @@ static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_ ...@@ -1506,20 +1517,27 @@ static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_
{ {
if (k < res_desc->Columns && l < res_desc->Rows) if (k < res_desc->Columns && l < res_desc->Rows)
{ {
if (!compare_float(fvalue[m * 16 + l * 4 + k], get_float(res_desc->Type, if (!compare_float(fvalue[m].m.m[l][k], get_float(res_desc->Type,
&res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512)) &res_value[m * res_desc->Columns * res_desc->Rows + l * res_desc->Columns + k]), 512))
++err; ++err;
} }
else if (fvalue[m * 16 + l * 4 + k] != 0.0f) ++err; else if (fvalue[m].m.m[l][k] != 0.0f)
++err;
} }
} }
} }
for (l = element * 16; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; for (m = element; m < ARRAY_SIZE(fvalue); ++m)
for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
if (fvalue[m].f[l] != cmp.f)
++err;
} }
else else
{ {
for (l = 0; l < EFFECT_PARAMETER_VALUE_ARRAY_SIZE; ++l) if (fvalue[l] != *(FLOAT *)&cmp) ++err; for (m = 0; m < ARRAY_SIZE(fvalue); ++m)
for (l = 0; l < ARRAY_SIZE(fvalue[m].f); ++l)
if (fvalue[m].f[l] != cmp.f)
++err;
ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n", ok(hr == D3DERR_INVALIDCALL, "%u - %s[%u]: GetMatrixPointerArray failed, got %#x, expected %#x\n",
i, res_full_name, element, hr, D3DERR_INVALIDCALL); i, res_full_name, element, hr, D3DERR_INVALIDCALL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment