Inspired by a patch from Eric Pouech.
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Eric, can you test this patch and see if it still fixes the warnings with GCC 11? --- dlls/d3dx9_36/tests/effect.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-)
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index 86edb1ac65c..7fce65548ec 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -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, 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 char *res_full_name = res->full_name; HRESULT hr; - DWORD cmp = 0xabababab; - FLOAT fvalue[EFFECT_PARAMETER_VALUE_ARRAY_SIZE]; - D3DXMATRIX *matrix_pointer_array[sizeof(fvalue)/sizeof(D3DXMATRIX)]; + D3DXMATRIX *matrix_pointer_array[ARRAY_SIZE(fvalue)]; UINT l, k, m, element, err = 0; + union + { + DWORD d; + float f; + } cmp = {0xabababab};
for (element = 0; element <= res_desc->Elements + 1; ++element) { memset(fvalue, 0xab, sizeof(fvalue)); 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); if (!element) @@ -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", 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) { @@ -1506,20 +1517,27 @@ static void test_effect_parameter_value_GetMatrixPointerArray(const struct test_ { 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)) ++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 { - 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", i, res_full_name, element, hr, D3DERR_INVALIDCALL);
Le 02/10/2021 à 18:39, Matteo Bruni a écrit :
Inspired by a patch from Eric Pouech.
not sure where the inspiration comes from ;-) seems very far far way
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Eric, can you test this patch and see if it still fixes the warnings with GCC 11?
warnings on this part of the file are removed
note that same warnings appear also in same file line 1678, and mesh.c line 4827 (in same directory)
thanks for looking into this
A+
On Sun, Oct 3, 2021 at 2:53 PM Eric Pouech eric.pouech@orange.fr wrote:
Le 02/10/2021 à 18:39, Matteo Bruni a écrit :
Inspired by a patch from Eric Pouech.
not sure where the inspiration comes from ;-) seems very far far way
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Eric, can you test this patch and see if it still fixes the warnings with GCC 11?
warnings on this part of the file are removed
note that same warnings appear also in same file line 1678, and mesh.c line 4827 (in same directory)
Thank you very much. I will have a couple more patches for the other two instances of the same warning (I forgot to mention it in the commit message).
Le 04/10/2021 à 17:11, Matteo Bruni a écrit :
On Sun, Oct 3, 2021 at 2:53 PM Eric Pouecheric.pouech@orange.fr wrote:
Le 02/10/2021 à 18:39, Matteo Bruni a écrit :
Inspired by a patch from Eric Pouech.
not sure where the inspiration comes from ;-) seems very far far way
Signed-off-by: Matteo Brunimbruni@codeweavers.com
Eric, can you test this patch and see if it still fixes the warnings with GCC 11?
warnings on this part of the file are removed
note that same warnings appear also in same file line 1678, and mesh.c line 4827 (in same directory)
Thank you very much. I will have a couple more patches for the other two instances of the same warning (I forgot to mention it in the commit message).
nice!! A+