From: Giovanni Mascellani gmascellani@codeweavers.com
--- dlls/dxgi/tests/dxgi.c | 82 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 3 deletions(-)
diff --git a/dlls/dxgi/tests/dxgi.c b/dlls/dxgi/tests/dxgi.c index e0465b90ed0..f8b60c241af 100644 --- a/dlls/dxgi/tests/dxgi.c +++ b/dlls/dxgi/tests/dxgi.c @@ -776,13 +776,13 @@ static ID3D12Device *create_d3d12_device(void) return device; }
-static ID3D12CommandQueue *create_d3d12_direct_queue(ID3D12Device *device) +static ID3D12CommandQueue *create_d3d12_queue(ID3D12Device *device, D3D12_COMMAND_LIST_TYPE type) { D3D12_COMMAND_QUEUE_DESC command_queue_desc; ID3D12CommandQueue *queue; HRESULT hr;
- command_queue_desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; + command_queue_desc.Type = type; command_queue_desc.Priority = D3D12_COMMAND_QUEUE_PRIORITY_NORMAL; command_queue_desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; command_queue_desc.NodeMask = 0; @@ -7610,7 +7610,7 @@ static void run_on_d3d12(void (*test_func)(IUnknown *device, BOOL is_d3d12)) return; }
- queue = create_d3d12_direct_queue(device); + queue = create_d3d12_queue(device, D3D12_COMMAND_LIST_TYPE_DIRECT);
test_func((IUnknown *)queue, TRUE);
@@ -7622,6 +7622,80 @@ static void run_on_d3d12(void (*test_func)(IUnknown *device, BOOL is_d3d12)) ok(!refcount, "Device has %lu references left.\n", refcount); }
+static void test_invalid_command_queue_types(void) +{ + static const enum D3D12_COMMAND_LIST_TYPE queue_types[] = + { + D3D12_COMMAND_LIST_TYPE_COMPUTE, + D3D12_COMMAND_LIST_TYPE_COPY, + }; + + DXGI_SWAP_CHAIN_DESC swapchain_desc; + ID3D12CommandQueue *queue; + IDXGISwapChain *swapchain; + IDXGIFactory *factory; + ID3D12Device *device; + IUnknown *queue_unk; + RECT client_rect; + ULONG refcount; + unsigned int i; + HWND window; + HRESULT hr; + BOOL ret; + + if (!(device = create_d3d12_device())) + { + skip("Failed to create Direct3D 12 device.\n"); + return; + } + + window = create_window(); + ret = GetClientRect(window, &client_rect); + ok(ret, "Failed to get client rect.\n"); + + for (i = 0; i < ARRAY_SIZE(queue_types); ++i) + { + queue = create_d3d12_queue(device, queue_types[i]); + hr = ID3D12CommandQueue_QueryInterface(queue, &IID_IUnknown, (void **)&queue_unk); + ok(hr == S_OK, "Got unexpected hr %lx.\n", hr); + + get_factory(queue_unk, TRUE, &factory); + + swapchain_desc.BufferDesc.Width = 640; + swapchain_desc.BufferDesc.Height = 480; + swapchain_desc.BufferDesc.RefreshRate.Numerator = 60; + swapchain_desc.BufferDesc.RefreshRate.Denominator = 1; + swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; + swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; + swapchain_desc.SampleDesc.Count = 1; + swapchain_desc.SampleDesc.Quality = 0; + swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + swapchain_desc.BufferCount = 2; + swapchain_desc.OutputWindow = window; + swapchain_desc.Windowed = TRUE; + swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; + swapchain_desc.Flags = 0; + + hr = IDXGIFactory_CreateSwapChain(factory, queue_unk, &swapchain_desc, &swapchain); + todo_wine + ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#lx.\n", hr); + + wait_queue_idle(device, queue); + + IDXGIFactory_Release(factory); + + IUnknown_Release(queue_unk); + refcount = ID3D12CommandQueue_Release(queue); + ok(!refcount, "Command queue has %lu references left.\n", refcount); + } + + DestroyWindow(window); + + refcount = ID3D12Device_Release(device); + ok(!refcount, "Device has %lu references left.\n", refcount); +} + START_TEST(dxgi) { HMODULE dxgi_module, d3d11_module, d3d12_module, gdi32_module; @@ -7721,6 +7795,8 @@ START_TEST(dxgi) ID3D12Debug_Release(debug); }
+ test_invalid_command_queue_types(); + run_on_d3d12(test_set_fullscreen); run_on_d3d12(test_resize_target); run_on_d3d12(test_swapchain_resize);