8 #ifndef PXR_BASE_TRACE_DATA_BUFFER_H
9 #define PXR_BASE_TRACE_DATA_BUFFER_H
22 #include <type_traits>
48 "Must by copy constructible");
50 "No destructors will be called");
51 return new(_alloc.Allocate(
alignof(
T),
sizeof(
T)))
T(value);
57 const size_t strLen = std::strlen(str) + 1;
58 void* mem = _alloc.Allocate(
alignof(
char), strLen);
59 char* cstr =
reinterpret_cast<char*
>(mem);
60 std::memcpy(cstr, str, strLen);
70 : _desiredBlockSize(blockSize) {}
71 Allocator(Allocator&&) =
default;
72 Allocator&
operator=(Allocator&&) =
default;
74 Allocator(
const Allocator&) =
delete;
75 Allocator&
operator=(
const Allocator&) =
delete;
77 void* Allocate(
const size_t align,
const size_t size) {
78 Byte* alignedNext = AlignPointer(_next, align);
81 AllocateBlock(align, size);
82 alignedNext = AlignPointer(_next, align);
90 using Byte = std::uint8_t;
92 static Byte* AlignPointer(
Byte*
ptr,
const size_t align) {
93 const size_t alignMask = align - 1;
94 return reinterpret_cast<Byte*
>(
95 reinterpret_cast<uintptr_t>(ptr + alignMask) & ~alignMask);
98 TRACE_API void AllocateBlock(
const size_t align,
const size_t desiredSize);
100 Byte* _blockEnd =
nullptr;
101 Byte* _next =
nullptr;
102 using BlockPtr = std::unique_ptr<Byte[]>;
103 std::deque<BlockPtr> _blocks;
104 size_t _desiredBlockSize;
112 #endif // PXR_BASE_TRACE_DATA_BUFFER_H
GLsizei const GLfloat * value
static constexpr size_t DefaultAllocSize
const char * StoreData(const char *str)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
LeafData & operator=(const LeafData &)=delete
#define PXR_NAMESPACE_CLOSE_SCOPE
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t blockSize(VULKAN_HPP_NAMESPACE::Format format)
TraceDataBuffer(size_t allocSize=DefaultAllocSize)
const T * StoreData(const T &value)