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 |
size_t | get_data_size_bytes () const |
UpdateSeq | get_modified () const |
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 |
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 (std::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 (Thread *current_thread=Thread::get_current_thread()) 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) |
bool | unclean_set_num_rows (int n) |
This method behaves like set_num_rows(), except the new data is not initialized. More... | |
void | write (std::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... | |
Public Member Functions inherited from CopyOnWriteObject | |
CopyOnWriteObject (const CopyOnWriteObject ©) | |
void | operator= (const CopyOnWriteObject ©) |
Public Member Functions inherited from CachedTypedWritableReferenceCount | |
void | cache_ref () const |
Explicitly increments the cache reference count and the normal reference count simultaneously. More... | |
void | cache_ref_only () const |
Decrements the cache reference count without affecting the normal reference count. More... | |
bool | cache_unref () const |
Explicitly decrements the cache reference count and the normal reference count simultaneously. More... | |
int | get_cache_ref_count () const |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. More... | |
Public Member Functions inherited from TypedWritableReferenceCount | |
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 ©) |
Public Member Functions inherited from TypedWritable | |
TypedWritable (const TypedWritable ©) | |
vector_uchar | encode_to_bam_stream () const |
Converts the TypedWritable object into a single stream of data using a BamWriter, and returns that data as a bytes object. More... | |
bool | encode_to_bam_stream (vector_uchar &data, BamWriter *writer=nullptr) 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... | |
Public Member Functions inherited from TypedObject | |
TypedObject (const TypedObject ©)=default | |
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... | |
TypedObject & | operator= (const TypedObject ©)=default |
Public Member Functions inherited from ReferenceCount | |
int | get_ref_count () const |
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 | ref_if_nonzero () const |
Atomically increases the reference count of this object if it is not zero. 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... | |
WeakReferenceList * | weak_ref () |
Adds the indicated PointerToVoid as a weak reference to this object. More... | |
void | weak_unref () |
Removes the indicated PointerToVoid as a weak reference to this object. More... | |
Public Member Functions inherited from SimpleLruPage | |
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 Public Member Functions inherited from CopyOnWriteObject | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from CachedTypedWritableReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedWritableReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
static | PT (TypedWritableReferenceCount) decode_from_bam_stream(vector_uchar data |
Static Public Member Functions inherited from TypedWritable | |
static bool | decode_raw_from_bam_stream (TypedWritable *&ptr, ReferenceCount *&ref_ptr, vector_uchar data, BamReader *reader=nullptr) |
Reads the bytes created by a previous call to encode_to_bam_stream(), and extracts the single object on those bytes. More... | |
static TypeHandle | get_class_type () |
static void | init_type () |
Static Public Member Functions inherited from TypedObject | |
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 Public Member Functions inherited from ReferenceCount | |
static TypeHandle | get_class_type () |
static void | init_type () |
Public Attributes | |
get_array_format | |
Returns the format object that describes this array. More... | |
get_data_size_bytes | |
Returns the number of bytes stored in the array. More... | |
get_modified | |
Returns a sequence number which is guaranteed to change at least every time the array vertex data is modified. More... | |
get_usage_hint | |
Returns the usage hint that describes to the rendering backend how often the vertex data will be modified and/or rendered. More... | |
set_usage_hint | |
Changes the UsageHint hint for this array. More... | |
Public Attributes inherited from CachedTypedWritableReferenceCount | |
get_cache_ref_count | |
Returns the current reference count. More... | |
Public Attributes inherited from TypedWritableReferenceCount | |
static BamReader * | reader = nullptr) |
Public Attributes inherited from TypedObject | |
get_type | |
Public Attributes inherited from ReferenceCount | |
get_ref_count | |
Returns the current reference count. More... | |
Friends | |
class | GeomCacheManager |
class | GeomPrimitivePipelineReader |
class | GeomVertexArrayDataHandle |
class | GeomVertexData |
class | PreparedGraphicsObjects |
Additional Inherited Members | |
Public Types inherited from GeomEnums | |
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, GR_render_mode_wireframe = 0x40000, GR_render_mode_point = 0x80000, GR_adjacency = 0x100000 } |
enum | NumericType { NT_uint8, NT_uint16, NT_uint32, NT_packed_dcba, NT_packed_dabc, NT_float32, NT_float64, NT_stdfloat, NT_int8, NT_int16, NT_int32, NT_packed_ufloat } |
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 Public Attributes inherited from TypedWritable | |
static TypedWritable *const | Null = nullptr |
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 58 of file geomVertexArrayData.h.
|
inline |
Removes all of the rows in the array.
Functionally equivalent to set_num_rows(0).
Definition at line 105 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 145 of file geomVertexArrayData.cxx.
References get_usage_hint.
|
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 432 of file geomVertexArrayData.cxx.
|
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 327 of file geomVertexArrayData.cxx.
References SimpleLruPage::dequeue_lru().
|
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 446 of file geomVertexArrayData.cxx.
References BamReader::change_pointer(), and BamReader::get_aux_data().
|
inlinestatic |
Returns the global VertexDataBook that will be used to allocate vertex data buffers.
Definition at line 201 of file geomVertexArrayData.I.
|
inlinestatic |
Returns a pointer to the global LRU object that manages the GeomVertexArrayData's that have not (yet) been paged out.
Definition at line 183 of file geomVertexArrayData.I.
|
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 47 of file geomVertexArrayData.I.
|
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 192 of file geomVertexArrayData.I.
|
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 37 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 212 of file geomVertexArrayData.cxx.
References PreparedGraphicsObjects::is_vertex_buffer_queued().
|
static |
Marks that an epoch has passed in each LRU.
Asks the LRU's to consider whether they should perform evictions.
Definition at line 310 of file geomVertexArrayData.cxx.
References SimpleLru::begin_epoch(), and VertexDataPage::get_global_lru().
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 114 of file geomVertexArrayData.cxx.
References 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 203 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 236 of file geomVertexArrayData.cxx.
References PreparedGraphicsObjects::prepare_vertex_buffer_now().
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 416 of file geomVertexArrayData.cxx.
References DatagramIterator::get_uint32().
|
static |
Tells the BamReader how to create objects of type GeomVertexArrayData.
Definition at line 395 of file geomVertexArrayData.cxx.
References BamReader::get_factory(), 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 259 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 279 of file geomVertexArrayData.cxx.
References PreparedGraphicsObjects::release_vertex_buffer().
|
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 135 of file geomVertexArrayData.I.
References PipelineCycler< CycleDataType >::read_unlocked(), and unref_delete().
|
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 96 of file geomVertexArrayData.I.
|
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 70 of file geomVertexArrayData.I.
|
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 84 of file geomVertexArrayData.I.
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from TypedWritable.
Definition at line 404 of file geomVertexArrayData.cxx.
References BamWriter::write_cdata(), TypedWritable::write_datagram(), and BamWriter::write_pointer().
|
inline |
Returns the format object that describes this array.
Definition at line 76 of file geomVertexArrayData.h.
Referenced by GeomPrimitive::set_vertices().
|
inline |
Returns the number of bytes stored in the array.
Definition at line 92 of file geomVertexArrayData.h.
Referenced by PreparedGraphicsObjects::release_vertex_buffer().
|
inline |
Returns a sequence number which is guaranteed to change at least every time the array vertex data is modified.
Definition at line 93 of file geomVertexArrayData.h.
|
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 80 of file geomVertexArrayData.h.
Referenced by compare_to(), GeomPrimitive::finalize(), and PreparedGraphicsObjects::release_vertex_buffer().
void GeomVertexArrayData::set_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 80 of file geomVertexArrayData.h.