diff --git a/src/dxvk/dxvk_resource.h b/src/dxvk/dxvk_resource.h index 8f8342c97..087c48a9a 100644 --- a/src/dxvk/dxvk_resource.h +++ b/src/dxvk/dxvk_resource.h @@ -20,10 +20,7 @@ namespace dxvk { * is recorded, it will be marked as 'in use'. */ class DxvkResource : public RcObject { - constexpr static uint32_t UseCountIncrementW = 1 << 18; - constexpr static uint32_t UseCountIncrementR = 1; - constexpr static uint32_t UseCountMaskW = ~(UseCountIncrementW - 1); - constexpr static uint32_t UseCountMaskR = ~(UseCountIncrementR - 1); + public: virtual ~DxvkResource(); @@ -39,10 +36,10 @@ namespace dxvk { * \returns \c true if the resource is in use */ bool isInUse(DxvkAccess access = DxvkAccess::Read) const { - uint32_t mask = access == DxvkAccess::Write - ? UseCountMaskW - : UseCountMaskR; - return m_useCount.load() & mask; + bool result = m_useCountW.load(); + if (access == DxvkAccess::Read) + result |= m_useCountR.load(); + return result; } /** @@ -52,8 +49,11 @@ namespace dxvk { * \param Access Resource access type */ void acquire(DxvkAccess access) { - if (access != DxvkAccess::None) - m_useCount += getIncrement(access); + if (access != DxvkAccess::None) { + (access == DxvkAccess::Read + ? m_useCountR + : m_useCountW) += 1; + } } /** @@ -63,19 +63,17 @@ namespace dxvk { * \param Access Resource access type */ void release(DxvkAccess access) { - if (access != DxvkAccess::None) - m_useCount -= getIncrement(access); + if (access != DxvkAccess::None) { + (access == DxvkAccess::Read + ? m_useCountR + : m_useCountW) -= 1; + } } private: - std::atomic m_useCount = { 0u }; - - static constexpr uint32_t getIncrement(DxvkAccess access) { - return access == DxvkAccess::Write - ? UseCountIncrementW - : UseCountIncrementR; - } + std::atomic m_useCountR = { 0u }; + std::atomic m_useCountW = { 0u }; };