1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-13 16:08:50 +01:00

[util] Always inline Rc::decRef and Rc::incRef

GCC feels the need to generate functions with two instructions for some
reason. Doesn't meaningfully change performance, but makes profiling a
lot easier in some instances.
This commit is contained in:
Philip Rebohle 2022-08-03 15:14:07 +02:00
parent ac2d3e952d
commit fc7e934854
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,8 @@
#include <atomic>
#include "../util_likely.h"
namespace dxvk {
/**
@ -15,7 +17,7 @@ namespace dxvk {
* \brief Increments reference count
* \returns New reference count
*/
uint32_t incRef() {
always_inline uint32_t incRef() {
return ++m_refCount;
}
@ -23,7 +25,7 @@ namespace dxvk {
* \brief Decrements reference count
* \returns New reference count
*/
uint32_t decRef() {
always_inline uint32_t decRef() {
return --m_refCount;
}

View File

@ -102,12 +102,12 @@ namespace dxvk {
T* m_object = nullptr;
void incRef() const {
always_inline void incRef() const {
if (m_object != nullptr)
m_object->incRef();
}
void decRef() const {
always_inline void decRef() const {
if (m_object != nullptr) {
if (m_object->decRef() == 0)
delete m_object;

View File

@ -3,7 +3,9 @@
#ifdef __GNUC__
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#define always_inline inline __attribute__((always_inline))
#else
#define likely(x) (x)
#define unlikely(x) (x)
#define always_inline inline
#endif