=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: libs/vkd3d: Release current command allocator in d3d12_command_list_Close().

Alexandre Julliard julliard at winehq.org
Tue Jan 9 13:38:51 CST 2018


Module: vkd3d
Branch: master
Commit: 5d85da0d84a9be3348a12f0b3584a59acfebeb88
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=5d85da0d84a9be3348a12f0b3584a59acfebeb88

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Tue Jan  9 13:13:10 2018 +0100

libs/vkd3d: Release current command allocator in d3d12_command_list_Close().

d3d12_command_allocator_free_command_buffer() is not a very accurate name.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/vkd3d/command.c | 12 ++++++------
 tests/d3d12.c        | 13 ++++++++++++-
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index a603c2b..cda3c1f 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -1426,6 +1426,12 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Close(ID3D12GraphicsCommandL
         return hresult_from_vk_result(vr);
     }
 
+    if (list->allocator)
+    {
+        d3d12_command_allocator_free_command_buffer(list->allocator, list);
+        list->allocator = NULL;
+    }
+
     list->is_recording = false;
 
     if (!list->is_valid)
@@ -1459,12 +1465,6 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandL
         return E_FAIL;
     }
 
-    if (list->allocator)
-    {
-        d3d12_command_allocator_free_command_buffer(list->allocator, list);
-        list->allocator = NULL;
-    }
-
     if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator_impl, list)))
     {
         list->allocator = allocator_impl;
diff --git a/tests/d3d12.c b/tests/d3d12.c
index c9e6336..dfc9257 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -2928,12 +2928,23 @@ static void test_reset_command_allocator(void)
 
     hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
             command_allocator2, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list2);
-    ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+    ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
 
     hr = ID3D12GraphicsCommandList_Close(command_list2);
     ok(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr);
     hr = ID3D12GraphicsCommandList_Reset(command_list2, command_allocator, NULL);
     ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    ID3D12GraphicsCommandList_Release(command_list2);
+
+    /* A command allocator can be re-used after closing the command list. */
+    hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
+            command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list2);
+    ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+    hr = ID3D12GraphicsCommandList_Close(command_list);
+    ok(SUCCEEDED(hr), "Failed to close command list, hr %#x.\n", hr);
+    hr = ID3D12Device_CreateCommandList(device, 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
+            command_allocator, NULL, &IID_ID3D12GraphicsCommandList, (void **)&command_list2);
+    ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
 
     ID3D12CommandAllocator_Release(command_allocator);
     ID3D12CommandAllocator_Release(command_allocator2);




More information about the wine-cvs mailing list