XLE
v0.02.0
|
A reference counted packet for small allocations More...
#include <RenderUtils.h>
Public Member Functions | |
void * | get () const never_throws |
operator bool () const never_throws | |
void * | begin () |
void * | end () |
const void * | begin () const |
const void * | end () const |
size_t | size () const |
SharedPkt (const SharedPkt &cloneFrom) | |
SharedPkt & | operator= (const SharedPkt &cloneFrom) |
SharedPkt (SharedPkt &&moveFrom) never_throws | |
SharedPkt & | operator= (SharedPkt &&moveFrom) never_throws |
void | swap (SharedPkt &other) never_throws |
Public Member Functions inherited from Utility::MiniHeap::Allocation | |
operator void * () | |
operator bool () | |
template<typename Type > | |
operator Type () | |
Allocation (void *a, uint32 marker) | |
Friends | |
SharedPkt | MakeSharedPktSize (size_t size) |
SharedPkt | MakeSharedPkt (const void *begin, const void *end) |
Additional Inherited Members | |
Public Attributes inherited from Utility::MiniHeap::Allocation | |
void * | _allocation |
uint32 | _marker |
A reference counted packet for small allocations
This object manage a small packet of reference counted memory in a way that reduces fragmentation and contention for the main heap.
Often we need to create small packets for constant buffer uploads. We want those packets to be variable sized (but typically multiples of 8), and have reference counting attached. Most of the time the allocations might be created and destroyed during a single frame (but sometimes the allocations can last longer).
This object uses a dedicated heap that is designed to deal with many small constant-buffer sized packets. It performs thread safe reference counting, so packets can be passed between threads safely.
By using a separate heap, we avoid polluting the main heap with these smaller (often short-lived) allocations.
SharedPkt has proper value semantics (it works like a smart pointer, but with a size attached). Prefer to use the "move" type methods to avoid unnecessary AddRef/Releases.