From 00fec8232bffb186efd85cdb75730ef0d37d5fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 28 Sep 2016 09:42:49 +0200 Subject: [PATCH] libs/vkd3d: Track command list recording state. --- libs/vkd3d/command.c | 18 ++++++++++++++++-- libs/vkd3d/vkd3d_private.h | 1 + tests/d3d12.c | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index bae907ca..98c5260c 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -60,6 +60,8 @@ static HRESULT vkd3d_command_allocator_allocate_command_list(struct d3d12_comman if ((vr = VK_CALL(vkBeginCommandBuffer(list->vk_command_buffer, &begin_info)))) ERR("Failed to begin command buffer, vr %d.\n", vr); + list->is_recording = TRUE; + allocator->current_command_list = list; return S_OK; @@ -415,9 +417,21 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Close(ID3D12GraphicsCommandL TRACE("iface %p.\n", iface); + if (!list->is_recording) + { + WARN("Command list is not in the recording state.\n"); + return E_FAIL; + } + vk_procs = &list->device->vk_procs; - vr = VK_CALL(vkEndCommandBuffer(list->vk_command_buffer)); - return hresult_from_vk_result(vr); + if ((vr = VK_CALL(vkEndCommandBuffer(list->vk_command_buffer)))) + { + WARN("Failed to end command buffer, vr %d.\n", vr); + return hresult_from_vk_result(vr); + } + + list->is_recording = FALSE; + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandList *iface, diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 3b016714..5d8f3205 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -136,6 +136,7 @@ struct d3d12_command_list D3D12_COMMAND_LIST_TYPE type; VkCommandBuffer vk_command_buffer; + BOOL is_recording; struct d3d12_command_allocator *allocator; struct d3d12_device *device; diff --git a/tests/d3d12.c b/tests/d3d12.c index 2caf6ba0..73fee2b4 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -855,7 +855,7 @@ static void test_reset_command_allocator(void) todo(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Close(command_list); - ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); + todo(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL); todo(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr);