Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Friends

GeomVertexArrayData Class Reference

This is the data for one array of a GeomVertexData structure. More...

#include "geomVertexArrayData.h"

Inheritance diagram for GeomVertexArrayData:
CopyOnWriteObject SimpleLruPage GeomEnums CachedTypedWritableReferenceCount LinkedListNode TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

List of all members.

Classes

class  BamAuxData
class  CData

Public Member Functions

 GeomVertexArrayData (const GeomVertexArrayFormat *array_format, UsageHint usage_hint)
 GeomVertexArrayData (const GeomVertexArrayData &copy)
void clear_rows ()
 Removes all of the rows in the array.
int compare_to (const GeomVertexArrayData &other) const
 Returns 0 if the two arrays are equivalent, even if they are not the same pointer.
virtual int complete_pointers (TypedWritable **plist, BamReader *manager)
 Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
 CPT (GeomVertexArrayDataHandle) get_handle(Thread *current_thread
virtual void evict_lru ()
 Evicts the page from the LRU.
virtual void finalize (BamReader *manager)
 Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
virtual TypeHandle force_init_type ()
const GeomVertexArrayFormatget_array_format () const
 Returns the format object that describes this array.
int get_data_size_bytes () const
 Returns the number of bytes stored in the array.
UpdateSeq get_modified () const
 Returns a sequence number which is guaranteed to change at least every time the array vertex data is modified.
int get_num_rows () const
 Returns the number of rows stored in the array, based on the number of bytes and the stride.
virtual TypeHandle get_type () const
UsageHint get_usage_hint () const
 Returns the usage hint that describes to the rendering backend how often the vertex data will be modified and/or rendered.
bool has_column (const InternalName *name) const
 Returns true if the array has the named column, false otherwise.
bool is_prepared (PreparedGraphicsObjects *prepared_objects) const
 Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.
void operator= (const GeomVertexArrayData &copy)
 The copy assignment operator is not pipeline-safe.
void output (ostream &out) const
void prepare (PreparedGraphicsObjects *prepared_objects)
 Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.
VertexBufferContextprepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg)
 Creates a context for the data on the particular GSG, if it does not already exist.
 PT (GeomVertexArrayDataHandle) modify_handle(Thread *current_thread
PTA_uchar read_raw_data (BamReader *manager, DatagramIterator &source)
 Called by CData::fillin to read the raw data of the array from the indicated datagram.
bool release (PreparedGraphicsObjects *prepared_objects)
 Frees the data context only on the indicated object, if it exists there.
int release_all ()
 Frees the context allocated on all objects for which the data has been declared.
bool request_resident () const
 Returns true if the vertex data is currently resident in memory.
bool reserve_num_rows (int n)
 This ensures that enough memory space for n rows is allocated, so that you may increase the number of rows to n without causing a new memory allocation.
bool set_num_rows (int n)
 Sets the length of the array to n rows.
void set_usage_hint (UsageHint usage_hint)
 Changes the UsageHint hint for this array.
bool unclean_set_num_rows (int n)
 This method behaves like set_num_rows(), except the new data is not initialized.
void write (ostream &out, int indent_level=0) const
virtual void write_datagram (BamWriter *manager, Datagram &dg)
 Writes the contents of this object to the datagram for shipping out to a Bam file.

Static Public Member Functions

static VertexDataBookget_book ()
 Returns the global VertexDataBook that will be used to allocate vertex data buffers.
static TypeHandle get_class_type ()
static SimpleLruget_independent_lru ()
 Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that have not (yet) been paged out.
static SimpleLruget_small_lru ()
 Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that are deemed too small to be paged out.
static void init_type ()
static void lru_epoch ()
 Marks that an epoch has passed in each LRU.
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type GeomVertexArrayData.

Protected Member Functions

void fillin (DatagramIterator &scan, BamReader *manager)
 This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new GeomVertexArrayData.
virtual PT (CopyOnWriteObject) make_cow_copy()

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type GeomVertexArrayData is encountered in the Bam file.

Friends

class GeomCacheManager
class GeomVertexArrayDataHandle
class GeomVertexData
class PreparedGraphicsObjects

Detailed Description

This is the data for one array of a GeomVertexData structure.

Many GeomVertexData structures will only define one array, with all data elements interleaved (DirectX 8.0 and before insisted on this format); some will define multiple arrays.

DirectX calls this concept of one array a "stream". It also closely correlates with the concept of a vertex buffer.

This object is just a block of data. In general, you should not be directly messing with this object from application code. See GeomVertexData for the organizing structure, and see GeomVertexReader/Writer/Rewriter for high-level tools to manipulate the actual vertex data.

Definition at line 63 of file geomVertexArrayData.h.


Member Function Documentation

void GeomVertexArrayData::clear_rows ( ) [inline]

Removes all of the rows in the array.

Functionally equivalent to set_num_rows(0).

Definition at line 131 of file geomVertexArrayData.I.

int GeomVertexArrayData::compare_to ( const GeomVertexArrayData other) const

Returns 0 if the two arrays are equivalent, even if they are not the same pointer.

Definition at line 165 of file geomVertexArrayData.cxx.

References Thread::get_current_thread(), and get_usage_hint().

int GeomVertexArrayData::complete_pointers ( TypedWritable **  p_list,
BamReader manager 
) [virtual]

Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().

Returns the number of pointers processed.

Reimplemented from TypedWritable.

Definition at line 503 of file geomVertexArrayData.cxx.

void GeomVertexArrayData::evict_lru ( ) [virtual]

Evicts the page from the LRU.

Called internally when the LRU determines that it is full. May also be called externally when necessary to explicitly evict the page.

It is legal for this method to either evict the page as requested, do nothing (in which case the eviction will be requested again at the next epoch), or requeue itself on the tail of the queue (in which case the eviction will be requested again much later).

Reimplemented from SimpleLruPage.

Definition at line 381 of file geomVertexArrayData.cxx.

References SimpleLruPage::dequeue_lru().

void GeomVertexArrayData::fillin ( DatagramIterator scan,
BamReader manager 
) [protected, virtual]

This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new GeomVertexArrayData.

Reimplemented from TypedWritable.

Definition at line 577 of file geomVertexArrayData.cxx.

References BamReader::read_cdata(), and BamReader::read_pointer().

void GeomVertexArrayData::finalize ( BamReader manager) [virtual]

Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.

Reimplemented from TypedWritable.

Definition at line 519 of file geomVertexArrayData.cxx.

References BamReader::change_pointer(), and BamReader::get_aux_data().

const GeomVertexArrayFormat * GeomVertexArrayData::get_array_format ( ) const [inline]

Returns the format object that describes this array.

Definition at line 22 of file geomVertexArrayData.I.

VertexDataBook & GeomVertexArrayData::get_book ( ) [inline, static]

Returns the global VertexDataBook that will be used to allocate vertex data buffers.

Definition at line 237 of file geomVertexArrayData.I.

int GeomVertexArrayData::get_data_size_bytes ( ) const [inline]

Returns the number of bytes stored in the array.

Definition at line 141 of file geomVertexArrayData.I.

Referenced by PreparedGraphicsObjects::prepare_vertex_buffer_now(), PreparedGraphicsObjects::release_vertex_buffer(), and SceneGraphAnalyzer::write().

SimpleLru * GeomVertexArrayData::get_independent_lru ( ) [inline, static]

Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that have not (yet) been paged out.

Definition at line 214 of file geomVertexArrayData.I.

Referenced by GraphicsEngine::render_frame().

UpdateSeq GeomVertexArrayData::get_modified ( ) const [inline]

Returns a sequence number which is guaranteed to change at least every time the array vertex data is modified.

Definition at line 154 of file geomVertexArrayData.I.

int GeomVertexArrayData::get_num_rows ( ) const [inline]

Returns the number of rows stored in the array, based on the number of bytes and the stride.

This should be the same for all arrays within a given GeomVertexData object.

Definition at line 60 of file geomVertexArrayData.I.

Referenced by GeomTristrips::append_unused_vertices().

SimpleLru * GeomVertexArrayData::get_small_lru ( ) [inline, static]

Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that are deemed too small to be paged out.

Definition at line 226 of file geomVertexArrayData.I.

Referenced by GraphicsEngine::render_frame().

GeomVertexArrayData::UsageHint GeomVertexArrayData::get_usage_hint ( ) const [inline]

Returns the usage hint that describes to the rendering backend how often the vertex data will be modified and/or rendered.

See geomEnums.h.

Definition at line 34 of file geomVertexArrayData.I.

Referenced by compare_to(), GeomPrimitive::finalize(), PreparedGraphicsObjects::prepare_vertex_buffer_now(), and PreparedGraphicsObjects::release_vertex_buffer().

bool GeomVertexArrayData::has_column ( const InternalName name) const [inline]

Returns true if the array has the named column, false otherwise.

This is really just a shortcut for asking the same thing from the format.

Definition at line 47 of file geomVertexArrayData.I.

bool GeomVertexArrayData::is_prepared ( PreparedGraphicsObjects prepared_objects) const

Returns true if the data has already been prepared or enqueued for preparation on the indicated GSG, false otherwise.

Definition at line 247 of file geomVertexArrayData.cxx.

References PreparedGraphicsObjects::is_vertex_buffer_queued().

Referenced by PreparedGraphicsObjects::is_vertex_buffer_prepared().

void GeomVertexArrayData::lru_epoch ( ) [static]

Marks that an epoch has passed in each LRU.

Asks the LRU's to consider whether they should perform evictions.

Definition at line 359 of file geomVertexArrayData.cxx.

References SimpleLru::begin_epoch(), and VertexDataPage::get_global_lru().

Referenced by GraphicsEngine::render_frame().

TypedWritable * GeomVertexArrayData::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type GeomVertexArrayData is encountered in the Bam file.

It should create the GeomVertexArrayData and extract its information from the file.

Definition at line 557 of file geomVertexArrayData.cxx.

References BamReader::register_finalize().

Referenced by register_with_read_factory().

void GeomVertexArrayData::operator= ( const GeomVertexArrayData copy)

The copy assignment operator is not pipeline-safe.

This will completely obliterate all stages of the pipeline, so don't do it for a GeomVertexArrayData that is actively being used for rendering.

Definition at line 130 of file geomVertexArrayData.cxx.

References Geom::get_next_modified(), and SimpleLruPage::mark_used_lru().

void GeomVertexArrayData::prepare ( PreparedGraphicsObjects prepared_objects)

Indicates that the data should be enqueued to be prepared in the indicated prepared_objects at the beginning of the next frame.

This will ensure the data is already loaded into the GSG if it is expected to be rendered soon.

Use this function instead of prepare_now() to preload datas from a user interface standpoint.

Definition at line 235 of file geomVertexArrayData.cxx.

References PreparedGraphicsObjects::enqueue_vertex_buffer().

VertexBufferContext * GeomVertexArrayData::prepare_now ( PreparedGraphicsObjects prepared_objects,
GraphicsStateGuardianBase gsg 
)

Creates a context for the data on the particular GSG, if it does not already exist.

Returns the new (or old) VertexBufferContext. This assumes that the GraphicsStateGuardian is the currently active rendering context and that it is ready to accept new datas. If this is not necessarily the case, you should use prepare() instead.

Normally, this is not called directly except by the GraphicsStateGuardian; a data does not need to be explicitly prepared by the user before it may be rendered.

Definition at line 276 of file geomVertexArrayData.cxx.

References PreparedGraphicsObjects::prepare_vertex_buffer_now().

Referenced by PreparedGraphicsObjects::begin_frame().

PTA_uchar GeomVertexArrayData::read_raw_data ( BamReader manager,
DatagramIterator source 
)

Called by CData::fillin to read the raw data of the array from the indicated datagram.

Definition at line 484 of file geomVertexArrayData.cxx.

References DatagramIterator::get_current_index(), Datagram::get_data(), DatagramIterator::get_datagram(), DatagramIterator::get_uint32(), and DatagramIterator::skip_bytes().

void GeomVertexArrayData::register_with_read_factory ( ) [static]

Tells the BamReader how to create objects of type GeomVertexArrayData.

Definition at line 459 of file geomVertexArrayData.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

bool GeomVertexArrayData::release ( PreparedGraphicsObjects prepared_objects)

Frees the data context only on the indicated object, if it exists there.

Returns true if it was released, false if it had not been prepared.

Definition at line 302 of file geomVertexArrayData.cxx.

References PreparedGraphicsObjects::dequeue_vertex_buffer(), and PreparedGraphicsObjects::release_vertex_buffer().

int GeomVertexArrayData::release_all ( )

Frees the context allocated on all objects for which the data has been declared.

Returns the number of contexts which have been freed.

Definition at line 325 of file geomVertexArrayData.cxx.

References PreparedGraphicsObjects::release_vertex_buffer().

bool GeomVertexArrayData::request_resident ( ) const [inline]

Returns true if the vertex data is currently resident in memory.

If this returns true, the next call to get_handle()->get_read_pointer() will probably not block. If this returns false, the vertex data will be brought back into memory shortly; try again later.

Definition at line 169 of file geomVertexArrayData.I.

bool GeomVertexArrayData::reserve_num_rows ( int  n) [inline]

This ensures that enough memory space for n rows is allocated, so that you may increase the number of rows to n without causing a new memory allocation.

This is a performance optimization only; it is especially useful when you know ahead of time that you will be adding n rows to the data.

Definition at line 120 of file geomVertexArrayData.I.

bool GeomVertexArrayData::set_num_rows ( int  n) [inline]

Sets the length of the array to n rows.

Normally, you would not call this directly, since all of the arrays in a particular GeomVertexData must have the same number of rows; instead, call GeomVertexData::set_num_rows().

The return value is true if the number of rows was changed, false if the object already contained n rows (or if there was some error).

The new vertex data is initialized to 0, including the "color" column (but see GeomVertexData::set_num_rows()).

Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

Definition at line 87 of file geomVertexArrayData.I.

void GeomVertexArrayData::set_usage_hint ( GeomVertexArrayData::UsageHint  usage_hint)

Changes the UsageHint hint for this array.

See get_usage_hint().

Don't call this in a downstream thread unless you don't mind it blowing away other changes you might have recently made in an upstream thread.

Definition at line 196 of file geomVertexArrayData.cxx.

References Geom::get_next_modified().

bool GeomVertexArrayData::unclean_set_num_rows ( int  n) [inline]

This method behaves like set_num_rows(), except the new data is not initialized.

Furthermore, after this call, *any* of the data in the GeomVertexArrayData may be uninitialized, including the earlier rows.

Normally, you would not call this directly, since all of the arrays in a particular GeomVertexData must have the same number of rows; instead, call GeomVertexData::unclean_set_num_rows().

Definition at line 105 of file geomVertexArrayData.I.

void GeomVertexArrayData::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from TypedWritable.

Definition at line 470 of file geomVertexArrayData.cxx.

References BamWriter::write_cdata(), and BamWriter::write_pointer().


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