From 14237e321b30bd3f9eaa441586f82c44c15bc5cf Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Wed, 18 May 2022 14:49:28 +0800 Subject: [PATCH] dxgi/tests: Test adapter video memory budget notification. Signed-off-by: Zhiyi Zhang Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/dxgi/tests/dxgi.c | 61 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index a199ba486ba..04bba29e8e5 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -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();