vkd3d: Translate pthread error numbers to HRESULTs.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-11-09 18:06:23 +01:00 committed by Alexandre Julliard
parent f3ddbe0342
commit d539adaff8
5 changed files with 32 additions and 13 deletions

View File

@ -33,7 +33,7 @@ HRESULT vkd3d_queue_create(struct d3d12_device *device,
{
ERR("Failed to initialize mutex, error %d.\n", rc);
vkd3d_free(object);
return E_FAIL;
return hresult_from_errno(rc);
}
object->vk_family_index = family_index;
@ -89,7 +89,7 @@ static HRESULT vkd3d_enqueue_gpu_fence(struct vkd3d_fence_worker *worker,
if ((rc = pthread_mutex_lock(&worker->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
if (!vkd3d_array_reserve((void **)&worker->vk_fences, &worker->vk_fences_size,
@ -255,14 +255,14 @@ HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker,
if ((rc = pthread_mutex_init(&worker->mutex, NULL)))
{
ERR("Failed to initialize mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
if ((rc = pthread_cond_init(&worker->cond, NULL)))
{
ERR("Failed to initialize condition variable, error %d.\n", rc);
pthread_mutex_destroy(&worker->mutex);
return E_FAIL;
return hresult_from_errno(rc);
}
if (device->create_thread)
@ -283,7 +283,7 @@ HRESULT vkd3d_fence_worker_start(struct vkd3d_fence_worker *worker,
ERR("Failed to create fence worker thread, error %d.\n", rc);
pthread_mutex_destroy(&worker->mutex);
pthread_cond_destroy(&worker->cond);
return E_FAIL;
return hresult_from_errno(rc);
}
return S_OK;
@ -300,7 +300,7 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker,
if ((rc = pthread_mutex_lock(&worker->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
worker->should_exit = true;
@ -321,7 +321,7 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker,
if ((rc = pthread_join(worker->u.thread, NULL)))
{
ERR("Failed to join fence worker thread, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
}
@ -472,7 +472,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i
if ((rc = pthread_mutex_lock(&fence->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
if (value <= fence->value)
@ -521,7 +521,7 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_Signal(ID3D12Fence *iface, UINT64 v
if ((rc = pthread_mutex_lock(&fence->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
fence->value = value;
@ -580,7 +580,7 @@ static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device *
if ((rc = pthread_mutex_init(&fence->mutex, NULL)))
{
ERR("Failed to initialize mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
if (flags)

View File

@ -1275,7 +1275,7 @@ static HRESULT d3d12_device_init_pipeline_cache(struct d3d12_device *device)
if ((rc = pthread_mutex_init(&device->pipeline_cache_mutex, NULL)))
{
ERR("Failed to initialize mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
cache_info.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;

View File

@ -245,7 +245,7 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, UINT64 offset, void **dat
{
ERR("Failed to lock mutex, error %d.\n", rc);
*data = NULL;
return E_FAIL;
return hresult_from_errno(rc);
}
if (!heap->map_ptr)
@ -365,7 +365,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
if ((rc = pthread_mutex_init(&heap->mutex, NULL)))
{
ERR("Failed to initialize mutex, error %d.\n", rc);
return E_FAIL;
return hresult_from_errno(rc);
}
if (FAILED(hr = vkd3d_allocate_device_memory(device, &heap->desc.Properties,

View File

@ -18,6 +18,8 @@
#include "vkd3d_private.h"
#include <errno.h>
#define COLOR (VK_IMAGE_ASPECT_COLOR_BIT)
#define DEPTH (VK_IMAGE_ASPECT_DEPTH_BIT)
#define STENCIL (VK_IMAGE_ASPECT_STENCIL_BIT)
@ -381,6 +383,22 @@ const char *debug_vk_memory_property_flags(VkMemoryPropertyFlags flags)
return vkd3d_dbg_sprintf("%s", &buffer[3]);
}
HRESULT hresult_from_errno(int rc)
{
switch (rc)
{
case 0:
return S_OK;
case ENOMEM:
return E_OUTOFMEMORY;
case EINVAL:
return E_INVALIDARG;
default:
FIXME("Unhandled errno %d.\n", rc);
return E_FAIL;
}
}
HRESULT hresult_from_vk_result(VkResult vr)
{
switch (vr)

View File

@ -896,6 +896,7 @@ static inline void debug_ignored_node_mask(unsigned int mask)
FIXME("Ignoring node mask 0x%08x.\n", mask);
}
HRESULT hresult_from_errno(int rc) DECLSPEC_HIDDEN;
HRESULT hresult_from_vk_result(VkResult vr) DECLSPEC_HIDDEN;
HRESULT hresult_from_vkd3d_result(int vkd3d_result) DECLSPEC_HIDDEN;