18#ifndef INCLUDED_PS_LINEARALLOCATOR
19#define INCLUDED_PS_LINEARALLOCATOR
26#include <fmt/format.h>
54#if defined(__cpp_lib_smart_ptr_for_overwrite)
68 void*
allocate(std::size_t n, std::size_t alignment)
79 "Tried to allocate from LinearAllocator with a size of {} but the capacity is only {}",
82#if defined(__cpp_lib_smart_ptr_for_overwrite)
94 void deallocate([[maybe_unused]]
void* ptr, [[maybe_unused]] std::size_t n)
146 void*
allocate(std::size_t n, std::size_t alignment)
#define ROUND_UP(n, multiple)
Definition: bits.h:143
Linear allocator (also known as an arena allocator or bump allocator) is a simple and fast system tha...
Definition: LinearAllocator.h:50
std::unique_ptr< std::byte[]> m_Buffer
Definition: LinearAllocator.h:114
std::size_t m_Size
Definition: LinearAllocator.h:113
PS::StaticVector< std::unique_ptr< std::byte[]>, 16 > m_BuffersToFree
Definition: LinearAllocator.h:118
std::size_t GetSize() const
Definition: LinearAllocator.h:101
std::uint32_t m_AllocationCount
Definition: LinearAllocator.h:116
LinearAllocator(const std::size_t initialSize, const std::size_t maxCapacity)
Definition: LinearAllocator.h:52
~LinearAllocator()
Definition: LinearAllocator.h:63
std::size_t GetCapacity() const
Definition: LinearAllocator.h:103
std::size_t m_Capacity
Definition: LinearAllocator.h:113
void deallocate(void *ptr, std::size_t n)
Definition: LinearAllocator.h:94
std::size_t m_MaxCapacity
Definition: LinearAllocator.h:113
void * allocate(std::size_t n, std::size_t alignment)
Definition: LinearAllocator.h:68
void Release()
Definition: LinearAllocator.h:105
Definition: LinearAllocator.h:132
std::uint32_t m_AllocationCount
Definition: LinearAllocator.h:161
void deallocate(void *ptr, std::size_t n)
Definition: LinearAllocator.h:152
~ScopedLinearAllocator()
Definition: LinearAllocator.h:140
void * allocate(std::size_t n, std::size_t alignment)
Definition: LinearAllocator.h:146
ScopedLinearAllocator(LinearAllocator &allocator)
Definition: LinearAllocator.h:134
LinearAllocator & m_Allocator
Definition: LinearAllocator.h:160
A conntainer close to std::vector but the elements are stored in place: There is a fixed capacity and...
Definition: StaticVector.h:89
void clear() noexcept
Definition: StaticVector.h:395
reference emplace_back(Args &&... args)
If an exception is thrown this function has no effect (strong exception guarantee).
Definition: StaticVector.h:477
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
Definition: debug.h:222
Definition: AllocatorAdapter.h:26
Definition: ShaderDefines.cpp:43
Definition: StaticVector.h:35