Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
VertexDataBuffer Class Reference

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 &copy)
 
 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 &copy)
 
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 ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VertexDataBuffer() [1/3]

VertexDataBuffer::VertexDataBuffer ( )
inline

Definition at line 17 of file vertexDataBuffer.I.

◆ VertexDataBuffer() [2/3]

VertexDataBuffer::VertexDataBuffer ( size_t size)
inline

Definition at line 28 of file vertexDataBuffer.I.

◆ VertexDataBuffer() [3/3]

VertexDataBuffer::VertexDataBuffer ( const VertexDataBuffer & copy)
inline

Definition at line 41 of file vertexDataBuffer.I.

◆ ~VertexDataBuffer()

VertexDataBuffer::~VertexDataBuffer ( )
inline

Definition at line 53 of file vertexDataBuffer.I.

Member Function Documentation

◆ clean_realloc()

void VertexDataBuffer::clean_realloc ( size_t reserved_size)
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().

◆ clear()

void VertexDataBuffer::clear ( )
inline

Empties the buffer and sets its size to 0.

Definition at line 174 of file vertexDataBuffer.I.

◆ get_class_type()

static TypeHandle VertexDataBuffer::get_class_type ( )
inlinestatic

Definition at line 88 of file vertexDataBuffer.h.

◆ get_read_pointer()

const unsigned char * VertexDataBuffer::get_read_pointer ( bool force) const
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().

◆ get_reserved_size()

size_t VertexDataBuffer::get_reserved_size ( ) const
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().

◆ get_size()

size_t VertexDataBuffer::get_size ( ) const
inline

◆ get_write_pointer()

unsigned char * VertexDataBuffer::get_write_pointer ( )
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().

◆ init_type()

static void VertexDataBuffer::init_type ( )
inlinestatic

Definition at line 91 of file vertexDataBuffer.h.

◆ operator=()

void VertexDataBuffer::operator= ( const VertexDataBuffer & copy)

Definition at line 23 of file vertexDataBuffer.cxx.

◆ page_out()

void VertexDataBuffer::page_out ( VertexDataBook & book)
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.

◆ set_size()

void VertexDataBuffer::set_size ( size_t size)
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().

◆ swap()

void VertexDataBuffer::swap ( VertexDataBuffer & other)

Swaps the data buffers between this one and the other one.

Definition at line 48 of file vertexDataBuffer.cxx.

◆ unclean_realloc()

void VertexDataBuffer::unclean_realloc ( size_t reserved_size)
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.


The documentation for this class was generated from the following files: