diff options
| author | azhirnov <zh1dron@gmail.com> | 2021-01-21 03:21:32 +0000 |
|---|---|---|
| committer | azhirnov <zh1dron@gmail.com> | 2021-01-21 03:35:02 +0000 |
| commit | cf7b7505e93c96e3b63d9dc9a775b994a1572fa8 (patch) | |
| tree | a1a81e131b10a0edeb87740c56435c37d1dfc5c3 /Common/interface | |
| parent | added pipeline resource signature (wip) (diff) | |
| download | DiligentCore-cf7b7505e93c96e3b63d9dc9a775b994a1572fa8.tar.gz DiligentCore-cf7b7505e93c96e3b63d9dc9a775b994a1572fa8.zip | |
pipeline resource signature for vulkan
Diffstat (limited to 'Common/interface')
| -rw-r--r-- | Common/interface/BasicMath.hpp | 14 | ||||
| -rw-r--r-- | Common/interface/FixedLinearAllocator.hpp | 7 | ||||
| -rw-r--r-- | Common/interface/RefCntAutoPtr.hpp | 3 |
3 files changed, 19 insertions, 5 deletions
diff --git a/Common/interface/BasicMath.hpp b/Common/interface/BasicMath.hpp index 05a168fc..78e9beaf 100644 --- a/Common/interface/BasicMath.hpp +++ b/Common/interface/BasicMath.hpp @@ -2189,6 +2189,20 @@ inline Uint32 BitInterleave16(Uint16 _x, Uint16 _y) return x | (y << 1u); } +template <typename T> +inline T ExtractBit(T& bits) +{ + static_assert(std::is_enum<T>::value || std::is_integral<T>::value, "T must be enum or integer type"); + + using U = std::conditional_t<(sizeof(T) > sizeof(Uint32)), Uint64, Uint32>; + VERIFY_EXPR(static_cast<U>(bits) > 0); + + const U result = static_cast<U>(bits) & ~(static_cast<U>(bits) - U{1}); + bits = static_cast<T>(static_cast<U>(bits) & ~result); + + return static_cast<T>(result); +} + } // namespace Diligent diff --git a/Common/interface/FixedLinearAllocator.hpp b/Common/interface/FixedLinearAllocator.hpp index 44629f91..c7718ed5 100644 --- a/Common/interface/FixedLinearAllocator.hpp +++ b/Common/interface/FixedLinearAllocator.hpp @@ -136,13 +136,14 @@ public: void AddSpaceForString(const Char* str) noexcept { - VERIFY_EXPR(str != nullptr); - AddSpace(strlen(str) + 1, 1); + if (str != nullptr) + AddSpace<Char>(strlen(str) + 1); } void AddSpaceForString(const String& str) noexcept { - AddSpaceForString(str.c_str()); + if (!str.empty()) + AddSpace<String::value_type>(str.length() + 1); } void Reserve(size_t size) diff --git a/Common/interface/RefCntAutoPtr.hpp b/Common/interface/RefCntAutoPtr.hpp index 2b89ffe8..45dbf574 100644 --- a/Common/interface/RefCntAutoPtr.hpp +++ b/Common/interface/RefCntAutoPtr.hpp @@ -31,7 +31,6 @@ #include "../../Platforms/interface/Atomics.hpp" #include "ValidatedCast.hpp" #include "RefCountedObjectImpl.hpp" -#include "CompilerDefinitions.h" namespace Diligent { @@ -136,7 +135,7 @@ public: m_pObject = pObj; } - NODISCARD T* Detach() noexcept + T* Detach() noexcept { T* pObj = m_pObject; m_pObject = nullptr; |
