Module: vkd3d Branch: master Commit: 8ddca1ebaf376716baff259c4c7052a73404436d URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/8ddca1ebaf376716baff259c4c7052...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Jan 30 13:21:09 2024 +0100
vkd3d: Get rid of vkd3d_atomic_decrement().
---
configure.ac | 1 - libs/vkd3d/command.c | 2 +- libs/vkd3d/resource.c | 4 ++-- libs/vkd3d/vkd3d_private.h | 14 -------------- 4 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/configure.ac b/configure.ac index 0b84b1ab..4cb229d5 100644 --- a/configure.ac +++ b/configure.ac @@ -154,7 +154,6 @@ VKD3D_CHECK_FUNC([HAVE_BUILTIN_CLZ], [__builtin_clz], [__builtin_clz(0)]) VKD3D_CHECK_FUNC([HAVE_BUILTIN_POPCOUNT], [__builtin_popcount], [__builtin_popcount(0)]) VKD3D_CHECK_FUNC([HAVE_BUILTIN_ADD_OVERFLOW], [__builtin_add_overflow], [__builtin_add_overflow(0, 0, (int *)0)]) VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_and_fetch((int *)0, 0)]) -VKD3D_CHECK_FUNC([HAVE_SYNC_SUB_AND_FETCH], [__sync_sub_and_fetch], [__sync_sub_and_fetch((int *)0, 0)]) VKD3D_CHECK_FUNC([HAVE_SYNC_BOOL_COMPARE_AND_SWAP], [__sync_bool_compare_and_swap], [__sync_bool_compare_and_swap((int *)0, 0, 0)]) VKD3D_CHECK_FUNC([HAVE_ATOMIC_EXCHANGE_N], [__atomic_exchange_n], [__atomic_exchange_n((int *)0, 0, 0)]) AC_CHECK_FUNCS([gettid]) diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c index 132ab228..9a3e44c6 100644 --- a/libs/vkd3d/command.c +++ b/libs/vkd3d/command.c @@ -1926,7 +1926,7 @@ static void d3d12_command_signature_incref(struct d3d12_command_signature *signa
static void d3d12_command_signature_decref(struct d3d12_command_signature *signature) { - unsigned int refcount = vkd3d_atomic_decrement(&signature->internal_refcount); + unsigned int refcount = vkd3d_atomic_decrement_u32(&signature->internal_refcount);
if (!refcount) { diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 2368473a..8f4d1835 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -2321,7 +2321,7 @@ static void *vkd3d_desc_object_cache_get(struct vkd3d_desc_object_cache *cache) { if ((u.object = cache->heads[i].head)) { - vkd3d_atomic_decrement(&cache->free_count); + vkd3d_atomic_decrement_u32(&cache->free_count); cache->heads[i].head = u.header->next; vkd3d_atomic_exchange(&cache->heads[i].spinlock, 0); return u.object; @@ -2429,7 +2429,7 @@ void vkd3d_view_decref(void *view, struct d3d12_device *device) { union d3d12_desc_object u = {view};
- if (vkd3d_atomic_decrement(&u.header->refcount)) + if (vkd3d_atomic_decrement_u32(&u.header->refcount)) return;
if (u.header->magic != VKD3D_DESCRIPTOR_MAGIC_CBV) diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h index eb65397a..a74c49ea 100644 --- a/libs/vkd3d/vkd3d_private.h +++ b/libs/vkd3d/vkd3d_private.h @@ -257,11 +257,6 @@ static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond) { }
-static inline unsigned int vkd3d_atomic_decrement(unsigned int volatile *x) -{ - return InterlockedDecrement((LONG volatile *)x); -} - static inline bool vkd3d_atomic_compare_exchange(unsigned int volatile *x, unsigned int cmp, unsigned int xchg) { return InterlockedCompareExchange((LONG volatile *)x, xchg, cmp) == cmp; @@ -384,15 +379,6 @@ static inline void vkd3d_cond_destroy(struct vkd3d_cond *cond) ERR("Could not destroy the condition variable, error %d.\n", ret); }
-# if HAVE_SYNC_SUB_AND_FETCH -static inline unsigned int vkd3d_atomic_decrement(unsigned int volatile *x) -{ - return __sync_sub_and_fetch(x, 1); -} -# else -# error "vkd3d_atomic_decrement() not implemented for this platform" -# endif /* HAVE_SYNC_SUB_AND_FETCH */ - # if HAVE_SYNC_BOOL_COMPARE_AND_SWAP static inline bool vkd3d_atomic_compare_exchange(unsigned int volatile *x, unsigned int cmp, unsigned int xchg) {