vkd3d: Replace atomic_add_fetch() by InterlockedAdd().

By analogy with InterlockedIncrement. It avoids the need for a
configure check on Windows platforms.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
This commit is contained in:
Alexandre Julliard 2022-01-28 16:50:37 +01:00
parent ab3aa96e1f
commit beafa0914e
3 changed files with 8 additions and 13 deletions

View File

@ -201,6 +201,10 @@ static inline LONG InterlockedIncrement(LONG volatile *x)
{
return __sync_add_and_fetch(x, 1);
}
static inline LONG InterlockedAdd(LONG volatile *x, LONG val)
{
return __sync_add_and_fetch(x, val);
}
# else
# error "InterlockedIncrement() not implemented for this platform"
# endif /* HAVE_SYNC_ADD_AND_FETCH */
@ -215,15 +219,6 @@ static inline LONG InterlockedDecrement(LONG volatile *x)
# endif
#endif /* _WIN32 */
#if HAVE_SYNC_ADD_AND_FETCH
# define atomic_add_fetch(ptr, val) __sync_add_and_fetch(ptr, val)
#elif defined(_MSC_VER)
/* InterlockedAdd returns value after increment, like add_and_fetch. */
# define atomic_add_fetch(ptr, val) InterlockedAdd(ptr, val)
#else
# error "atomic_add_fetch() not implemented for this platform"
#endif /* HAVE_SYNC_ADD_AND_FETCH */
static inline void vkd3d_parse_version(const char *version, int *major, int *minor)
{
*major = atoi(version);

View File

@ -288,7 +288,7 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s
LONG count;
int rc;
if (!(count = atomic_add_fetch(&fence->pending_worker_operation_count, 0)))
if (!(count = InterlockedAdd(&fence->pending_worker_operation_count, 0)))
return;
WARN("Waiting for %u pending fence operations (fence %p).\n", count, fence);
@ -299,7 +299,7 @@ static void vkd3d_fence_worker_remove_fence(struct vkd3d_fence_worker *worker, s
return;
}
while ((count = atomic_add_fetch(&fence->pending_worker_operation_count, 0)))
while ((count = InterlockedAdd(&fence->pending_worker_operation_count, 0)))
{
TRACE("Still waiting for %u pending fence operations (fence %p).\n", count, fence);
@ -410,7 +410,7 @@ static void *vkd3d_fence_worker_main(void *arg)
{
vkd3d_wait_for_gpu_fences(worker);
if (!worker->fence_count || atomic_add_fetch(&worker->enqueued_fence_count, 0))
if (!worker->fence_count || InterlockedAdd(&worker->enqueued_fence_count, 0))
{
if ((rc = pthread_mutex_lock(&worker->mutex)))
{

View File

@ -192,7 +192,7 @@ struct vkd3d_fence_worker
bool should_exit;
bool pending_fence_destruction;
size_t enqueued_fence_count;
LONG enqueued_fence_count;
struct vkd3d_enqueued_fence
{
VkFence vk_fence;