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);
if (device->join_thread)
{
if (FAILED(hr = device->join_thread(worker->thread.handle)))
{
ERR("Failed to join fence worker thread, hr %#x.\n", 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);
}
}
if (FAILED(hr = vkd3d_join_thread(device->vkd3d_instance, &worker->thread)))
return hr;
pthread_mutex_destroy(&worker->mutex);
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);
device->vk_info = instance->vk_info;
device->signal_event = instance->signal_event;
device->join_thread = instance->join_thread;
device->wchar_size = instance->wchar_size;
device->adapter_luid = create_info->adapter_luid;
@ -3223,6 +3222,28 @@ HRESULT vkd3d_create_thread(struct vkd3d_instance *instance,
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)
{
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,
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
{
@ -1019,8 +1020,6 @@ struct d3d12_device
struct vkd3d_instance *vkd3d_instance;
PFN_vkd3d_join_thread join_thread;
IUnknown *parent;
LUID adapter_luid;