Panda3D
|
A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object. More...
#include "vertexDataBuffer.h"
Public Member Functions | |
VertexDataBuffer (const VertexDataBuffer ©) | |
VertexDataBuffer (size_t size) | |
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). | |
void | clear () |
Empties the buffer and sets its size to 0. | |
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. | |
size_t | get_reserved_size () const |
Returns the total number of bytes "reserved" in the buffer. | |
size_t | get_size () const |
Returns the number of bytes in the buffer. | |
unsigned char * | get_write_pointer () |
Returns a writable pointer to the raw data. | |
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. | |
void | set_size (size_t size) |
Changes the size of the buffer. | |
void | swap (VertexDataBuffer &other) |
Swaps the data buffers between this one and the other one. | |
void | unclean_realloc (size_t reserved_size) |
Changes the size of the buffer, without regard to preserving its data. | |
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 |
Definition at line 17 of file vertexDataBuffer.I.
|
inline |
Definition at line 28 of file vertexDataBuffer.I.
|
inline |
Definition at line 41 of file vertexDataBuffer.I.
|
inline |
Definition at line 53 of file vertexDataBuffer.I.
|
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 152 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().
|
inline |
Empties the buffer and sets its size to 0.
Definition at line 174 of file vertexDataBuffer.I.
|
inlinestatic |
Definition at line 88 of file vertexDataBuffer.h.
|
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 66 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_data_from(), GeomVertexArrayDataHandle::get_data(), GeomVertexArrayDataHandle::get_read_pointer(), GeomVertexArrayDataHandle::get_subdata(), and GeomVertexArrayData::request_resident().
|
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 120 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().
|
inline |
Returns the number of bytes in the buffer.
Definition at line 108 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_data_from(), GeomVertexArrayDataHandle::copy_subdata_from(), GeomVertexArrayDataHandle::copy_subdata_from(), GeomVertexArrayDataHandle::get_data(), GeomPrimitivePipelineReader::get_data_size_bytes(), GeomVertexArrayDataHandle::get_subdata(), and GeomVertexArrayDataHandle::set_subdata().
|
inline |
Returns a writable pointer to the raw data.
Definition at line 91 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), GeomVertexArrayData::finalize(), and GeomVertexArrayDataHandle::set_subdata().
|
inlinestatic |
Definition at line 91 of file vertexDataBuffer.h.
void VertexDataBuffer::operator= | ( | const VertexDataBuffer & | copy | ) |
Definition at line 23 of file vertexDataBuffer.cxx.
|
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 187 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 130 of file vertexDataBuffer.I.
Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().
void VertexDataBuffer::swap | ( | VertexDataBuffer & | other | ) |
Swaps the data buffers between this one and the other one.
Definition at line 48 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 165 of file vertexDataBuffer.I.