From 0c03bbe9b5a97782020dc84f54f4c79289868c26 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 14 Apr 2020 13:42:43 +0200 Subject: [PATCH] vkd3d: Implement ID3D12Device4::CreateCommandList1. Signed-off-by: Philip Rebohle --- libs/vkd3d/command.c | 36 ++++++++++++------------------------ libs/vkd3d/device.c | 26 ++++++++++++++++++++++++-- libs/vkd3d/vkd3d_private.h | 1 + 3 files changed, 37 insertions(+), 26 deletions(-) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 6875f4cc..9c5799aa 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -2013,7 +2013,7 @@ static const struct ID3D12CommandAllocatorVtbl d3d12_command_allocator_vtbl = d3d12_command_allocator_Reset, }; -static struct d3d12_command_allocator *unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface) +struct d3d12_command_allocator *unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface) { if (!iface) return NULL; @@ -6288,16 +6288,17 @@ static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d d3d12_device_add_ref(list->device = device); - list->allocator = allocator; - - if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator, list))) + if ((list->allocator = allocator)) { - d3d12_command_list_reset_state(list, initial_pipeline_state); - } - else - { - vkd3d_private_store_destroy(&list->private_store); - d3d12_device_release(device); + if (SUCCEEDED(hr = d3d12_command_allocator_allocate_command_buffer(allocator, list))) + { + d3d12_command_list_reset_state(list, initial_pipeline_state); + } + else + { + vkd3d_private_store_destroy(&list->private_store); + d3d12_device_release(device); + } } return hr; @@ -6307,23 +6308,10 @@ HRESULT d3d12_command_list_create(struct d3d12_device *device, UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface, ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list) { - struct d3d12_command_allocator *allocator; + struct d3d12_command_allocator *allocator = unsafe_impl_from_ID3D12CommandAllocator(allocator_iface); struct d3d12_command_list *object; HRESULT hr; - if (!(allocator = unsafe_impl_from_ID3D12CommandAllocator(allocator_iface))) - { - WARN("Command allocator is NULL.\n"); - return E_INVALIDARG; - } - - if (allocator->type != type) - { - WARN("Command list types do not match (allocator %#x, list %#x).\n", - allocator->type, type); - return E_INVALIDARG; - } - debug_ignored_node_mask(node_mask); if (!(object = vkd3d_malloc(sizeof(*object)))) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index af0e622d..66380b02 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2377,6 +2377,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommandList(d3d12_device_ifa ID3D12PipelineState *initial_pipeline_state, REFIID riid, void **command_list) { struct d3d12_device *device = impl_from_ID3D12Device(iface); + struct d3d12_command_allocator *allocator; struct d3d12_command_list *object; HRESULT hr; @@ -2385,6 +2386,19 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommandList(d3d12_device_ifa iface, node_mask, type, command_allocator, initial_pipeline_state, debugstr_guid(riid), command_list); + if (!(allocator = unsafe_impl_from_ID3D12CommandAllocator(command_allocator))) + { + WARN("Command allocator is NULL.\n"); + return E_INVALIDARG; + } + + if (allocator->type != type) + { + WARN("Command list types do not match (allocator %#x, list %#x).\n", + allocator->type, type); + return E_INVALIDARG; + } + if (FAILED(hr = d3d12_command_list_create(device, node_mask, type, command_allocator, initial_pipeline_state, &object))) return hr; @@ -3769,10 +3783,18 @@ static HRESULT STDMETHODCALLTYPE d3d12_device_CreateCommandList1(d3d12_device_if UINT node_mask, D3D12_COMMAND_LIST_TYPE type, D3D12_COMMAND_LIST_FLAGS flags, REFIID riid, void **command_list) { - FIXME("iface %p, node_mask 0x%08x, type %#x, flags %#x, riid %s, command_list %p stub!\n", + struct d3d12_device *device = impl_from_ID3D12Device(iface); + struct d3d12_command_list *object; + HRESULT hr; + + TRACE("iface %p, node_mask 0x%08x, type %#x, flags %#x, riid %s, command_list %p.\n", iface, node_mask, type, flags, debugstr_guid(riid), command_list); - return E_NOTIMPL; + if (FAILED(hr = d3d12_command_list_create(device, node_mask, type, NULL, NULL, &object))) + return hr; + + return return_interface(&object->ID3D12GraphicsCommandList_iface, + &IID_ID3D12GraphicsCommandList, riid, command_list); } static HRESULT STDMETHODCALLTYPE d3d12_device_CreateProtectedResourceSession(d3d12_device_iface *iface, diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index 76b1b8a8..cd27e850 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -1049,6 +1049,7 @@ struct d3d12_command_allocator HRESULT d3d12_command_allocator_create(struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator) DECLSPEC_HIDDEN; +struct d3d12_command_allocator *unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface) DECLSPEC_HIDDEN; enum vkd3d_pipeline_dirty_flag {