Panda3D
|
This is the data for one array of a GeomVertexData structure. More...
#include "geomVertexArrayData.h"
Public Member Functions | |
GeomVertexArrayData (const GeomVertexArrayFormat *array_format, UsageHint usage_hint) | |
GeomVertexArrayData (const GeomVertexArrayData ©) | |
void | clear_rows () |
Removes all of the rows in the array. More... | |
int | compare_to (const GeomVertexArrayData &other) const |
Returns 0 if the two arrays are equivalent, even if they are not the same pointer. More... | |
virtual int | complete_pointers (TypedWritable **plist, BamReader *manager) |
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin(). More... | |
CPT (GeomVertexArrayDataHandle) get_handle(Thread *current_thread | |
virtual void | evict_lru () |
Evicts the page from the LRU. More... | |
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. More... | |
virtual TypeHandle | force_init_type () |
const GeomVertexArrayFormat * | get_array_format () const |
Returns the format object that describes this array. More... | |
int | get_data_size_bytes () const |
Returns the number of bytes stored in the array. More... | |
UpdateSeq | get_modified () const |
Returns a sequence number which is guaranteed to change at least every time the array vertex data is modified. More... | |
int | get_num_rows () const |
Returns the number of rows stored in the array, based on the number of bytes and the stride. More... | |
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. More... | |
bool | has_column (const InternalName *name) const |
Returns true if the array has the named column, false otherwise. More... | |
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. More... | |
void | operator= (const GeomVertexArrayData ©) |
The copy assignment operator is not pipeline-safe. More... | |
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. More... | |
VertexBufferContext * | prepare_now (PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) |
Creates a context for the data on the particular GSG, if it does not already exist. More... | |
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. More... | |
bool | release (PreparedGraphicsObjects *prepared_objects) |
Frees the data context only on the indicated object, if it exists there. More... | |
int | release_all () |
Frees the context allocated on all objects for which the data has been declared. More... | |
bool | request_resident () const |
Returns true if the vertex data is currently resident in memory. More... | |
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. More... | |
bool | set_num_rows (int n) |
Sets the length of the array to n rows. More... | |
void | set_usage_hint (UsageHint usage_hint) |
Changes the UsageHint hint for this array. More... | |
bool | unclean_set_num_rows (int n) |
This method behaves like set_num_rows(), except the new data is not initialized. More... | |
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. More... | |
![]() | |
CopyOnWriteObject (const CopyOnWriteObject ©) | |
void | operator= (const CopyOnWriteObject ©) |
![]() | |
void | cache_ref () const |
Explicitly increments the cache reference count and the normal reference count simultaneously. More... | |
bool | cache_unref () const |
Explicitly decrements the cache reference count and the normal reference count simultaneously. More... | |
int | get_cache_ref_count () const |
Returns the current reference count. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
![]() | |
TypedWritableReferenceCount (const TypedWritableReferenceCount ©) | |
virtual ReferenceCount * | as_reference_count () |
Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More... | |
void | operator= (const TypedWritableReferenceCount ©) |
![]() | |
TypedWritable (const TypedWritable ©) | |
string | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a string string. More... | |
bool | encode_to_bam_stream (string &data, BamWriter *writer=NULL) const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and stores that data in the indicated string. More... | |
UpdateSeq | get_bam_modified () const |
Returns the current bam_modified counter. More... | |
void | mark_bam_modified () |
Increments the bam_modified counter, so that this object will be invalidated and retransmitted on any open bam streams. More... | |
void | operator= (const TypedWritable ©) |
virtual bool | require_fully_complete () const |
Some objects require all of their nested pointers to have been completed before the objects themselves can be completed. More... | |
virtual void | update_bam_nested (BamWriter *manager) |
Called by the BamWriter when this object has not itself been modified recently, but it should check its nested objects for updates. More... | |
![]() | |
TypedObject (const TypedObject ©) | |
TypedObject * | as_typed_object () |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
const TypedObject * | as_typed_object () const |
Returns the object, upcast (if necessary) to a TypedObject pointer. More... | |
int | get_best_parent_from_Set (const std::set< int > &) const |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More... | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. More... | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. More... | |
void | operator= (const TypedObject ©) |
![]() | |
int | get_ref_count () const |
Returns the current reference count. More... | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. More... | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More... | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More... | |
void | ref () const |
Explicitly increments the reference count. More... | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More... | |
virtual bool | unref () const |
Explicitly decrements the reference count. More... | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
![]() | |
SimpleLruPage (size_t lru_size) | |
SimpleLruPage (const SimpleLruPage ©) | |
void | dequeue_lru () |
Removes the page from its SimpleLru. More... | |
void | enqueue_lru (SimpleLru *lru) |
Adds the page to the LRU for the first time, or marks it recently-accessed if it has already been added. More... | |
SimpleLru * | get_lru () const |
Returns the LRU that manages this page, or NULL if it is not currently managed by any LRU. More... | |
size_t | get_lru_size () const |
Returns the size of this page as reported to the LRU, presumably in bytes. More... | |
void | mark_used_lru () const |
To be called when the page is used; this will move it to the tail of the SimpleLru queue it is already on. More... | |
void | mark_used_lru (SimpleLru *lru) |
To be called when the page is used; this will move it to the tail of the specified SimpleLru queue. More... | |
void | operator= (const SimpleLruPage ©) |
void | set_lru_size (size_t lru_size) |
Specifies the size of this page, presumably in bytes, although any unit is possible. More... | |
Static Public Member Functions | |
static VertexDataBook & | get_book () |
Returns the global VertexDataBook that will be used to allocate vertex data buffers. More... | |
static TypeHandle | get_class_type () |
static SimpleLru * | get_independent_lru () |
Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that have not (yet) been paged out. More... | |
static SimpleLru * | get_small_lru () |
Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that are deemed too small to be paged out. More... | |
static void | init_type () |
static void | lru_epoch () |
Marks that an epoch has passed in each LRU. More... | |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type GeomVertexArrayData. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (TypedWritableReferenceCount) decode_from_bam_stream(const string &data |
![]() | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, const string &data, BamReader *reader=NULL) |
Reads the string created by a previous call to encode_to_bam_stream(), and extracts the single object on that string. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. More... | |
![]() | |
static TypeHandle | get_class_type () |
static void | init_type () |
Friends | |
class | GeomCacheManager |
class | GeomVertexArrayDataHandle |
class | GeomVertexData |
class | PreparedGraphicsObjects |
Additional Inherited Members | |
![]() | |
enum | AnimationType { AT_none, AT_panda, AT_hardware } |
enum | Contents { C_other, C_point, C_clip_point, C_vector, C_texcoord, C_color, C_index, C_morph_delta, C_matrix, C_normal } |
enum | GeomRendering { GR_indexed_point = 0x00001, GR_indexed_other = 0x10000, GR_indexed_bits = 0x10001, GR_point = 0x00002, GR_point_uniform_size = 0x00004, GR_per_point_size = 0x00008, GR_point_perspective = 0x00010, GR_point_aspect_ratio = 0x00020, GR_point_scale = 0x00040, GR_point_rotate = 0x00080, GR_point_sprite = 0x00100, GR_point_sprite_tex_matrix = 0x00200, GR_point_bits = 0x003fe, GR_triangle_strip = 0x00400, GR_triangle_fan = 0x00800, GR_line_strip = 0x01000, GR_composite_bits = 0x01c00, GR_strip_cut_index = 0x20000, GR_flat_first_vertex = 0x02000, GR_flat_last_vertex = 0x04000, GR_shade_model_bits = 0x06000 } |
enum | NumericType { NT_uint8, NT_uint16, NT_uint32, NT_packed_dcba, NT_packed_dabc, NT_float32, NT_float64, NT_stdfloat } |
enum | PrimitiveType { PT_none, PT_polygons, PT_lines, PT_points, PT_patches } |
enum | ShadeModel { SM_uniform, SM_smooth, SM_flat_first_vertex, SM_flat_last_vertex } |
enum | UsageHint { UH_client, UH_stream, UH_dynamic, UH_static, UH_unspecified } |
![]() | |
static BamReader * | reader = NULL) |
![]() | |
static TypedWritable *const | Null = (TypedWritable*)0L |
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.
|
inline |
Removes all of the rows in the array.
Functionally equivalent to set_num_rows(0).
Definition at line 131 of file geomVertexArrayData.I.
References get_data_size_bytes().
Referenced by reserve_num_rows().
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(), get_usage_hint(), and set_usage_hint().
Referenced by operator=().
|
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.
References TypedWritable::complete_pointers(), and finalize().
Referenced by read_raw_data().
|
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 GeomVertexColumn::get_component_bytes(), GeomVertexColumn::get_num_components(), GeomVertexColumn::get_start(), register_with_read_factory(), and ReversedNumericData::store_value().
Referenced by lru_epoch().
|
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 Datagram::add_uint32(), Datagram::add_uint8(), Datagram::append_data(), BamReader::change_pointer(), TypedWritable::fillin(), BamReader::get_aux_data(), DatagramIterator::get_current_index(), Datagram::get_data(), DatagramIterator::get_datagram(), BamWriter::get_file_endian(), BamReader::get_file_endian(), BamReader::get_file_minor_ver(), Geom::get_next_modified(), DatagramIterator::get_uint32(), DatagramIterator::get_uint8(), GeomVertexArrayDataHandle::get_write_pointer(), BamReader::read_cdata(), BamReader::read_pointer(), read_raw_data(), BamReader::register_finalize(), BamReader::set_aux_data(), and DatagramIterator::skip_bytes().
Referenced by complete_pointers().
|
inline |
Returns the format object that describes this array.
Definition at line 22 of file geomVertexArrayData.I.
References get_usage_hint().
Referenced by DXGraphicsStateGuardian9::prepare_vertex_buffer(), and GeomPrimitive::set_vertices().
|
inlinestatic |
Returns the global VertexDataBook that will be used to allocate vertex data buffers.
Definition at line 237 of file geomVertexArrayData.I.
References GeomVertexArrayDataHandle::get_read_pointer(), SimpleLruPage::mark_used_lru(), and SimpleLruPage::set_lru_size().
Referenced by get_small_lru().
|
inline |
Returns the number of bytes stored in the array.
Definition at line 141 of file geomVertexArrayData.I.
References get_modified().
Referenced by clear_rows(), GeomVertexArrayDataHandle::get_read_pointer(), DXGraphicsStateGuardian9::prepare_vertex_buffer(), PreparedGraphicsObjects::prepare_vertex_buffer_now(), PreparedGraphicsObjects::release_vertex_buffer(), and SceneGraphAnalyzer::write().
|
inlinestatic |
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.
References get_small_lru().
Referenced by GraphicsEngine::render_frame(), and request_resident().
|
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.
References request_resident().
Referenced by get_data_size_bytes().
|
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.
References set_num_rows().
Referenced by GeomPrimitive::calc_sphere_radius(), has_column(), and DXGraphicsStateGuardian9::prepare_vertex_buffer().
|
inlinestatic |
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.
References get_book().
Referenced by get_independent_lru(), and GraphicsEngine::render_frame().
|
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.
References has_column().
Referenced by compare_to(), GeomPrimitive::finalize(), get_array_format(), PreparedGraphicsObjects::prepare_vertex_buffer_now(), and PreparedGraphicsObjects::release_vertex_buffer().
|
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.
References get_num_rows().
Referenced by get_usage_hint().
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(), and prepare_now().
Referenced by PreparedGraphicsObjects::is_vertex_buffer_prepared(), and prepare().
|
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(), evict_lru(), and VertexDataPage::get_global_lru().
Referenced by release_all(), and GraphicsEngine::render_frame().
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 compare_to(), 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(), and is_prepared().
Referenced by set_usage_hint().
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(), and release().
Referenced by PreparedGraphicsObjects::begin_frame(), and is_prepared().
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 complete_pointers(), DatagramIterator::get_current_index(), Datagram::get_data(), DatagramIterator::get_datagram(), DatagramIterator::get_uint32(), and DatagramIterator::skip_bytes().
Referenced by finalize(), and write_datagram().
|
static |
Tells the BamReader how to create objects of type GeomVertexArrayData.
Definition at line 459 of file geomVertexArrayData.cxx.
References BamReader::get_factory(), Factory< Type >::register_factory(), and write_datagram().
Referenced by evict_lru().
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(), release_all(), and PreparedGraphicsObjects::release_vertex_buffer().
Referenced by prepare_now().
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 lru_epoch(), and PreparedGraphicsObjects::release_vertex_buffer().
Referenced by release().
|
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.
References get_independent_lru(), PipelineCycler< CycleDataType >::read_unlocked(), and PipelineCycler< CycleDataType >::write_upstream().
Referenced by get_modified().
|
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.
References clear_rows().
Referenced by unclean_set_num_rows().
|
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.
References unclean_set_num_rows().
Referenced by get_num_rows(), GeomVertexArrayDataHandle::get_read_pointer(), and GeomVertexData::transform_vertices().
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(), and prepare().
Referenced by compare_to().
|
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.
References reserve_num_rows().
Referenced by GeomPrimitive::calc_sphere_radius(), and set_num_rows().
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 read_raw_data(), BamWriter::write_cdata(), TypedWritable::write_datagram(), and BamWriter::write_pointer().
Referenced by register_with_read_factory().