From ec2f43e5e37afafd58a4824e17760dac60eb9fa8 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 23 Sep 2024 01:15:19 +0200 Subject: [PATCH] [dxvk] Make DxvkResource manage its own destruction Necessary for actual resource refactors. We want view objects to use the resource's reference count wehenever possible. --- src/dxvk/dxvk_lifetime.h | 6 ++---- src/dxvk/dxvk_resource.h | 21 +++++++++------------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/dxvk/dxvk_lifetime.h b/src/dxvk/dxvk_lifetime.h index 4b021186..b211d6a1 100644 --- a/src/dxvk/dxvk_lifetime.h +++ b/src/dxvk/dxvk_lifetime.h @@ -71,10 +71,8 @@ namespace dxvk { } void release() const { - if (m_resource) { - if (!m_resource->release(m_access)) - delete m_resource; - } + if (m_resource) + m_resource->release(m_access); } }; diff --git a/src/dxvk/dxvk_resource.h b/src/dxvk/dxvk_resource.h index 7945a1b8..03ae6c6d 100644 --- a/src/dxvk/dxvk_resource.h +++ b/src/dxvk/dxvk_resource.h @@ -43,18 +43,16 @@ namespace dxvk { /** * \brief Increments reference count - * \returns New reference count */ - uint32_t incRef() { - return acquire(DxvkAccess::None); + void incRef() { + acquire(DxvkAccess::None); } /** * \brief Decrements reference count - * \returns New reference count */ - uint32_t decRef() { - return release(DxvkAccess::None); + void decRef() { + release(DxvkAccess::None); } /** @@ -62,10 +60,9 @@ namespace dxvk { * * Atomically increments both the reference count * as well as the use count for the given access. - * \returns New reference count */ - uint32_t acquire(DxvkAccess access) { - return uint32_t((m_useCount += getIncrement(access)) & RefcountMask); + void acquire(DxvkAccess access) { + m_useCount += getIncrement(access); } /** @@ -73,10 +70,10 @@ namespace dxvk { * * Atomically decrements both the reference count * as well as the use count for the given access. - * \returns New reference count */ - uint32_t release(DxvkAccess access) { - return uint32_t((m_useCount -= getIncrement(access)) & RefcountMask); + void release(DxvkAccess access) { + if (!(m_useCount -= getIncrement(access))) + delete this; } /**