1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[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.
This commit is contained in:
Philip Rebohle 2024-09-23 01:15:19 +02:00 committed by Philip Rebohle
parent 10164fdf4d
commit ec2f43e5e3
2 changed files with 11 additions and 16 deletions

View File

@ -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);
}
};

View File

@ -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;
}
/**