diff --git a/src/util/com/com_pointer.h b/src/util/com/com_pointer.h index 2c91c03a..9583bd4b 100644 --- a/src/util/com/com_pointer.h +++ b/src/util/com/com_pointer.h @@ -18,6 +18,26 @@ namespace dxvk { return object; } + + /** + * \brief Ref count methods for public references + */ + template + struct ComRef_ { + static void incRef(T* ptr) { ptr->AddRef(); } + static void decRef(T* ptr) { ptr->Release(); } + }; + + + /** + * \brief Ref count methods for private references + */ + template + struct ComRef_ { + static void incRef(T* ptr) { ptr->AddRefPrivate(); } + static void decRef(T* ptr) { ptr->ReleasePrivate(); } + }; + /** * \brief COM pointer @@ -27,7 +47,7 @@ namespace dxvk { */ template class Com { - + using ComRef = ComRef_; public: Com() { } @@ -107,21 +127,13 @@ namespace dxvk { T* m_ptr = nullptr; void incRef() const { - if (m_ptr != nullptr) { - if constexpr (Public) - m_ptr->AddRef(); - else - m_ptr->AddRefPrivate(); - } + if (m_ptr != nullptr) + ComRef::incRef(m_ptr); } void decRef() const { - if (m_ptr != nullptr) { - if constexpr (Public) - m_ptr->Release(); - else - m_ptr->ReleasePrivate(); - } + if (m_ptr != nullptr) + ComRef::decRef(m_ptr); } };