Panda3D
Public Member Functions | Static Public Member Functions

VertexDataBuffer Class Reference

A block of bytes that stores the actual raw vertex data referenced by a GeomVertexArrayData object. More...

#include "vertexDataBuffer.h"

List of all members.

Public Member Functions

 VertexDataBuffer (size_t size)
 VertexDataBuffer (const VertexDataBuffer &copy)
void clean_realloc (size_t size)
 Changes the 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_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 swap (VertexDataBuffer &other)
 Swaps the data buffers between this one and the other one.
void unclean_realloc (size_t 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).

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.

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 59 of file vertexDataBuffer.h.


Member Function Documentation

void VertexDataBuffer::clean_realloc ( size_t  size) [inline]

Changes the 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.

Definition at line 125 of file vertexDataBuffer.I.

Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().

void VertexDataBuffer::clear ( ) [inline]

Empties the buffer and sets its size to 0.

Definition at line 149 of file vertexDataBuffer.I.

References unclean_realloc().

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, but may block until the data is available.

Definition at line 76 of file vertexDataBuffer.I.

size_t VertexDataBuffer::get_size ( ) const [inline]

Returns the number of bytes in the buffer.

Definition at line 112 of file vertexDataBuffer.I.

Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().

unsigned char * VertexDataBuffer::get_write_pointer ( ) [inline]

Returns a writable pointer to the raw data.

Definition at line 97 of file vertexDataBuffer.I.

Referenced by GeomVertexArrayDataHandle::copy_subdata_from(), and GeomVertexArrayDataHandle::set_subdata().

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 164 of file vertexDataBuffer.I.

void VertexDataBuffer::swap ( VertexDataBuffer other) [inline]

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

Definition at line 176 of file vertexDataBuffer.I.

void VertexDataBuffer::unclean_realloc ( size_t  size) [inline]

Changes the size of the buffer, without regard to preserving its data.

The buffer may contain random data after this call.

Definition at line 138 of file vertexDataBuffer.I.

Referenced by clear().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations