Giovanni Mascellani (@giomasce) commented about libs/vkd3d/device.c:
+ static struct vkd3d_mutex key_cache_mutex = {VKD3D_MUTEX_INITIALIZER}; + static struct vkd3d_tls_key tls_key; + static bool tls_initialised; + int rc = 0; + + vkd3d_mutex_lock(&key_cache_mutex); + + if (!tls_initialised) + { + rc = vkd3d_tls_key_create(&tls_key, global_tls_key_destroy); + desc_rebalance_init(&view_desc_rebalance); + desc_rebalance_init(&cbuffer_desc_rebalance); + tls_initialised = true; + } + + vkd3d_mutex_unlock(&key_cache_mutex); I guess this can be done more efficiently with `pthread_once()` and `InitOnceExecuteOnce()`. Though it's probably not a bottleneck anyway.
-- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/384#note_48506