summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2021-03-14 02:11:59 +0000
committerassiduous <assiduous@diligentgraphics.com>2021-03-19 00:38:22 +0000
commit00219a5bdbe63aee3957de193fe640f499f01eb4 (patch)
tree5bb5cddda4b76861fe5f0e8d2120f9b085bd2173 /Common/interface
parentDirect3D11: added BindPointsD3D11 instead of TBindPoints and TBindPointsAndAc... (diff)
downloadDiligentCore-00219a5bdbe63aee3957de193fe640f499f01eb4.tar.gz
DiligentCore-00219a5bdbe63aee3957de193fe640f499f01eb4.zip
Renamed Align to AlignUp
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/Align.hpp6
-rw-r--r--Common/interface/DynamicLinearAllocator.hpp4
-rw-r--r--Common/interface/FixedLinearAllocator.hpp12
3 files changed, 11 insertions, 11 deletions
diff --git a/Common/interface/Align.hpp b/Common/interface/Align.hpp
index b22a7717..a20d19d1 100644
--- a/Common/interface/Align.hpp
+++ b/Common/interface/Align.hpp
@@ -44,7 +44,7 @@ bool IsPowerOfTwo(T val)
}
template <typename T1, typename T2>
-inline typename std::conditional<sizeof(T1) >= sizeof(T2), T1, T2>::type Align(T1 val, T2 alignment)
+inline typename std::conditional<sizeof(T1) >= sizeof(T2), T1, T2>::type AlignUp(T1 val, T2 alignment)
{
static_assert(std::is_unsigned<T1>::value == std::is_unsigned<T2>::value, "both types must be signed or unsigned");
static_assert(!std::is_pointer<T1>::value && !std::is_pointer<T2>::value, "types must not be pointers");
@@ -55,9 +55,9 @@ inline typename std::conditional<sizeof(T1) >= sizeof(T2), T1, T2>::type Align(T
}
template <typename PtrType, typename AlignType>
-inline PtrType* Align(PtrType* val, AlignType alignment)
+inline PtrType* AlignUp(PtrType* val, AlignType alignment)
{
- return reinterpret_cast<PtrType*>(Align(reinterpret_cast<uintptr_t>(val), static_cast<uintptr_t>(alignment)));
+ return reinterpret_cast<PtrType*>(AlignUp(reinterpret_cast<uintptr_t>(val), static_cast<uintptr_t>(alignment)));
}
template <typename T1, typename T2>
diff --git a/Common/interface/DynamicLinearAllocator.hpp b/Common/interface/DynamicLinearAllocator.hpp
index 1ab9c5ee..d5987a35 100644
--- a/Common/interface/DynamicLinearAllocator.hpp
+++ b/Common/interface/DynamicLinearAllocator.hpp
@@ -90,7 +90,7 @@ public:
for (auto& block : m_Blocks)
{
- auto* Ptr = Align(block.CurrPtr, align);
+ auto* Ptr = AlignUp(block.CurrPtr, align);
if (Ptr + size <= block.Data + block.Size)
{
block.CurrPtr = Ptr + size;
@@ -105,7 +105,7 @@ public:
m_Blocks.emplace_back(m_pAllocator->Allocate(BlockSize, "dynamic linear allocator page", __FILE__, __LINE__), BlockSize);
auto& block = m_Blocks.back();
- auto* Ptr = Align(block.Data, align);
+ auto* Ptr = AlignUp(block.Data, align);
VERIFY(Ptr + size <= block.Data + block.Size, "Not enough space in the new block - this is a bug");
block.CurrPtr = Ptr + size;
return Ptr;
diff --git a/Common/interface/FixedLinearAllocator.hpp b/Common/interface/FixedLinearAllocator.hpp
index 2c47ccc0..327ed8ad 100644
--- a/Common/interface/FixedLinearAllocator.hpp
+++ b/Common/interface/FixedLinearAllocator.hpp
@@ -124,7 +124,7 @@ public:
}
m_CurrAlignment = alignment;
- size = Align(size, alignment);
+ size = AlignUp(size, alignment);
m_ReservedSize += size;
#if DILIGENT_DEBUG
@@ -163,11 +163,11 @@ public:
VERIFY(m_pDataStart == nullptr, "Memory has already been allocated");
VERIFY(m_pAllocator != nullptr, "Allocator must not be null");
// Make sure the data size is at least sizeof(void*)-aligned
- m_ReservedSize = Align(m_ReservedSize, sizeof(void*));
+ m_ReservedSize = AlignUp(m_ReservedSize, sizeof(void*));
if (m_ReservedSize > 0)
{
m_pDataStart = reinterpret_cast<uint8_t*>(m_pAllocator->Allocate(m_ReservedSize, "Raw memory for linear allocator", __FILE__, __LINE__));
- VERIFY(m_pDataStart == Align(m_pDataStart, sizeof(void*)), "Memory pointer must be at least sizeof(void*)-aligned");
+ VERIFY(m_pDataStart == AlignUp(m_pDataStart, sizeof(void*)), "Memory pointer must be at least sizeof(void*)-aligned");
m_pCurrPtr = m_pDataStart;
}
@@ -182,7 +182,7 @@ public:
if (size == 0)
return nullptr;
- size = Align(size, alignment);
+ size = AlignUp(size, alignment);
#if DILIGENT_DEBUG
VERIFY(m_DbgCurrAllocation < m_DbgAllocations.size(), "Allocation number exceed the number of allocations that were originally reserved.");
@@ -191,8 +191,8 @@ public:
VERIFY(CurrAllocation.alignment == alignment, "Allocation alignment (", alignment, ") does not match the initially requested alignment (", CurrAllocation.alignment, ")");
#endif
- VERIFY(Align(m_pCurrPtr, m_CurrAlignment) == m_pCurrPtr, "Current pointer is not aligned as expected");
- m_pCurrPtr = Align(m_pCurrPtr, alignment);
+ VERIFY(AlignUp(m_pCurrPtr, m_CurrAlignment) == m_pCurrPtr, "Current pointer is not aligned as expected");
+ m_pCurrPtr = AlignUp(m_pCurrPtr, alignment);
m_CurrAlignment = alignment;
VERIFY(m_pCurrPtr + size <= m_pDataStart + CurrAllocation.reserved_size,