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`
/cc @zfigura
From: Pavel Ondračka pavel.ondracka@gmail.com
Co-authored-by: David Heidelberg david@ixit.cz Signed-off-by: David Heidelberg david@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 8f7fa4be12b..7c0269b93c5 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]; };
From: David Heidelberg david@ixit.cz
Signed-off-by: David Heidelberg david@ixit.cz --- dlls/d3d9/tests/visual.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 7c0269b93c5..590239ff232 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -1840,10 +1840,11 @@ static void color_fill_test(void) if (SUCCEEDED(hr)) { hr = IDirect3DDevice9_ColorFill(device, surface, &rect2, 0xdeadbeef); - if (formats[i].flags & BLOCKS) + if (formats[i].flags & BLOCKS) { ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#lx, fmt=%s.\n", hr, formats[i].name); - else + } else { ok(SUCCEEDED(hr), "Failed to color fill, hr %#lx, fmt=%s.\n", hr, formats[i].name); + } }
if (!(formats[i].flags & CHECK_FILL_VALUE)) @@ -3855,10 +3856,11 @@ static void z_range_test(void) color = getPixelColor(device, 28, 238); ok(color_match(color, 0x00ffffff, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color); color = getPixelColor(device, 28, 241); - if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_CLIPTLVERTS) + if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_CLIPTLVERTS) { ok(color_match(color, 0x00ffffff, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color); - else + } else { ok(color_match(color, 0x00ffff00, 0), "Z range failed: Got color 0x%08x, expected 0x00ffff00.\n", color); + }
/* Not clipped, > z buffer clear value(0.75). * @@ -3890,10 +3892,11 @@ static void z_range_test(void) color = getPixelColor(device, 321, 238); ok(color_match(color, 0x00ffffff, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color); color = getPixelColor(device, 321, 241); - if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_CLIPTLVERTS) + if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_CLIPTLVERTS) { ok(color_match(color, 0x00ffffff, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color); - else + } else { ok(color_match(color, 0x0000ff00, 0), "Z range failed: Got color 0x%08x, expected 0x00ffffff.\n", color); + }
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Failed to present, hr %#lx.\n", hr); @@ -8406,17 +8409,18 @@ static void pretransformed_varying_test(void) /* This isn't a weekend's job to fix, ignore the problem for now. * Needs a replacement pipeline. */ color = getPixelColor(device, 360, 240); - if (tests[i].todo) + if (tests[i].todo) { todo_wine ok(color_match(color, tests[i].color, 1) || broken(color_match(color, 0x00000000, 1) && tests[i].shader_code == blendindices_code), "Test %s returned color 0x%08x, expected 0x%08x (todo).\n", tests[i].name, color, tests[i].color); - else + } else { ok(color_match(color, tests[i].color, 1) || broken(color_match(color, tests[i].broken_color, 1) && tests[i].broken), "Test %s returned color 0x%08x, expected 0x%08x.\n", tests[i].name, color, tests[i].color); + }
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -8925,7 +8929,7 @@ static void test_vshader_input(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_SetPixelShader(device, ps); ok(hr == S_OK, "Got hr %#lx.\n", hr); - } else if(i == 2){ + } else if(i == 2) { hr = IDirect3DDevice9_CreateVertexShader(device, swapped_shader_code_2, &swapped_shader); ok(hr == S_OK, "Got hr %#lx.\n", hr); } else if(i == 1) { @@ -8947,11 +8951,12 @@ static void test_vshader_input(void) hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd); ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr); hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2, sizeof(float) * 11); - if (i == 3 || i == 2) + if (i == 3 || i == 2) { ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr); - else if (i == 1) + } else if (i == 1) { /* Succeeds or fails, depending on SW or HW vertex processing. */ ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + }
hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotexcrd_rightorder); ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr); @@ -8961,10 +8966,11 @@ static void test_vshader_input(void) hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_twotex_wrongidx); ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr); hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad3, sizeof(float) * 11); - if (i == 3 || i == 2) + if (i == 3 || i == 2) { ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr); - else if (i == 1) + } else if (i == 1) { ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + }
hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr); @@ -9026,11 +9032,12 @@ static void test_vshader_input(void) hr = IDirect3DDevice9_SetVertexDeclaration(device, decl_onetexcrd); ok(SUCCEEDED(hr), "Failed to set vertex declaration, hr %#lx.\n", hr); hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad2_modified, sizeof(float) * 11); - if (i == 3 || i == 2) + if (i == 3 || i == 2) { ok(SUCCEEDED(hr), "Failed to draw, i %u, hr %#lx.\n", i, hr); - else if (i == 1) + } else if (i == 1) { /* Succeeds or fails, depending on SW or HW vertex processing. */ ok(hr == D3DERR_INVALIDCALL || hr == D3D_OK, "Got unexpected hr %#lx.\n", hr); + }
hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#lx.\n", hr); @@ -9070,7 +9077,7 @@ static void test_vshader_input(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_SetPixelShader(device, ps); ok(hr == S_OK, "Got hr %#lx.\n", hr); - } else if(i == 2){ + } else if(i == 2) { hr = IDirect3DDevice9_CreateVertexShader(device, texcoord_color_shader_code_2, &texcoord_color_shader); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IDirect3DDevice9_CreateVertexShader(device, color_color_shader_code_2, &color_color_shader);
From: David Heidelberg david@ixit.cz
Signed-off-by: David Heidelberg david@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@codeweavers.com Charles Davis cdavis5x@gmail.com Christopher Gautier krys@via.ecp.fr David A. Cuthbert dacut@ece.cmu.edu -David Heidelberger david@ixit.cz +David Heidelberg david@ixit.cz Dennis Björklund db@zigo.dhs.org Dennis Björklund dennisb@cs.chalmers.se Dimitrie O. Paun dimi@bigfoot.com
Wrt 2/3, would it be possible to use a "do {...} while (0)" construction, or perhaps a GCC statement expression? Those are more usual ways of handling function-like macros, and wouldn't impose any restrictions on the tests.
1/3 isn't particularly invasive, so I don't really want to bikeshed, but at the same time, compiling Wine code as C++ doesn't seem like the most productive approach, and I worry that it's going to impose more subtle or annoying restrictions in the future. I haven't looked in detail at how you're building this, but can you just compile that file as C and link it into a C++ project?
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.
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)).
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.