From cf7b7505e93c96e3b63d9dc9a775b994a1572fa8 Mon Sep 17 00:00:00 2001 From: azhirnov Date: Thu, 21 Jan 2021 06:21:32 +0300 Subject: pipeline resource signature for vulkan --- Common/interface/BasicMath.hpp | 14 ++++++++++++++ Common/interface/FixedLinearAllocator.hpp | 7 ++++--- Common/interface/RefCntAutoPtr.hpp | 3 +-- 3 files changed, 19 insertions(+), 5 deletions(-) (limited to 'Common/interface') 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 +inline T ExtractBit(T& bits) +{ + static_assert(std::is_enum::value || std::is_integral::value, "T must be enum or integer type"); + + using U = std::conditional_t<(sizeof(T) > sizeof(Uint32)), Uint64, Uint32>; + VERIFY_EXPR(static_cast(bits) > 0); + + const U result = static_cast(bits) & ~(static_cast(bits) - U{1}); + bits = static_cast(static_cast(bits) & ~result); + + return static_cast(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(strlen(str) + 1); } void AddSpaceForString(const String& str) noexcept { - AddSpaceForString(str.c_str()); + if (!str.empty()) + AddSpace(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; -- cgit v1.2.3