libs/vkd3d: Fix command list resetting.

A command list can be resetted to the same command allocator when it is
in use.
This commit is contained in:
Józef Kucia 2016-10-20 16:38:04 +02:00
parent 2189859532
commit fd9f1abb4f
2 changed files with 24 additions and 25 deletions

View File

@ -520,22 +520,6 @@ static HRESULT d3d12_command_list_begin_command_buffer(struct d3d12_command_list
return S_OK; 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, static HRESULT d3d12_command_allocator_allocate_command_buffer(struct d3d12_command_allocator *allocator,
struct d3d12_command_list *list) struct d3d12_command_list *list)
{ {
@ -1285,18 +1269,19 @@ static HRESULT STDMETHODCALLTYPE d3d12_command_list_Reset(ID3D12GraphicsCommandL
return E_FAIL; return E_FAIL;
} }
if (list->allocator == allocator_impl)
return d3d12_command_list_reset_command_buffer(list);
if (list->allocator) if (list->allocator)
{
d3d12_command_allocator_free_command_buffer(list->allocator, list); d3d12_command_allocator_free_command_buffer(list->allocator, list);
list->allocator = NULL;
}
list->allocator = allocator_impl; if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator_impl, list)))
list->pipeline_state = initial_state; {
if (FAILED(hr = d3d12_command_allocator_allocate_command_buffer(allocator_impl, list))) list->allocator = allocator_impl;
return hr; list->pipeline_state = initial_state;
}
return S_OK; return hr;
} }
static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCommandList *iface, static HRESULT STDMETHODCALLTYPE d3d12_command_list_ClearState(ID3D12GraphicsCommandList *iface,

View File

@ -1338,7 +1338,6 @@ static void test_reset_command_allocator(void)
uav_barrier(command_list, NULL); uav_barrier(command_list, NULL);
hr = ID3D12GraphicsCommandList_Close(command_list); hr = ID3D12GraphicsCommandList_Close(command_list);
ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Close failed, hr %#x.\n", hr);
exec_command_list(queue, command_list); exec_command_list(queue, command_list);
/* A command list can be reset when it is in use. */ /* 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); wait_queue_idle(device, queue);
hr = ID3D12CommandAllocator_Reset(command_allocator); hr = ID3D12CommandAllocator_Reset(command_allocator);
ok(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);
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); hr = ID3D12GraphicsCommandList_Reset(command_list, command_allocator, NULL);
ok(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr); ok(SUCCEEDED(hr), "Resetting command list failed, hr %#x.\n", hr);