17 INLINE VertexDataBuffer::
19 _resident_data(nullptr),
28 INLINE VertexDataBuffer::
29 VertexDataBuffer(
size_t size) :
30 _resident_data(nullptr),
34 do_unclean_realloc(size);
41 INLINE VertexDataBuffer::
43 _resident_data(nullptr),
53 INLINE VertexDataBuffer::
70 const unsigned char *ptr;
71 if (_resident_data !=
nullptr || _size == 0) {
74 nassertr(_block !=
nullptr,
nullptr);
75 nassertr(_reserved_size >= _size,
nullptr);
80 ptr = _block->get_pointer(force);
83 assert(((uintptr_t)ptr % MEMORY_HOOK_ALIGNMENT) == 0);
85 return (
const unsigned char *)ASSUME_ALIGNED(ptr, MEMORY_HOOK_ALIGNMENT);
95 if (_resident_data ==
nullptr && _reserved_size != 0) {
98 nassertr(_reserved_size >= _size,
nullptr);
100 assert(((uintptr_t)_resident_data % MEMORY_HOOK_ALIGNMENT) == 0);
102 return (
unsigned char *)ASSUME_ALIGNED(_resident_data, MEMORY_HOOK_ALIGNMENT);
122 return _reserved_size;
133 nassertv(size <= _reserved_size);
136 if (_resident_data ==
nullptr && _reserved_size != 0) {
155 do_clean_realloc(reserved_size);
168 do_unclean_realloc(reserved_size);
178 do_unclean_realloc(0);
unsigned char * get_write_pointer()
Returns a writable pointer to the raw data.
size_t get_size() const
Returns the number of bytes in the buffer.
const unsigned char * get_read_pointer(bool force) const
Returns a read-only pointer to the raw data, or NULL if the data is not currently resident.
void clear()
Empties the buffer and sets its size to 0.
void clean_realloc(size_t reserved_size)
Changes the "reserved" size of the buffer, preserving its data (except for any data beyond the new en...
Similar to MutexHolder, but for a light mutex.
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object.
size_t get_reserved_size() const
Returns the total number of bytes "reserved" in the buffer.
void set_size(size_t size)
Changes the size of the buffer.
A collection of VertexDataPages, which can be used to allocate new VertexDataBlock objects.
void unclean_realloc(size_t reserved_size)
Changes the size of the buffer, without regard to preserving its data.
void page_out(VertexDataBook &book)
Moves the buffer out of independent memory and puts it on a page in the indicated book.