From e7eb9ca93648f8f975dda334f3463c4cde32928c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B3zef=20Kucia?= Date: Wed, 12 Sep 2018 15:20:01 +0200 Subject: [PATCH] vkd3d: Simplify d3d12_device_init(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Józef Kucia Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- libs/vkd3d/device.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c index d39eef2c..cfb17ea1 100644 --- a/libs/vkd3d/device.c +++ b/libs/vkd3d/device.c @@ -2282,6 +2282,7 @@ struct d3d12_device *unsafe_impl_from_ID3D12Device(ID3D12Device *iface) static HRESULT d3d12_device_init(struct d3d12_device *device, struct vkd3d_instance *instance, const struct vkd3d_device_create_info *create_info) { + const struct vkd3d_vk_device_procs *vk_procs; HRESULT hr; device->ID3D12Device_iface.lpVtbl = &d3d12_device_vtbl; @@ -2295,30 +2296,22 @@ static HRESULT d3d12_device_init(struct d3d12_device *device, device->wchar_size = instance->wchar_size; device->adapter_luid = create_info->adapter_luid; + device->removed_reason = S_OK; + + device->vk_device = VK_NULL_HANDLE; + device->vk_dummy_sampler = VK_NULL_HANDLE; if (FAILED(hr = vkd3d_create_vk_device(device, create_info))) - { - vkd3d_instance_decref(device->vkd3d_instance); - return hr; - } + goto out_free_instance; if (FAILED(hr = d3d12_device_create_dummy_sampler(device))) { - const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; ERR("Failed to create dummy sampler, hr %#x.\n", hr); - VK_CALL(vkDestroyDevice(device->vk_device, NULL)); - vkd3d_instance_decref(device->vkd3d_instance); - return hr; + goto out_free_vk_resources; } if (FAILED(hr = vkd3d_fence_worker_start(&device->fence_worker, device))) - { - const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs; - VK_CALL(vkDestroySampler(device->vk_device, device->vk_dummy_sampler, NULL)); - VK_CALL(vkDestroyDevice(device->vk_device, NULL)); - vkd3d_instance_decref(device->vkd3d_instance); - return hr; - } + goto out_free_vk_resources; vkd3d_gpu_va_allocator_init(&device->gpu_va_allocator); @@ -2327,9 +2320,15 @@ static HRESULT d3d12_device_init(struct d3d12_device *device, if ((device->parent = create_info->parent)) IUnknown_AddRef(device->parent); - device->removed_reason = S_OK; - return S_OK; + +out_free_vk_resources: + vk_procs = &device->vk_procs; + VK_CALL(vkDestroySampler(device->vk_device, device->vk_dummy_sampler, NULL)); + VK_CALL(vkDestroyDevice(device->vk_device, NULL)); +out_free_instance: + vkd3d_instance_decref(device->vkd3d_instance); + return hr; } HRESULT d3d12_device_create(struct vkd3d_instance *instance,