[PATCH v2 0/1] MR11110: Draft: dxgi/tests: Avoid crash with old Windows.
-- v2: dxgi/tests: Fix tests with old Windows versions. https://gitlab.winehq.org/wine/wine/-/merge_requests/11110
From: Bernhard Übelacker <bernhardu@mailbox.org> --- dlls/dxgi/tests/dxgi.c | 45 +++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index ecd0661ab25..92d378948e8 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -915,7 +915,7 @@ static IDXGISwapChain *create_swapchain_(unsigned int line, IUnknown *device, BO HWND window, UINT flags, DXGI_SWAP_EFFECT swap_effect) { DXGI_SWAP_CHAIN_DESC desc; - IDXGISwapChain *swapchain; + IDXGISwapChain *swapchain = NULL; IDXGIFactory *factory; HRESULT hr; @@ -937,7 +937,7 @@ static IDXGISwapChain *create_swapchain_(unsigned int line, IUnknown *device, BO get_factory(device, is_d3d12, &factory); hr = IDXGIFactory_CreateSwapChain(factory, device, &desc, &swapchain); - ok_(__FILE__, line)(hr == S_OK, "Failed to create swapchain, hr %#lx.\n", hr); + ok_(__FILE__, line)(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win8.1 */, "Failed to create swapchain, hr %#lx.\n", hr); IDXGIFactory_Release(factory); return swapchain; @@ -2837,16 +2837,22 @@ static void test_set_fullscreen(IUnknown *device, BOOL is_d3d12) hr = IDXGIFactory_CreateSwapChain(factory, device, &swapchain_desc, &swapchain); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - ok(!!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen); + ok(hr == S_OK || broken(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) /* Win 1507 */, "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen); + } DestroyWindow(swapchain_desc.OutputWindow); hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, NULL); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - ok(!!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen); + ok(hr == S_OK || broken(hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) /* Win 1507 */, "Got unexpected hr %#lx.\n", hr); + if (hr == S_OK) + { + hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!!fullscreen, "Got unexpected fullscreen %#x.\n", fullscreen); + } hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); hr = IDXGISwapChain_GetFullscreenState(swapchain, &fullscreen, NULL); @@ -7107,7 +7113,10 @@ static void test_cursor_clipping(IUnknown *device, BOOL is_d3d12) } ok(mode_idx < mode_count, "Failed to find a different mode than %ux%u.\n", width, height); if (mode_idx >= mode_count) + { + winetest_pop_context(); continue; + } ret = ClipCursor(NULL); ok(ret, "ClipCursor failed, error %#lx.\n", GetLastError()); @@ -7278,7 +7287,14 @@ static void test_frame_latency_event(IUnknown *device, BOOL is_d3d12) hr = IDXGIFactory2_CreateSwapChainForHwnd(factory2, device, window, &swapchain_desc, NULL, NULL, &swapchain1); - ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win8.1 */, "Got unexpected hr %#lx.\n", hr); + if (FAILED(hr)) + { + win_skip("CreateSwapChainForHwnd failed.\n"); + IDXGIFactory2_Release(factory2); + DestroyWindow(window); + return; + } hr = IDXGISwapChain1_QueryInterface(swapchain1, &IID_IDXGISwapChain2, (void**)&swapchain2); IDXGISwapChain1_Release(swapchain1); @@ -8001,6 +8017,12 @@ static void test_swapchain_present_count(IUnknown *device, BOOL is_d3d12) winetest_push_context("test %u", i); swapchain = create_swapchain(device, is_d3d12, window, flags, swap_effect); + if (!swapchain) + { + win_skip("create_swapchain failed.\n"); + winetest_pop_context(); + continue; + } present_count = ~0u; hr = IDXGISwapChain_GetLastPresentCount(swapchain, &present_count); @@ -8248,6 +8270,7 @@ static void run_on_d3d12(void (*test_func)(IUnknown *device, BOOL is_d3d12)) if (!(device = create_d3d12_device())) { skip("Failed to create Direct3D 12 device.\n"); + winetest_pop_context(); return; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11110
```diff @@ -937,7 +937,7 @@ static IDXGISwapChain *create_swapchain_(unsigned int line, IUnknown *device, BO
get_factory(device, is_d3d12, &factory); hr = IDXGIFactory_CreateSwapChain(factory, device, &desc, &swapchain); - ok_(__FILE__, line)(hr == S_OK, "Failed to create swapchain, hr %#lx.\n", hr); + ok_(__FILE__, line)(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win8.1 */, "Failed to create swapchain, hr %#lx.\n", hr); IDXGIFactory_Release(factory);
return swapchain; ```
Is there a specific reason swapchain creation fails? Surely Windows 8.1 supports swapchains in general. Is this about DXGI_SWAP_EFFECT_FLIP_DISCARD (which is more or less a d3d12 thing) being unsupported? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11110#note_142648
v2: [Testbot run with this patch](https://testbot.winehq.org/JobDetails.pl?Key=163328) - Add two missing winetest_pop_context. - Add another broken in winetest_pop_context. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11110#note_142650
On Wed Jun 10 16:11:13 2026 +0000, Henri Verbeet wrote:
```diff @@ -937,7 +937,7 @@ static IDXGISwapChain *create_swapchain_(unsigned
int line, IUnknown *device, BO
get_factory(device, is_d3d12, &factory); hr = IDXGIFactory_CreateSwapChain(factory, device, &desc, &swapchain); - ok_(__FILE__, line)(hr == S_OK, "Failed to create swapchain, hr
%#lx.\n", hr);
+ ok_(__FILE__, line)(hr == S_OK || broken(hr == DXGI_ERROR_INVALID_CALL) /* Win8.1 */, "Failed to create swapchain, hr %#lx.\n", hr); IDXGIFactory_Release(factory);
return swapchain; ``` Is there a specific reason swapchain creation fails? Surely Windows 8.1 supports swapchains in general. Is this about DXGI_SWAP_EFFECT_FLIP_DISCARD (which is more or less a d3d12 thing) being unsupported? Hello, thanks for taking a look.
This line is against the crash that gets hit after avoiding the first one, visible here: https://testbot.winehq.org/JobDetails.pl?Key=163329&f203=exe32.report#k203 This shows `dxgi.c:8010: Test failed: d3d10: test 1: Failed to create swapchain, hr 0x887a0001.` So, yes, this seems to be about DXGI_SWAP_EFFECT_FLIP_DISCARD. I fear there is now to much in this MR, should I at least put the missing winetest_pop_context into a separate MR? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11110#note_142656
This line is against the crash that gets hit after avoiding the first one, visible here: https://testbot.winehq.org/JobDetails.pl?Key=163329&f203=exe32.report#k203
This shows `dxgi.c:8010: Test failed: d3d10: test 1: Failed to create swapchain, hr 0x887a0001.`
So, yes, this seems to be about DXGI_SWAP_EFFECT_FLIP_DISCARD.
IIRC the issue there is that DXGI_SWAP_EFFECT_FLIP_DISCARD is introduced by DXGI 1.4, which is part of Windows 10. We should probably just check for DXGI 1.4 support before trying to use DXGI_SWAP_EFFECT_FLIP_DISCARD. In practice the easiest way to do that is probably to QI the IDXGIFactory interface for IID_IDXGIFactory4.
I fear there is now to much in this MR, should I at least put the missing winetest_pop_context into a separate MR?
Personally I tend to split MRs when I think I can get away with it, so as far as I'm concerned that makes sense. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/11110#note_142662
participants (3)
-
Bernhard Übelacker -
Bernhard Übelacker (@bernhardu) -
Henri Verbeet (@hverbeet)