vkd3d: Factor out vkd3d_join_thread().

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 2019-06-11 10:13:38 +02:00 committed by Alexandre Julliard
parent bc5e8a9cc2
commit 7ecd67aaa0
3 changed files with 25 additions and 19 deletions

View File

@ -467,22 +467,8 @@ HRESULT vkd3d_fence_worker_stop(struct vkd3d_fence_worker *worker,
pthread_mutex_unlock(&worker->mutex); pthread_mutex_unlock(&worker->mutex);
if (device->join_thread) if (FAILED(hr = vkd3d_join_thread(device->vkd3d_instance, &worker->thread)))
{
if (FAILED(hr = device->join_thread(worker->thread.handle)))
{
ERR("Failed to join fence worker thread, hr %#x.\n", hr);
return hr; return hr;
}
}
else
{
if ((rc = pthread_join(worker->thread.pthread, NULL)))
{
ERR("Failed to join fence worker thread, error %d.\n", rc);
return hresult_from_errno(rc);
}
}
pthread_mutex_destroy(&worker->mutex); pthread_mutex_destroy(&worker->mutex);
pthread_cond_destroy(&worker->cond); pthread_cond_destroy(&worker->cond);

View File

@ -3112,7 +3112,6 @@ static HRESULT d3d12_device_init(struct d3d12_device *device,
vkd3d_instance_incref(device->vkd3d_instance = instance); vkd3d_instance_incref(device->vkd3d_instance = instance);
device->vk_info = instance->vk_info; device->vk_info = instance->vk_info;
device->signal_event = instance->signal_event; device->signal_event = instance->signal_event;
device->join_thread = instance->join_thread;
device->wchar_size = instance->wchar_size; device->wchar_size = instance->wchar_size;
device->adapter_luid = create_info->adapter_luid; device->adapter_luid = create_info->adapter_luid;
@ -3223,6 +3222,28 @@ HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
return hr; return hr;
} }
HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread)
{
HRESULT hr = S_OK;
int rc;
if (instance->join_thread)
{
if (FAILED(hr = instance->join_thread(thread->handle)))
ERR("Failed to join thread, hr %#x.\n", hr);
}
else
{
if ((rc = pthread_join(thread->pthread, NULL)))
{
ERR("Failed to join thread, error %d.\n", rc);
hr = hresult_from_errno(rc);
}
}
return hr;
}
IUnknown *vkd3d_get_device_parent(ID3D12Device *device) IUnknown *vkd3d_get_device_parent(ID3D12Device *device)
{ {
struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device); struct d3d12_device *d3d12_device = impl_from_ID3D12Device(device);

View File

@ -149,6 +149,7 @@ union vkd3d_thread_handle
HRESULT vkd3d_create_thread(struct vkd3d_instance *instance, HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread) DECLSPEC_HIDDEN; PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread) DECLSPEC_HIDDEN;
HRESULT vkd3d_join_thread(struct vkd3d_instance *instance, union vkd3d_thread_handle *thread) DECLSPEC_HIDDEN;
struct vkd3d_fence_worker struct vkd3d_fence_worker
{ {
@ -1019,8 +1020,6 @@ struct d3d12_device
struct vkd3d_instance *vkd3d_instance; struct vkd3d_instance *vkd3d_instance;
PFN_vkd3d_join_thread join_thread;
IUnknown *parent; IUnknown *parent;
LUID adapter_luid; LUID adapter_luid;