A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object. More...
#include "vertexDataBuffer.h"
Public Member Functions | |
VertexDataBuffer (size_t size) | |
VertexDataBuffer (const VertexDataBuffer ©) | |
void | clean_realloc (size_t reserved_size) |
Changes the "reserved" size of the buffer, preserving its data (except for any data beyond the new end of the buffer, if the buffer is being reduced). More... | |
void | clear () |
Empties the buffer and sets its size to 0. More... | |
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. More... | |
size_t | get_reserved_size () const |
Returns the total number of bytes "reserved" in the buffer. More... | |
size_t | get_size () const |
Returns the number of bytes in the buffer. More... | |
unsigned char * | get_write_pointer () |
Returns a writable pointer to the raw data. More... | |
void | operator= (const VertexDataBuffer ©) |
void | page_out (VertexDataBook &book) |
Moves the buffer out of independent memory and puts it on a page in the indicated book. More... | |
void | set_size (size_t size) |
Changes the size of the buffer. More... | |
void | swap (VertexDataBuffer &other) |
Swaps the data buffers between this one and the other one. More... | |
void | unclean_realloc (size_t reserved_size) |
Changes the size of the buffer, without regard to preserving its data. More... | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object.
At any point, a buffer may be in any of two states:
independent - the buffer's memory is resident, and owned by the VertexDataBuffer object itself (in _resident_data). In this state, _reserved_size might be greater than or equal to _size.
paged - the buffer's memory is owned by a VertexDataBlock. That block might itself be resident, compressed, or paged to disk. If it is resident, the memory may still be accessed directly from the block. However, this memory is considered read-only. In this state, _reserved_size will always equal _size.
VertexDataBuffers start out in independent state. They get moved to paged state when their owning GeomVertexArrayData objects get evicted from the _independent_lru. They can get moved back to independent state if they are modified (e.g. get_write_pointer() or realloc() is called).
The idea is to keep the highly dynamic and frequently-modified VertexDataBuffers resident in easy-to-access memory, while collecting the static and rarely accessed VertexDataBuffers together onto pages, where they may be written to disk as a block when necessary.
Definition at line 52 of file vertexDataBuffer.h.
|
inline |
Changes the "reserved" size of the buffer, preserving its data (except for any data beyond the new end of the buffer, if the buffer is being reduced).
If the buffer is expanded, the new data is uninitialized.
It is an error to set the reserved size smaller than the size specified with set_size().
Definition at line 153 of file vertexDataBuffer.I.
|
inline |
Empties the buffer and sets its size to 0.
Definition at line 175 of file vertexDataBuffer.I.
|
inline |
Returns a read-only pointer to the raw data, or NULL if the data is not currently resident.
If the data is not currently resident, this will implicitly request it to become resident soon.
If force is true, this method will never return NULL (unless the data is actually empty), but may block until the data is available.
Definition at line 67 of file vertexDataBuffer.I.
|
inline |
Returns the total number of bytes "reserved" in the buffer.
This may be greater than or equal to get_size(). If it is greater, the additional bytes are extra unused bytes in the buffer, and this indicates the maximum value that may be passed to set_size() without first calling one of the realloc methods.
Definition at line 121 of file vertexDataBuffer.I.
|
inline |
Returns the number of bytes in the buffer.
Definition at line 109 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_subdata_from().
|
inline |
Returns a writable pointer to the raw data.
Definition at line 92 of file vertexDataBuffer.I.
|
inline |
Moves the buffer out of independent memory and puts it on a page in the indicated book.
The buffer may still be directly accessible as long as its page remains resident. Any subsequent attempt to rewrite the buffer will implicitly move it off of the page and back into independent memory.
Definition at line 188 of file vertexDataBuffer.I.
|
inline |
Changes the size of the buffer.
The new size must be less than or equal to the "reserved" size, which can only be changed via clean_realloc() or unclean_realloc().
Definition at line 131 of file vertexDataBuffer.I.
void VertexDataBuffer::swap | ( | VertexDataBuffer & | other | ) |
Swaps the data buffers between this one and the other one.
Definition at line 49 of file vertexDataBuffer.cxx.
|
inline |
Changes the size of the buffer, without regard to preserving its data.
The buffer may contain random data after this call.
It is an error to set the reserved size smaller than the size specified with set_size().
Definition at line 166 of file vertexDataBuffer.I.