dxgi/tests: Extend test for creating swapchain.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e57ab97f6f
commit
ce4e01387e
|
@ -172,7 +172,7 @@ static void check_swapchain_fullscreen_state_(unsigned int line, IDXGISwapChain
|
|||
ok_(__FILE__, line)(fullscreen == expected_state->fullscreen, "Got fullscreen %#x, expected %#x.\n",
|
||||
fullscreen, expected_state->fullscreen);
|
||||
|
||||
if (!swapchain_desc.Windowed)
|
||||
if (!swapchain_desc.Windowed && expected_state->fullscreen)
|
||||
{
|
||||
IDXGIAdapter *adapter;
|
||||
IDXGIDevice *device;
|
||||
|
@ -203,10 +203,33 @@ static void check_swapchain_fullscreen_state_(unsigned int line, IDXGISwapChain
|
|||
}
|
||||
}
|
||||
|
||||
static void compute_expected_swapchain_fullscreen_state_after_fullscreen_change(
|
||||
#define compute_expected_swapchain_fullscreen_state_after_fullscreen_change(a, b, c, d, e, f) \
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change_(__LINE__, a, b, c, d, e, f)
|
||||
static void compute_expected_swapchain_fullscreen_state_after_fullscreen_change_(unsigned int line,
|
||||
struct swapchain_fullscreen_state *state, const DXGI_SWAP_CHAIN_DESC *swapchain_desc,
|
||||
const RECT *old_monitor_rect, unsigned int new_width, unsigned int new_height)
|
||||
const RECT *old_monitor_rect, unsigned int new_width, unsigned int new_height, IDXGIOutput *target)
|
||||
{
|
||||
if (!new_width && !new_height)
|
||||
{
|
||||
RECT client_rect;
|
||||
GetClientRect(swapchain_desc->OutputWindow, &client_rect);
|
||||
new_width = client_rect.right - client_rect.left;
|
||||
new_height = client_rect.bottom - client_rect.top;
|
||||
}
|
||||
|
||||
if (target)
|
||||
{
|
||||
DXGI_MODE_DESC mode_desc = swapchain_desc->BufferDesc;
|
||||
HRESULT hr;
|
||||
|
||||
mode_desc.Width = new_width;
|
||||
mode_desc.Height = new_height;
|
||||
hr = IDXGIOutput_FindClosestMatchingMode(target, &mode_desc, &mode_desc, NULL);
|
||||
todo_wine ok_(__FILE__, line)(SUCCEEDED(hr), "FindClosestMatchingMode failed, hr %#x.\n", hr);
|
||||
new_width = mode_desc.Width;
|
||||
new_height = mode_desc.Height;
|
||||
}
|
||||
|
||||
state->fullscreen = TRUE;
|
||||
if (swapchain_desc->Flags & DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH)
|
||||
{
|
||||
|
@ -220,6 +243,9 @@ static void compute_expected_swapchain_fullscreen_state_after_fullscreen_change(
|
|||
SetRect(&state->fullscreen_state.client_rect, 0, 0, new_width, new_height);
|
||||
state->fullscreen_state.monitor_rect = new_monitor_rect;
|
||||
state->fullscreen_state.window_rect = new_monitor_rect;
|
||||
|
||||
if (target)
|
||||
state->target = target;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -607,9 +633,11 @@ struct refresh_rates
|
|||
|
||||
static void test_create_swapchain(void)
|
||||
{
|
||||
struct swapchain_fullscreen_state initial_state;
|
||||
struct swapchain_fullscreen_state initial_state, expected_state;
|
||||
unsigned int i, expected_width, expected_height;
|
||||
DXGI_SWAP_CHAIN_DESC creation_desc, result_desc;
|
||||
ULONG refcount, expected_refcount;
|
||||
RECT *expected_client_rect;
|
||||
IDXGISwapChain *swapchain;
|
||||
IUnknown *obj, *parent;
|
||||
IDXGIAdapter *adapter;
|
||||
|
@ -618,7 +646,6 @@ static void test_create_swapchain(void)
|
|||
IDXGIOutput *target;
|
||||
BOOL fullscreen;
|
||||
HRESULT hr;
|
||||
UINT i;
|
||||
|
||||
const struct refresh_rates refresh_list[] =
|
||||
{
|
||||
|
@ -656,7 +683,7 @@ static void test_create_swapchain(void)
|
|||
capture_fullscreen_state(&initial_state.fullscreen_state, creation_desc.OutputWindow);
|
||||
|
||||
hr = IDXGIDevice_QueryInterface(device, &IID_IUnknown, (void **)&obj);
|
||||
ok(SUCCEEDED(hr), "IDXGIDevice does not implement IUnknown\n");
|
||||
ok(SUCCEEDED(hr), "IDXGIDevice does not implement IUnknown.\n");
|
||||
|
||||
hr = IDXGIDevice_GetAdapter(device, &adapter);
|
||||
ok(SUCCEEDED(hr), "GetAdapter failed, hr %#x.\n", hr);
|
||||
|
@ -822,6 +849,131 @@ static void test_create_swapchain(void)
|
|||
|
||||
check_window_fullscreen_state(creation_desc.OutputWindow, &initial_state.fullscreen_state);
|
||||
|
||||
/* Test swapchain creation with backbuffer width and height equal to 0. */
|
||||
expected_state = initial_state;
|
||||
expected_client_rect = &expected_state.fullscreen_state.client_rect;
|
||||
|
||||
/* Windowed */
|
||||
expected_width = expected_client_rect->right;
|
||||
expected_height = expected_client_rect->bottom;
|
||||
|
||||
creation_desc.BufferDesc.Width = 0;
|
||||
creation_desc.BufferDesc.Height = 0;
|
||||
creation_desc.Windowed = TRUE;
|
||||
creation_desc.Flags = 0;
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain);
|
||||
ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
|
||||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
ok(result_desc.BufferDesc.Width == expected_width, "Got width %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Width, expected_width);
|
||||
ok(result_desc.BufferDesc.Height == expected_height, "Got height %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Height, expected_height);
|
||||
check_swapchain_fullscreen_state(swapchain, &expected_state);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
|
||||
DestroyWindow(creation_desc.OutputWindow);
|
||||
creation_desc.OutputWindow = CreateWindowA("static", "dxgi_test",
|
||||
WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX,
|
||||
0, 0, 222, 222, 0, 0, 0, 0);
|
||||
SetRect(&expected_state.fullscreen_state.window_rect, 0, 0, 222, 222);
|
||||
GetClientRect(creation_desc.OutputWindow, expected_client_rect);
|
||||
expected_width = expected_client_rect->right;
|
||||
expected_height = expected_client_rect->bottom;
|
||||
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain);
|
||||
ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
|
||||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
ok(result_desc.BufferDesc.Width == expected_width, "Got width %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Width, expected_width);
|
||||
ok(result_desc.BufferDesc.Height == expected_height, "Got height %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Height, expected_height);
|
||||
check_swapchain_fullscreen_state(swapchain, &expected_state);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
|
||||
DestroyWindow(creation_desc.OutputWindow);
|
||||
creation_desc.OutputWindow = CreateWindowA("static", "dxgi_test", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
check_window_fullscreen_state(creation_desc.OutputWindow, &initial_state.fullscreen_state);
|
||||
|
||||
/* Fullscreen */
|
||||
creation_desc.Windowed = FALSE;
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain);
|
||||
ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
|
||||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
|
||||
ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_GetContainingOutput(swapchain, &expected_state.target);
|
||||
ok(SUCCEEDED(hr) || broken(hr == DXGI_ERROR_UNSUPPORTED) /* Win 7 testbot */,
|
||||
"GetContainingOutput failed, hr %#x.\n", hr);
|
||||
check_swapchain_fullscreen_state(swapchain, &initial_state);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
if (hr == DXGI_ERROR_UNSUPPORTED)
|
||||
{
|
||||
win_skip("GetContainingOutput() not supported.\n");
|
||||
goto done;
|
||||
}
|
||||
if (result_desc.Windowed)
|
||||
{
|
||||
win_skip("Fullscreen not supported.\n");
|
||||
IDXGIOutput_Release(expected_state.target);
|
||||
goto done;
|
||||
}
|
||||
|
||||
creation_desc.BufferDesc.Width = 0;
|
||||
creation_desc.BufferDesc.Height = 0;
|
||||
creation_desc.Windowed = FALSE;
|
||||
creation_desc.Flags = 0;
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&creation_desc, &initial_state.fullscreen_state.monitor_rect, 0, 0, expected_state.target);
|
||||
expected_width = expected_client_rect->right - expected_client_rect->left;
|
||||
expected_height = expected_client_rect->bottom - expected_client_rect->top;
|
||||
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain);
|
||||
ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
|
||||
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
|
||||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
todo_wine ok(result_desc.BufferDesc.Width == expected_width, "Got width %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Width, expected_width);
|
||||
todo_wine ok(result_desc.BufferDesc.Height == expected_height, "Got height %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Height, expected_height);
|
||||
check_swapchain_fullscreen_state(swapchain, &expected_state);
|
||||
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
|
||||
ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr);
|
||||
check_swapchain_fullscreen_state(swapchain, &initial_state);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
|
||||
/* Fullscreen and DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH */
|
||||
creation_desc.BufferDesc.Width = 0;
|
||||
creation_desc.BufferDesc.Height = 0;
|
||||
creation_desc.Windowed = FALSE;
|
||||
creation_desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&creation_desc, &initial_state.fullscreen_state.monitor_rect, 0, 0, expected_state.target);
|
||||
expected_width = expected_client_rect->right - expected_client_rect->left;
|
||||
expected_height = expected_client_rect->bottom - expected_client_rect->top;
|
||||
|
||||
hr = IDXGIFactory_CreateSwapChain(factory, obj, &creation_desc, &swapchain);
|
||||
todo_wine ok(SUCCEEDED(hr), "CreateSwapChain failed, hr %#x.\n", hr);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IDXGISwapChain_GetDesc(swapchain, &result_desc);
|
||||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
ok(result_desc.BufferDesc.Width == expected_width, "Got width %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Width, expected_width);
|
||||
ok(result_desc.BufferDesc.Height == expected_height, "Got height %u, expected %u.\n",
|
||||
result_desc.BufferDesc.Height, expected_height);
|
||||
check_swapchain_fullscreen_state(swapchain, &expected_state);
|
||||
hr = IDXGISwapChain_SetFullscreenState(swapchain, FALSE, NULL);
|
||||
ok(SUCCEEDED(hr), "SetFullscreenState failed, hr %#x.\n", hr);
|
||||
check_swapchain_fullscreen_state(swapchain, &initial_state);
|
||||
IDXGISwapChain_Release(swapchain);
|
||||
}
|
||||
|
||||
IDXGIOutput_Release(expected_state.target);
|
||||
|
||||
done:
|
||||
IUnknown_Release(obj);
|
||||
refcount = IDXGIDevice_Release(device);
|
||||
ok(!refcount, "Device has %u references left.\n", refcount);
|
||||
|
@ -829,6 +981,7 @@ static void test_create_swapchain(void)
|
|||
ok(!refcount, "Adapter has %u references left.\n", refcount);
|
||||
refcount = IDXGIFactory_Release(factory);
|
||||
ok(!refcount, "Factory has %u references left.\n", refcount);
|
||||
check_window_fullscreen_state(creation_desc.OutputWindow, &initial_state.fullscreen_state);
|
||||
DestroyWindow(creation_desc.OutputWindow);
|
||||
}
|
||||
|
||||
|
@ -1059,7 +1212,7 @@ static void test_swapchain_fullscreen_state(IDXGISwapChain *swapchain,
|
|||
|
||||
expected_state = *initial_state;
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&swapchain_desc, &initial_state->fullscreen_state.monitor_rect, 800, 600);
|
||||
&swapchain_desc, &initial_state->fullscreen_state.monitor_rect, 800, 600, NULL);
|
||||
hr = IDXGISwapChain_GetContainingOutput(swapchain, &expected_state.target);
|
||||
ok(SUCCEEDED(hr), "GetContainingOutput failed, hr %#x.\n", hr);
|
||||
|
||||
|
@ -1122,7 +1275,7 @@ static void test_swapchain_fullscreen_state(IDXGISwapChain *swapchain,
|
|||
expected_state.fullscreen_state.monitor = output_desc.Monitor;
|
||||
expected_state.fullscreen_state.monitor_rect = orig_monitor_rect;
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&swapchain_desc, &orig_monitor_rect, 800, 600);
|
||||
&swapchain_desc, &orig_monitor_rect, 800, 600, NULL);
|
||||
|
||||
hr = IDXGISwapChain_SetFullscreenState(swapchain, TRUE, output);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
@ -1522,7 +1675,7 @@ static void test_fullscreen_resize_target(IDXGISwapChain *swapchain,
|
|||
ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr);
|
||||
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&swapchain_desc, &output_desc.DesktopCoordinates, modes[i].Width, modes[i].Height);
|
||||
&swapchain_desc, &output_desc.DesktopCoordinates, modes[i].Width, modes[i].Height, NULL);
|
||||
|
||||
hr = IDXGISwapChain_ResizeTarget(swapchain, &modes[i]);
|
||||
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
|
||||
|
@ -1627,7 +1780,7 @@ static void test_resize_target(void)
|
|||
{
|
||||
expected_state.fullscreen = TRUE;
|
||||
compute_expected_swapchain_fullscreen_state_after_fullscreen_change(&expected_state,
|
||||
&swapchain_desc, &initial_state.fullscreen_state.monitor_rect, 800, 600);
|
||||
&swapchain_desc, &initial_state.fullscreen_state.monitor_rect, 800, 600, NULL);
|
||||
hr = IDXGISwapChain_GetContainingOutput(swapchain, &expected_state.target);
|
||||
ok(SUCCEEDED(hr) || broken(hr == DXGI_ERROR_UNSUPPORTED) /* Win 7 testbot */,
|
||||
"GetContainingOutput failed, hr %#x.\n", hr);
|
||||
|
|
Loading…
Reference in New Issue