Nugget
Loading...
Searching...
No Matches
Public Member Functions | List of all members
psyqo::BumpAllocator< N, safety > Class Template Reference

A bump allocator for fragments. More...

#include <psyqo/bump-allocator.hh>

Public Member Functions

template<Primitive P, typename... Args>
Fragments::SimpleFragment< P > & allocateFragment (Args &&...args)
 
template<typename T , typename... Args>
T & allocate (Args &&...args)
 
void reset ()
 
size_t remaining () const
 
size_t used () const
 

Detailed Description

template<size_t N, Safe safety = Safe::Yes>
class psyqo::BumpAllocator< N, safety >

A bump allocator for fragments.

This allocator is used to allocate fragments without the need for dynamic memory allocation. It is useful for allocating fragments to render in a complex scene, where the number of fragments isn't known at compile time.

The allocator will need to be reset at the beginning of each frame, to ensure that the memory is properly reused. Also, don't forget to double buffer the allocator when chaining fragments allocated with it.

The allocate method works with both primitives, and custom fragments. It will always return a reference to the allocated fragment.

Template Parameters
NThe size of the memory buffer in bytes.

Member Function Documentation

◆ allocate()

template<size_t N, Safe safety = Safe::Yes>
template<typename T , typename... Args>
T & psyqo::BumpAllocator< N, safety >::allocate ( Args &&...  args)
inline

◆ allocateFragment()

template<size_t N, Safe safety = Safe::Yes>
template<Primitive P, typename... Args>
Fragments::SimpleFragment< P > & psyqo::BumpAllocator< N, safety >::allocateFragment ( Args &&...  args)
inline

◆ remaining()

template<size_t N, Safe safety = Safe::Yes>
size_t psyqo::BumpAllocator< N, safety >::remaining ( ) const
inline

◆ reset()

template<size_t N, Safe safety = Safe::Yes>
void psyqo::BumpAllocator< N, safety >::reset ( )
inline

◆ used()

template<size_t N, Safe safety = Safe::Yes>
size_t psyqo::BumpAllocator< N, safety >::used ( ) const
inline

The documentation for this class was generated from the following file: