From 335bde65503d14815fcdae25b79b2f56a31c230a 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: Implement d3d12_command_allocator_Reset(). --- libs/vkd3d/command.c | 31 +++++++++++++++++++++++++++++-- tests/d3d12.c | 12 ++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 98c5260c..dd4f3b83 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -196,9 +196,36 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_GetDevice(ID3D12Command static HRESULT STDMETHODCALLTYPE d3d12_command_allocator_Reset(ID3D12CommandAllocator *iface) { - FIXME("iface %p stub!\n", iface); + struct d3d12_command_allocator *allocator = impl_from_ID3D12CommandAllocator(iface); + const struct vkd3d_vk_device_procs *vk_procs; + struct d3d12_command_list *list; + struct d3d12_device *device; + VkResult vr; - return E_NOTIMPL; + TRACE("iface %p.\n", iface); + + if ((list = allocator->current_command_list)) + { + if (list->is_recording) + { + WARN("A command list using this allocator is in the recording state.\n"); + return E_FAIL; + } + + TRACE("Resetting command list %p.\n", list); + } + + device = allocator->device; + vk_procs = &device->vk_procs; + + if ((vr = VK_CALL(vkResetCommandPool(device->vk_device, allocator->vk_command_pool, + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT)))) + { + WARN("Resetting command pool failed, vr %d.\n", vr); + return hresult_from_vk_result(vr); + } + + return S_OK; } static const struct ID3D12CommandAllocatorVtbl d3d12_command_allocator_vtbl = diff --git a/tests/d3d12.c b/tests/d3d12.c index 73fee2b4..57d9b92d 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -827,26 +827,26 @@ static void test_reset_command_allocator(void) ok(SUCCEEDED(hr), "CreateCommandAllocator failed, hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT, command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list); ok(SUCCEEDED(hr), "CreateCommandList failed, hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); + ok(hr == E_FAIL, "Got unexpected hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Close(command_list); ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); hr = ID3D12CommandAllocator_Reset(command_allocator); - todo(hr == S_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL); todo(SUCCEEDED(hr), "Resetting Command list failed, hr %#x.\n", hr);