Signed-off-by: Conor McCarthy cmccarthy@codeweavers.com --- The tests are todo for vkd3d but here they are for future use. Supersedes 173222. --- tests/d3d12.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
diff --git a/tests/d3d12.c b/tests/d3d12.c index 5284138..1485396 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -32684,6 +32684,99 @@ static void test_bufinfo_instruction(void) destroy_test_context(&context); }
+static void test_write_buffer_immediate(void) +{ + D3D12_WRITEBUFFERIMMEDIATE_PARAMETER params[2]; + ID3D12GraphicsCommandList2 *command_list2; + D3D12_WRITEBUFFERIMMEDIATE_MODE modes[2]; + ID3D12GraphicsCommandList *command_list; + ID3D12CommandAllocator *allocator; + struct resource_readback rb; + ID3D12CommandQueue *queue; + ID3D12Resource *buffer; + ID3D12Device *device; + unsigned int value; + HRESULT hr; + + static const unsigned int data_values[] = {0xdeadbeef, 0xf00baa}; + + hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); + ok(hr == S_OK, "Failed to create device, hr %#x.\n", hr); + + queue = create_command_queue(device, D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL); + + hr = ID3D12Device_CreateCommandAllocator(device, D3D12_COMMAND_LIST_TYPE_DIRECT, + &IID_ID3D12CommandAllocator, (void **)&allocator); + ok(SUCCEEDED(hr), "Failed to create command allocator, hr %#x.\n", hr); + + hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, + allocator, NULL, &IID_ID3D12GraphicsCommandList2, (void **)&command_list); + if (FAILED(hr)) + { + skip("ID3D12GraphicsCommandList2 not implemented.\n"); + goto done; + } + command_list2 = (ID3D12GraphicsCommandList2 *)command_list; + + buffer = create_default_buffer(device, sizeof(data_values), + D3D12_RESOURCE_FLAG_NONE, D3D12_RESOURCE_STATE_COPY_DEST); + upload_buffer_data(buffer, 0, sizeof(data_values), data_values, queue, command_list); + reset_command_list(command_list, allocator); + + params[0].Dest = ID3D12Resource_GetGPUVirtualAddress(buffer); + params[0].Value = 0x1020304; + params[1].Dest = params[0].Dest + sizeof(data_values[0]); + params[1].Value = 0xc0d0e0f; + ID3D12GraphicsCommandList2_WriteBufferImmediate(command_list2, ARRAY_SIZE(params), params, NULL); + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + if (FAILED(hr)) + goto done1; + exec_command_list(queue, command_list); + wait_queue_idle(device, queue); + reset_command_list(command_list, allocator); + + get_buffer_readback_with_command_list(buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list); + value = get_readback_uint(&rb, 0, 0, 0); + todo ok(value == params[0].Value, "Got unexpected readback 0x%#x.\n", value); + value = get_readback_uint(&rb, 1, 0, 0); + todo ok(value == params[1].Value, "Got unexpected readback 0x%#x.\n", value); + release_resource_readback(&rb); + reset_command_list(command_list, allocator); + + params[0].Value = 0x2030405; + params[1].Value = 0xb0c0d0e; + modes[0] = D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_IN; + modes[1] = D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT; + ID3D12GraphicsCommandList2_WriteBufferImmediate(command_list2, ARRAY_SIZE(params), params, modes); + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr); + exec_command_list(queue, command_list); + wait_queue_idle(device, queue); + reset_command_list(command_list, allocator); + + get_buffer_readback_with_command_list(buffer, DXGI_FORMAT_R32_UINT, &rb, queue, command_list); + value = get_readback_uint(&rb, 0, 0, 0); + todo ok(value == params[0].Value, "Got unexpected readback 0x%#x.\n", value); + value = get_readback_uint(&rb, 1, 0, 0); + todo ok(value == params[1].Value, "Got unexpected readback 0x%#x.\n", value); + release_resource_readback(&rb); + reset_command_list(command_list, allocator); + + modes[0] = 0x7FFFFFFF; + ID3D12GraphicsCommandList2_WriteBufferImmediate(command_list2, ARRAY_SIZE(params), params, modes); + hr = ID3D12GraphicsCommandList_Close(command_list); + todo ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %#x.\n", hr); + +done1: + ID3D12Resource_Release(buffer); + ID3D12GraphicsCommandList2_Release(command_list2); +done: + ID3D12CommandAllocator_Release(allocator); + ID3D12CommandQueue_Release(queue); + ID3D12Device_Release(device); +} + START_TEST(d3d12) { parse_args(argc, argv); @@ -32847,4 +32940,5 @@ START_TEST(d3d12) run_test(test_early_depth_stencil_tests); run_test(test_conditional_rendering); run_test(test_bufinfo_instruction); + run_test(test_write_buffer_immediate); }