25 #ifndef PXR_BASE_TRACE_DATA_BUFFER_H
26 #define PXR_BASE_TRACE_DATA_BUFFER_H
39 #include <type_traits>
65 "Must by copy constructible");
67 "No destructors will be called");
68 return new(_alloc.Allocate(
alignof(
T),
sizeof(
T)))
T(value);
74 const size_t strLen = std::strlen(str) + 1;
75 void* mem = _alloc.Allocate(
alignof(
char), strLen);
76 char* cstr =
reinterpret_cast<char*
>(mem);
77 std::memcpy(cstr, str, strLen);
87 : _desiredBlockSize(blockSize) {}
88 Allocator(Allocator&&) =
default;
89 Allocator&
operator=(Allocator&&) =
default;
91 Allocator(
const Allocator&) =
delete;
92 Allocator&
operator=(
const Allocator&) =
delete;
94 void* Allocate(
const size_t align,
const size_t size) {
95 Byte* alignedNext = AlignPointer(_next, align);
98 AllocateBlock(align, size);
99 alignedNext = AlignPointer(_next, align);
107 using Byte = std::uint8_t;
109 static Byte* AlignPointer(
Byte*
ptr,
const size_t align) {
110 const size_t alignMask = align - 1;
111 return reinterpret_cast<Byte*
>(
112 reinterpret_cast<uintptr_t>(ptr + alignMask) & ~alignMask);
115 TRACE_API void AllocateBlock(
const size_t align,
const size_t desiredSize);
117 Byte* _blockEnd =
nullptr;
118 Byte* _next =
nullptr;
119 using BlockPtr = std::unique_ptr<Byte[]>;
120 std::deque<BlockPtr> _blocks;
121 size_t _desiredBlockSize;
129 #endif // PXR_BASE_TRACE_DATA_BUFFER_H
GLsizei const GLfloat * value
fallback_uintptr uintptr_t
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)