diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 8e59e16e..7fc81b52 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -520,22 +520,6 @@ static HRESULT d3d12_command_list_begin_command_buffer(struct d3d12_command_list return S_OK; } -static HRESULT d3d12_command_list_reset_command_buffer(struct d3d12_command_list *list) -{ - struct d3d12_device *device = list->device; - const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; - VkResult vr; - - if ((vr = VK_CALL(vkResetCommandBuffer(list->vk_command_buffer, - VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT))) < 0) - { - WARN("Failed to reset command buffer, vr %d.\n", vr); - return hresult_from_vk_result(vr); - } - - return d3d12_command_list_begin_command_buffer(list); -} - static HRESULT d3d12_command_allocator_allocate_command_buffer(struct d3d12_command_allocator *allocator, struct d3d12_command_list *list) { @@ -1285,18 +1269,19 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandL return E_FAIL; } - if (list->allocator == allocator_impl) - return d3d12_command_list_reset_command_buffer(list); - if (list->allocator) + { d3d12_command_allocator_free_command_buffer(list->allocator, list); + list->allocator = NULL; + } - list->allocator = allocator_impl; - list->pipeline_state = initial_state; - if (FAILED(hr = d3d12_command_allocator_allocate_command_buffer(allocator_impl, list))) - return hr; + if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator_impl, list))) + { + list->allocator = allocator_impl; + list->pipeline_state = initial_state; + } - return S_OK; + return hr; } static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCommandList *iface, diff --git a/tests/d3d12.c b/tests/d3d12.c index 756b0fde..e59788e6 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -1338,7 +1338,6 @@ static void test_reset_command_allocator(void) uav_barrier(command_list, NULL); hr = ID3D12GraphicsCommandList_Close(command_list); ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); - exec_command_list(queue, command_list); /* A command list can be reset when it is in use. */ @@ -1350,7 +1349,22 @@ static void test_reset_command_allocator(void) wait_queue_idle(device, queue); hr = ID3D12CommandAllocator_Reset(command_allocator); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); + hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL); + ok(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr); + uav_barrier(command_list, NULL); + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); + exec_command_list(queue, command_list); + + hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL); + ok(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr); + hr = ID3D12GraphicsCommandList_Close(command_list); + ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); + + wait_queue_idle(device, queue); + hr = ID3D12CommandAllocator_Reset(command_allocator); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL); ok(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr);