vkd3d: Do not allow synchronization primitives to fail.

In practice they never fail. If they fail, it means that there
is some underlying platform problem and there is little we can do
anyway. Under pthreads function prototypes allow returning failure,
but that's only used for "error checking" mutexes, which we
don't use.

On the other hand, error handling in vkd3d is rather inconsistent:
sometimes the errors are ignored, sometimes logged, sometimes
passed to the caller. It's hard to handle failures appropriately
if you can't even keep your state consistent, so I think it's
better to avoid trying, assume that synchronization primitives do
not fail and at least have consistent logging if something goes
wrong.
This commit is contained in:
Giovanni Mascellani
2023-01-27 16:45:05 +01:00
committed by Alexandre Julliard
parent a66fe31fe5
commit 552926cfca
Notes: Alexandre Julliard 2023-02-02 22:14:51 +01:00
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/75
6 changed files with 129 additions and 355 deletions

View File

@@ -443,15 +443,8 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset,
struct d3d12_device *device = heap->device;
HRESULT hr = S_OK;
VkResult vr;
int rc;
if ((rc = vkd3d_mutex_lock(&heap->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
if (data)
*data = NULL;
return hresult_from_errno(rc);
}
vkd3d_mutex_lock(&heap->mutex);
assert(!resource->map_count || heap->map_ptr);
@@ -501,13 +494,8 @@ static HRESULT d3d12_heap_map(struct d3d12_heap *heap, uint64_t offset,
static void d3d12_heap_unmap(struct d3d12_heap *heap, struct d3d12_resource *resource)
{
struct d3d12_device *device = heap->device;
int rc;
if ((rc = vkd3d_mutex_lock(&heap->mutex)))
{
ERR("Failed to lock mutex, error %d.\n", rc);
return;
}
vkd3d_mutex_lock(&heap->mutex);
if (!resource->map_count)
{
@@ -570,7 +558,6 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
VkMemoryRequirements memory_requirements;
VkDeviceSize vk_memory_size;
HRESULT hr;
int rc;
heap->ID3D12Heap_iface.lpVtbl = &d3d12_heap_vtbl;
heap->refcount = 1;
@@ -596,11 +583,7 @@ static HRESULT d3d12_heap_init(struct d3d12_heap *heap,
if (FAILED(hr = validate_heap_desc(&heap->desc, resource)))
return hr;
if ((rc = vkd3d_mutex_init(&heap->mutex)))
{
ERR("Failed to initialize mutex, error %d.\n", rc);
return hresult_from_errno(rc);
}
vkd3d_mutex_init(&heap->mutex);
if (FAILED(hr = vkd3d_private_store_init(&heap->private_store)))
{