[PATCH v3 0/3] MR5324: d3d9/tests: define enums outside of struct
These two commits shouldn't change anything functional wise, but with minimal changes on wine side, they allow easy integration of d3d9/tests/visual.c into GoogleTest native runner. visual.c code is C++ compatible, except the `enums`. Second change is done, because we had to redefine `ok()` macro, so without proper braces around conditions it cannot be expanded to multiple lines. Here is [MR how we import](https://github.com/axeldavy/Xnine/pull/12) the `visual.c` Third commit just correct my name in the `.mailmap` My main goal here is bring code which run in Mesa3D CI workflow as closer to the original wine d3d9 tests, so we can easily update from wine and eventually provide also fixes and improvements back. If you find this MR suitable, we could try figure out a way, to incorporate data about [nine_todo](https://github.com/axeldavy/Xnine/commit/7ac97c8350ea5b2bfd7307ca750ed1d0e51...), of course only if you find some use of these extra information. /cc @zfigura -- v3: d3d9/tests: replace LPDWORD with DWORD* in visual.c https://gitlab.winehq.org/wine/wine/-/merge_requests/5324
From: Pavel Ondračka <pavel.ondracka(a)gmail.com> Co-authored-by: David Heidelberg <david(a)ixit.cz> Signed-off-by: David Heidelberg <david(a)ixit.cz> --- dlls/d3d9/tests/visual.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index d05649ab92e..36af662f19b 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -1667,16 +1667,17 @@ static void color_fill_test(void) {D3DPOOL_MANAGED, 0, D3DERR_INVALIDCALL}, {D3DPOOL_SCRATCH, 0, D3DERR_INVALIDCALL}, }; + enum format_flags + { + CHECK_FILL_VALUE = 0x1, + BLOCKS = 0x2, + FLOAT_VALUES = 0x4, + }; static const struct { D3DFORMAT format; const char *name; - enum - { - CHECK_FILL_VALUE = 0x1, - BLOCKS = 0x2, - FLOAT_VALUES = 0x4, - } flags; + enum format_flags flags; unsigned int fill_i[4]; float fill_f[4]; } @@ -23249,16 +23250,17 @@ static void test_texture_blending(void) DWORD value; }; + enum texture_stage_texture + { + TEXTURE_INVALID, + TEXTURE_NONE, + TEXTURE_BUMPMAP, + TEXTURE_RED, + }; + struct texture_stage { - enum - { - TEXTURE_INVALID, - TEXTURE_NONE, - TEXTURE_BUMPMAP, - TEXTURE_RED, - } - texture; + enum texture_stage_texture texture; struct texture_stage_state state[20]; }; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5324
From: David Heidelberg <david(a)ixit.cz> Signed-off-by: David Heidelberg <david(a)ixit.cz> --- .mailmap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index 4bd0cee2b2c..7cf13e67174 100644 --- a/.mailmap +++ b/.mailmap @@ -18,7 +18,7 @@ Charles Davis <cdavis(a)codeweavers.com> Charles Davis <cdavis5x(a)gmail.com> Christopher Gautier <krys(a)via.ecp.fr> David A. Cuthbert <dacut(a)ece.cmu.edu> -David Heidelberger <david(a)ixit.cz> +David Heidelberg <david(a)ixit.cz> Dennis Björklund <db(a)zigo.dhs.org> Dennis Björklund <dennisb(a)cs.chalmers.se> Dimitrie O. Paun <dimi(a)bigfoot.com> -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5324
From: David Heidelberg <david(a)ixit.cz> Signed-off-by: David Heidelberg <david(a)ixit.cz> --- dlls/d3d9/tests/visual.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 36af662f19b..f8baea9ff3e 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -3511,10 +3511,10 @@ static void texbem_test(void) generate_bumpmap_textures(device); - IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]); - IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]); - IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]); - hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT00, *(DWORD*)&bumpenvmat[0]); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(DWORD*)&bumpenvmat[1]); + IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(DWORD*)&bumpenvmat[2]); + hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(DWORD*)&bumpenvmat[3]); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_SetVertexShader(device, NULL); @@ -3665,24 +3665,24 @@ static void texbem_test(void) bumpenvmat[0] =-1.0; bumpenvmat[2] = 2.0; bumpenvmat[1] = 0.0; bumpenvmat[3] = 0.0; - hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]); + hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT00, *(DWORD*)&bumpenvmat[0]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]); + hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT01, *(DWORD*)&bumpenvmat[1]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]); + hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT10, *(DWORD*)&bumpenvmat[2]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]); + hr = IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_BUMPENVMAT11, *(DWORD*)&bumpenvmat[3]); ok(hr == S_OK, "Got hr %#lx.\n", hr); bumpenvmat[0] = 1.5; bumpenvmat[2] = 0.0; bumpenvmat[1] = 0.0; bumpenvmat[3] = 0.5; - hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]); + hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT00, *(DWORD*)&bumpenvmat[0]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]); + hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT01, *(DWORD*)&bumpenvmat[1]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]); + hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT10, *(DWORD*)&bumpenvmat[2]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]); + hr = IDirect3DDevice9_SetTextureStageState(device, 3, D3DTSS_BUMPENVMAT11, *(DWORD*)&bumpenvmat[3]); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); @@ -11028,13 +11028,13 @@ static void fixed_function_bumpmap_test(void) /* Generate the textures */ generate_bumpmap_textures(device); - hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT00, *(LPDWORD)&bumpenvmat[0]); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT00, *(DWORD*)&bumpenvmat[0]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT01, *(LPDWORD)&bumpenvmat[1]); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT01, *(DWORD*)&bumpenvmat[1]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT10, *(LPDWORD)&bumpenvmat[2]); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT10, *(DWORD*)&bumpenvmat[2]); ok(hr == S_OK, "Got hr %#lx.\n", hr); - hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT11, *(LPDWORD)&bumpenvmat[3]); + hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_BUMPENVMAT11, *(DWORD*)&bumpenvmat[3]); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5324
On Mon Mar 18 21:05:28 2024 +0000, Zebediah Figura wrote:
2/3
adding the `do {...} while (0)` option could be solution, thou the changes are kinda minimal on wine side without any drawback (if we don't count extra line at the end :wink: ). If you prefer to keep it without braces, I'm ok to drop the commit adjust it on our side. The diff might be small, but it's not an uncommon construction, and it would be easily broken. And it doesn't seem like it should be that difficult to fix in the GTest integration code.
1/3
Sadly GTest requires the code have at least C++14 and it's very convenient way to integrate it into existing solutions we use (as [deqp-runner](https://gitlab.freedesktop.org/mesa/deqp-runner)). That's rather unfortunate. If it would be inconvenient for wine to carry changes to be compatible with \> C++14 in future, we would just patch it by ourselves. I suppose it depends. Is this the only code incompatible with C++? I'd be mildly surprised if so; are there really no problems with e.g. casting? we have no other problems with C++, except the `enum` :wink:
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/5324#note_65246
@zfigura I added the `LPDWORD` -> `DWORD*` change, for consistency (if it's prefer within the wine code, then it would make sense to change it in few places), or we can do just `typedef DWORD* LPDWORD;` as we did before :smile: -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5324#note_65247
@zfigura I added the `LPDWORD` -\> `DWORD*` change, for consistency (if it's prefer within the wine code, then it would make sense to change it in few places), or we can do just `typedef DWORD* LPDWORD;` as we did before :smile:
Thanks, although, if we're going to go to lengths to beautify that code anyway, I'd rather replace the casts with wined3d's float_to_int(). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5324#note_65293
participants (4)
-
David Heidelberg -
David Heidelberg (@dh) -
Pavel Ondračka -
Zebediah Figura (@zfigura)