dxgi/tests: Test adapter video memory budget notification.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2022-05-18 14:49:28 +08:00 committed by Alexandre Julliard
parent 6ebfc35fc4
commit 14237e321b
1 changed files with 61 additions and 0 deletions

View File

@ -7514,6 +7514,66 @@ static void test_swapchain_present_count(IUnknown *device, BOOL is_d3d12)
DestroyWindow(window);
}
static void test_video_memory_budget_notification(void)
{
DXGI_QUERY_VIDEO_MEMORY_INFO memory_info;
IDXGIAdapter3 *adapter3;
IDXGIAdapter *adapter;
IDXGIDevice *device;
DWORD cookie, ret;
ULONG refcount;
HANDLE event;
HRESULT hr;
if (!(device = create_device(0)))
{
skip("Failed to create device.\n");
return;
}
hr = IDXGIDevice_GetAdapter(device, &adapter);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = IDXGIAdapter_QueryInterface(adapter, &IID_IDXGIAdapter3, (void **)&adapter3);
ok(hr == S_OK || hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
if (hr == E_NOINTERFACE)
goto done;
hr = IDXGIAdapter3_RegisterVideoMemoryBudgetChangeNotificationEvent(adapter3, NULL, &cookie);
todo_wine
ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr);
event = CreateEventW(NULL, FALSE, FALSE, NULL);
hr = IDXGIAdapter3_RegisterVideoMemoryBudgetChangeNotificationEvent(adapter3, event, NULL);
todo_wine
ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr);
hr = IDXGIAdapter3_RegisterVideoMemoryBudgetChangeNotificationEvent(adapter3, event, &cookie);
todo_wine
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = IDXGIAdapter3_QueryVideoMemoryInfo(adapter3, 0, DXGI_MEMORY_SEGMENT_GROUP_LOCAL, &memory_info);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
if (!memory_info.Budget)
{
hr = IDXGIAdapter3_QueryVideoMemoryInfo(adapter3, 0, DXGI_MEMORY_SEGMENT_GROUP_NON_LOCAL, &memory_info);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
}
if (memory_info.Budget)
{
ret = WaitForSingleObject(event, 1000);
todo_wine
ok(ret == WAIT_OBJECT_0, "Expected event fired.\n");
}
IDXGIAdapter3_UnregisterVideoMemoryBudgetChangeNotification(adapter3, cookie);
IDXGIAdapter3_Release(adapter3);
CloseHandle(event);
done:
IDXGIAdapter_Release(adapter);
refcount = IDXGIDevice_Release(device);
ok(!refcount, "Device has %lu references left.\n", refcount);
}
static void run_on_d3d10(void (*test_func)(IUnknown *device, BOOL is_d3d12))
{
IDXGIDevice *device;
@ -7613,6 +7673,7 @@ START_TEST(dxgi)
queue_test(test_output_desc);
queue_test(test_object_wrapping);
queue_test(test_factory_check_feature_support);
queue_test(test_video_memory_budget_notification);
run_queued_tests();