Panda3D
 All Classes Functions Variables Enumerations
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
RenderState Class Reference

This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state. More...

#include "renderState.h"

Inheritance diagram for RenderState:
NodeCachedReferenceCount CachedTypedWritableReferenceCount TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase

Public Types

typedef
RenderAttribRegistry::SlotMask 
SlotMask
 
- Public Types inherited from NodeCachedReferenceCount
enum  Referenced { R_node = 0x001, R_cache = 0x002 }
 

Public Member Functions

virtual ~RenderState ()
 The destructor is responsible for removing the RenderState from the global set if it is there. More...
 
void cache_ref () const
 
bool cache_unref () const
 Overrides this method to update PStats appropriately. More...
 
int compare_mask (const RenderState &other, SlotMask compare_mask) const
 This version of compare_to takes a slot mask that indicates which attributes to include in the comparison. More...
 
int compare_sort (const RenderState &other) const
 Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rendering performance, so that "heavier" RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are more likely to be grouped together. More...
 
int compare_to (const RenderState &other) const
 Provides an arbitrary ordering among all unique RenderStates, so we can store the essentially different ones in a big set and throw away the rest. 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 (RenderState) compose(const RenderState *other) const
 
 CPT (RenderState) invert_compose(const RenderState *other) const
 
 CPT (RenderState) add_attrib(const RenderAttrib *attrib
 
 CPT (RenderState) set_attrib(const RenderAttrib *attrib) const
 
 CPT (RenderState) set_attrib(const RenderAttrib *attrib
 
 CPT (RenderState) remove_attrib(TypeHandle type) const
 
 CPT (RenderState) remove_attrib(int slot) const
 
 CPT (RenderState) adjust_all_priorities(int adjustment) const
 
 CPT (RenderState) get_unique() const
 
 CPT (RenderAttrib) _generated_shader
 
bool cull_callback (CullTraverser *trav, const CullTraverserData &data) const
 Calls cull_callback() on each attrib. 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 RenderAttribget_attrib (TypeHandle type) const
 Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not. More...
 
const RenderAttribget_attrib (int slot) const
 Returns the RenderAttrib with the indicated slot index, or NULL if there is no such RenderAttrib in the state. More...
 
template<class AttribType >
bool get_attrib (const AttribType *&attrib) const
 Handy templated version of get_attrib that costs to the right type. More...
 
const RenderAttribget_attrib_def (int slot) const
 Returns the RenderAttrib with the indicated slot index, or the default attrib for that slot if there is no such RenderAttrib in the state. More...
 
template<class AttribType >
void get_attrib_def (const AttribType *&attrib) const
 Handy templated version of get_attrib_def that costs to the right type. More...
 
const RenderStateget_auto_shader_state () const
 Returns the base RenderState that should have the generated_shader stored within it, for generated shader states. More...
 
int get_bin_index () const
 Returns the bin index indicated by the CullBinAttrib, if any, associated by this state (or the default bin index if there is no CullBinAttrib). More...
 
int get_composition_cache_num_entries () const
 Returns the number of entries in the composition cache for this RenderState. More...
 
const RenderStateget_composition_cache_result (int n) const
 Returns the result RenderState of the nth element in the composition cache. More...
 
int get_composition_cache_size () const
 Returns the number of slots in the composition cache for this RenderState. More...
 
const RenderStateget_composition_cache_source (int n) const
 Returns the source RenderState of the nth element in the composition cache. More...
 
int get_draw_order () const
 Returns the draw order indicated by the CullBinAttrib, if any, associated by this state (or 0 if there is no CullBinAttrib). More...
 
int get_geom_rendering (int geom_rendering) const
 Returns the union of the Geom::GeomRendering bits that will be required once this RenderState is applied to a geom which includes the indicated geom_rendering bits. More...
 
size_t get_hash () const
 Returns a suitable hash value for phash_map. More...
 
int get_invert_composition_cache_num_entries () const
 Returns the number of entries in the invert_composition cache for this RenderState. More...
 
const RenderStateget_invert_composition_cache_result (int n) const
 Returns the result RenderState of the nth element in the invert composition cache. More...
 
int get_invert_composition_cache_size () const
 Returns the number of slots in the composition cache for this RenderState. More...
 
const RenderStateget_invert_composition_cache_source (int n) const
 Returns the source RenderState of the nth element in the invert composition cache. More...
 
int get_override (TypeHandle type) const
 Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not. More...
 
int get_override (int slot) const
 Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not. More...
 
virtual TypeHandle get_type () const
 
bool has_attrib (TypeHandle type) const
 Returns true if an attrib of the indicated type is present, false otherwise. More...
 
bool has_attrib (int slot) const
 Returns true if an attrib of the indicated type is present, false otherwise. More...
 
bool has_cull_callback () const
 Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do. More...
 
bool is_empty () const
 Returns true if the state is empty, false otherwise. More...
 
void node_ref () const
 Overrides this method to update PStats appropriately. More...
 
bool node_unref () const
 Overrides this method to update PStats appropriately. More...
 
void output (ostream &out) const
 
virtual bool unref () const
 This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object. More...
 
void write (ostream &out, int indent_level) 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 NodeCachedReferenceCount
int get_node_ref_count () const
 Returns the current reference count. More...
 
int get_referenced_bits () const
 Returns the union of the values defined in the Referenced enum that represents the various things that appear to be holding a pointer to this object. More...
 
void node_ref () const
 Explicitly increments the reference count. More...
 
bool node_unref () const
 Explicitly decrements the node reference count and the normal reference count simultaneously. More...
 
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 CachedTypedWritableReferenceCount
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...
 
- Public Member Functions inherited from TypedWritableReferenceCount
 TypedWritableReferenceCount (const TypedWritableReferenceCount &copy)
 
virtual ReferenceCountas_reference_count ()
 Returns the pointer cast to a ReferenceCount pointer, if it is in fact of that type. More...
 
void operator= (const TypedWritableReferenceCount &copy)
 
- Public Member Functions inherited from TypedWritable
 TypedWritable (const TypedWritable &copy)
 
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 &copy)
 
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 &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_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 &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_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...
 
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...
 

Static Public Member Functions

static void bin_removed (int bin_index)
 Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached. More...
 
static TypedWritablechange_this (TypedWritable *old_ptr, BamReader *manager)
 Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired. More...
 
static int clear_cache ()
 Empties the cache of composed RenderStates. More...
 
static void clear_munger_cache ()
 Completely empties the cache of state + gsg -> munger, for all states and all gsg's. More...
 
static CPT (RenderState) make_empty()
 
static CPT (RenderState) make_full_default()
 
static CPT (RenderState) make(const RenderAttrib *attrib
 
static CPT (RenderState) make(const RenderAttrib *attrib1
 
static CPT (RenderState) make(const RenderAttrib *attrib1
 
static CPT (RenderState) make(const RenderAttrib *attrib1
 
static CPT (RenderState) make(const RenderAttrib *attrib1
 
static CPT (RenderState) make(const RenderAttrib *const *attrib
 
static void flush_level ()
 Flushes the PStatCollectors used during traversal. More...
 
static int garbage_collect ()
 Performs a garbage-collection cycle. More...
 
static TypeHandle get_class_type ()
 
static int get_max_priority ()
 Returns the maximum priority number (sometimes called override) that may be set on any node. More...
 
static int get_num_states ()
 Returns the total number of unique RenderState objects allocated in the world. More...
 
static int get_num_unused_states ()
 Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState cache. More...
 
static void init_states ()
 Make sure the global _states map is allocated. More...
 
static void init_type ()
 
static void list_cycles (ostream &out)
 Detects all of the reference-count cycles in the cache and reports them to standard output. More...
 
static void list_states (ostream &out)
 Lists all of the RenderStates in the cache to the output stream, one per line. More...
 
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type RenderState. More...
 
static bool validate_states ()
 Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted. More...
 
- Static Public Member Functions inherited from NodeCachedReferenceCount
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(const string &data
 
- Static Public Member Functions inherited from TypedWritable
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 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

static const RenderAttribattrib2
 
static const RenderAttrib
const RenderAttrib
attrib3
 
static const RenderAttrib
const RenderAttrib const
RenderAttrib
attrib4
 
static const RenderAttrib
const RenderAttrib const
RenderAttrib const
RenderAttrib
attrib5
 
int override const
 
static int num_attribs
 
static int override = 0)
 
static const RenderAttrib int override = 0)
 
static const RenderAttrib
const RenderAttrib int 
override = 0)
 
static const RenderAttrib
const RenderAttrib const
RenderAttrib int 
override = 0)
 
static const RenderAttrib
const RenderAttrib const
RenderAttrib const
RenderAttrib int 
override = 0)
 
static int int override = 0)
 
int override = 0) const
 
- Public Attributes inherited from TypedWritableReferenceCount
static BamReaderreader = NULL)
 

Friends

class Extension< RenderState >
 
class GraphicsStateGuardian
 
class RenderAttribRegistry
 

Additional Inherited Members

- Static Public Attributes inherited from TypedWritable
static TypedWritable *const Null = (TypedWritable*)0L
 

Detailed Description

This represents a unique collection of RenderAttrib objects that correspond to a particular renderable state.

You should not attempt to create or modify a RenderState object directly. Instead, call one of the make() functions to create one for you. And instead of modifying a RenderState object, create a new one.

Definition at line 53 of file renderState.h.

Constructor & Destructor Documentation

RenderState::~RenderState ( )
virtual

Member Function Documentation

void RenderState::bin_removed ( int  bin_index)
static

Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world to remove the indicated bin_index from their cache if it has been cached.

Definition at line 1368 of file renderState.cxx.

Referenced by CullBinManager::remove_bin().

bool RenderState::cache_unref ( ) const
inline

Overrides this method to update PStats appropriately.

Definition at line 230 of file renderState.I.

References NodeCachedReferenceCount::get_referenced_bits().

Referenced by clear_cache(), and garbage_collect().

TypedWritable * RenderState::change_this ( TypedWritable old_ptr,
BamReader manager 
)
static

Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointer if desired.

Most objects don't change pointers after completion, but some need to.

Once this function has been called, the old pointer will no longer be accessed.

Definition at line 2279 of file renderState.cxx.

References BamReader::register_finalize().

int RenderState::clear_cache ( )
static

Empties the cache of composed RenderStates.

This makes every RenderState forget what results when it is composed with other RenderStates.

This will eliminate any RenderState objects that have been allocated but have no references outside of the internal RenderState map. It will not eliminate RenderState objects that are still in use.

Nowadays, this method should not be necessary, as reference-count cycles in the composition cache should be automatically detected and broken.

The return value is the number of RenderStates freed by this operation.

Definition at line 975 of file renderState.cxx.

References cache_unref(), SimpleHashMap< Key, Value, Compare >::clear(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

void RenderState::clear_munger_cache ( )
static

Completely empties the cache of state + gsg -> munger, for all states and all gsg's.

Normally there is no need to empty this cache.

Definition at line 1128 of file renderState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

int RenderState::compare_mask ( const RenderState other,
SlotMask  compare_mask 
) const

This version of compare_to takes a slot mask that indicates which attributes to include in the comparison.

Unlike compare_to, this method compares the attributes by pointer.

Definition at line 242 of file renderState.cxx.

References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().

int RenderState::compare_sort ( const RenderState other) const

Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rendering performance, so that "heavier" RenderAttribs (as defined by RenderAttribRegistry::get_slot_sort()) are more likely to be grouped together.

This is not related to the sorting order defined by compare_to.

Definition at line 211 of file renderState.cxx.

References BitMask< WType, nbits >::get_bit(), RenderAttribRegistry::get_num_sorted_slots(), RenderAttribRegistry::get_sorted_slot(), and RenderAttribRegistry::quick_get_global_ptr().

int RenderState::compare_to ( const RenderState other) const

Provides an arbitrary ordering among all unique RenderStates, so we can store the essentially different ones in a big set and throw away the rest.

This method is not needed outside of the RenderState class because all equivalent RenderState objects are guaranteed to share the same pointer; thus, a pointer comparison is always sufficient.

Definition at line 185 of file renderState.cxx.

References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().

Referenced by validate_states().

int RenderState::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 2241 of file renderState.cxx.

References TypedWritable::complete_pointers(), RenderAttribRegistry::quick_get_global_ptr(), and BitMask< WType, nbits >::set_bit().

bool RenderState::cull_callback ( CullTraverser trav,
const CullTraverserData data 
) const

Calls cull_callback() on each attrib.

If any attrib returns false, interrupts the list and returns false immediately; otherwise, completes the list and returns true.

Definition at line 267 of file renderState.cxx.

References BitMask< WType, nbits >::clear_bit(), and BitMask< WType, nbits >::get_lowest_on_bit().

void RenderState::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 2307 of file renderState.cxx.

References ReferenceCount::get_ref_count(), and unref().

void RenderState::flush_level ( )
inlinestatic

Flushes the PStatCollectors used during traversal.

Definition at line 622 of file renderState.I.

Referenced by GraphicsEngine::render_frame().

int RenderState::garbage_collect ( )
static

Performs a garbage-collection cycle.

This must be called periodically if garbage-collect-states is true to ensure that RenderStates get cleaned up appropriately. It does no harm to call it even if this variable is not true, but there is probably no advantage in that case.

This automatically calls RenderAttrib::garbage_collect() as well.

Definition at line 1060 of file renderState.cxx.

References cache_unref(), RenderAttrib::garbage_collect(), CachedTypedWritableReferenceCount::get_cache_ref_count(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), SimpleHashMap< Key, Value, Compare >::has_element(), and SimpleHashMap< Key, Value, Compare >::validate().

Referenced by PandaFramework::task_garbage_collect().

const RenderAttrib * RenderState::get_attrib ( TypeHandle  type) const
inline

Looks for a RenderAttrib of the indicated type in the state, and returns it if it is found, or NULL if it is not.

Definition at line 134 of file renderState.I.

References RenderAttribRegistry::get_slot().

Referenced by CullResult::add_object(), CullTraverserData::apply_transform_and_state(), SpeedTreeNode::cull_callback(), get_attrib(), get_geom_rendering(), has_attrib(), and StandardMunger::StandardMunger().

const RenderAttrib * RenderState::get_attrib ( int  slot) const
inline

Returns the RenderAttrib with the indicated slot index, or NULL if there is no such RenderAttrib in the state.

Definition at line 148 of file renderState.I.

template<class AttribType >
bool RenderState::get_attrib ( const AttribType *&  attrib) const
inline

Handy templated version of get_attrib that costs to the right type.

Returns true if the attribute was present, false otherwise.

Definition at line 637 of file renderState.I.

References get_attrib().

const RenderAttrib * RenderState::get_attrib_def ( int  slot) const
inline

Returns the RenderAttrib with the indicated slot index, or the default attrib for that slot if there is no such RenderAttrib in the state.

Definition at line 160 of file renderState.I.

Referenced by get_attrib_def(), and StandardMunger::StandardMunger().

template<class AttribType >
void RenderState::get_attrib_def ( const AttribType *&  attrib) const
inline

Handy templated version of get_attrib_def that costs to the right type.

Definition at line 650 of file renderState.I.

References get_attrib_def().

const RenderState * RenderState::get_auto_shader_state ( ) const

Returns the base RenderState that should have the generated_shader stored within it, for generated shader states.

The returned object might be the same as this object, or it might be a different RenderState with certain attributes removed, or set to their default values.

The point is to avoid needless regeneration of the shader attrib by storing the generated shader on a common RenderState object, with all irrelevant attributes removed.

Definition at line 766 of file renderState.cxx.

int RenderState::get_bin_index ( ) const
inline

Returns the bin index indicated by the CullBinAttrib, if any, associated by this state (or the default bin index if there is no CullBinAttrib).

This function is provided as an optimization for determining this at render time.

Definition at line 454 of file renderState.I.

int RenderState::get_composition_cache_num_entries ( ) const
inline

Returns the number of entries in the composition cache for this RenderState.

This is the number of other RenderStates whose composition with this one has been cached. This number is not useful for any practical reason other than performance analysis.

Definition at line 284 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

const RenderState * RenderState::get_composition_cache_result ( int  n) const
inline

Returns the result RenderState of the nth element in the composition cache.

Returns NULL if there doesn't happen to be an entry in the nth element.

In general, a->compose(a->get_composition_cache_source(n)) == a->get_composition_cache_result(n).

This has no practical value other than for examining the cache for performance analysis.

Definition at line 357 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_data(), and SimpleHashMap< Key, Value, Compare >::has_element().

int RenderState::get_composition_cache_size ( ) const
inline

Returns the number of slots in the composition cache for this RenderState.

You may use this as an upper bound when walking through all of the composition cache results via get_composition_cache_source() or result().

This has no practical value other than for examining the cache for performance analysis.

Definition at line 317 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_size().

const RenderState * RenderState::get_composition_cache_source ( int  n) const
inline

Returns the source RenderState of the nth element in the composition cache.

Returns NULL if there doesn't happen to be an entry in the nth element. See get_composition_cache_result().

This has no practical value other than for examining the cache for performance analysis.

Definition at line 334 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_key(), and SimpleHashMap< Key, Value, Compare >::has_element().

int RenderState::get_draw_order ( ) const
inline

Returns the draw order indicated by the CullBinAttrib, if any, associated by this state (or 0 if there is no CullBinAttrib).

See get_bin_index().

Definition at line 435 of file renderState.I.

int RenderState::get_geom_rendering ( int  geom_rendering) const

Returns the union of the Geom::GeomRendering bits that will be required once this RenderState is applied to a geom which includes the indicated geom_rendering bits.

Definition at line 1341 of file renderState.cxx.

References get_attrib(), TexMatrixAttrib::get_geom_rendering(), TexGenAttrib::get_geom_rendering(), and RenderModeAttrib::get_geom_rendering().

size_t RenderState::get_hash ( ) const
inline

Returns a suitable hash value for phash_map.

Definition at line 22 of file renderState.I.

int RenderState::get_invert_composition_cache_num_entries ( ) const
inline

Returns the number of entries in the invert_composition cache for this RenderState.

This is similar to the composition cache, but it records cache entries for the invert_compose() operation. See get_composition_cache_num_entries().

Definition at line 299 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

const RenderState * RenderState::get_invert_composition_cache_result ( int  n) const
inline

Returns the result RenderState of the nth element in the invert composition cache.

Returns NULL if there doesn't happen to be an entry in the nth element.

In general, a->invert_compose(a->get_invert_composition_cache_source(n)) == a->get_invert_composition_cache_result(n).

This has no practical value other than for examining the cache for performance analysis.

Definition at line 419 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_data(), and SimpleHashMap< Key, Value, Compare >::has_element().

int RenderState::get_invert_composition_cache_size ( ) const
inline

Returns the number of slots in the composition cache for this RenderState.

You may use this as an upper bound when walking through all of the composition cache results via get_invert_composition_cache_source() or result().

This has no practical value other than for examining the cache for performance analysis.

Definition at line 378 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_size().

const RenderState * RenderState::get_invert_composition_cache_source ( int  n) const
inline

Returns the source RenderState of the nth element in the invert composition cache.

Returns NULL if there doesn't happen to be an entry in the nth element. See get_invert_composition_cache_result().

This has no practical value other than for examining the cache for performance analysis.

Definition at line 395 of file renderState.I.

References SimpleHashMap< Key, Value, Compare >::get_key(), and SimpleHashMap< Key, Value, Compare >::has_element().

int RenderState::get_max_priority ( )
static

Returns the maximum priority number (sometimes called override) that may be set on any node.

This may or may not be enforced, but the scene graph code assumes that no priority numbers will be larger than this, and some effects may not work properly if you use a larger number.

Definition at line 838 of file renderState.cxx.

int RenderState::get_num_states ( )
static

Returns the total number of unique RenderState objects allocated in the world.

This will go up and down during normal operations.

Definition at line 850 of file renderState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_num_entries().

Referenced by GraphicsEngine::render_frame().

int RenderState::get_num_unused_states ( )
static

Returns the total number of RenderState objects that have been allocated but have no references outside of the internal RenderState cache.

A nonzero return value is not necessarily indicative of leaked references; it is normal for two RenderState objects, both of which have references held outside the cache, to have to result of their composition stored within the cache. This result will be retained within the cache until one of the base RenderStates is released.

Use list_cycles() to get an idea of the number of actual "leaked" RenderState objects.

Definition at line 877 of file renderState.cxx.

References CachedTypedWritableReferenceCount::get_cache_ref_count(), SimpleHashMap< Key, Value, Compare >::get_data(), SimpleHashMap< Key, Value, Compare >::get_key(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

Referenced by GraphicsEngine::render_frame().

int RenderState::get_override ( TypeHandle  type) const
inline

Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.

Definition at line 175 of file renderState.I.

References RenderAttribRegistry::get_slot().

int RenderState::get_override ( int  slot) const
inline

Looks for a RenderAttrib of the indicated type in the state, and returns its override value if it is found, or 0 if it is not.

Definition at line 189 of file renderState.I.

bool RenderState::has_attrib ( TypeHandle  type) const
inline

Returns true if an attrib of the indicated type is present, false otherwise.

Definition at line 111 of file renderState.I.

References get_attrib().

bool RenderState::has_attrib ( int  slot) const
inline

Returns true if an attrib of the indicated type is present, false otherwise.

Definition at line 122 of file renderState.I.

References get_attrib().

bool RenderState::has_cull_callback ( ) const
inline

Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of them do.

Definition at line 45 of file renderState.I.

void RenderState::init_states ( )
static

Make sure the global _states map is allocated.

This only has to be done once. We could make this map static, but then we run into problems if anyone creates a RenderState object at static init time; it also seems to cause problems when the Panda shared library is unloaded at application exit time.

Definition at line 2179 of file renderState.cxx.

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

bool RenderState::is_empty ( ) const
inline

Returns true if the state is empty, false otherwise.

Definition at line 33 of file renderState.I.

References BitMask< WType, nbits >::is_zero().

Referenced by PandaNode::set_state().

void RenderState::list_cycles ( ostream &  out)
static

Detects all of the reference-count cycles in the cache and reports them to standard output.

These cycles may be inadvertently created when state compositions cycle back to a starting point. Nowadays, these cycles should be automatically detected and broken, so this method should never list any cycles unless there is a bug in that detection logic.

The cycles listed here are not leaks in the strictest sense of the word, since they can be reclaimed by a call to clear_cache(); but they will not be reclaimed automatically.

Definition at line 1161 of file renderState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_key(), ReferenceCount::get_ref_count(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

void RenderState::list_states ( ostream &  out)
static

Lists all of the RenderStates in the cache to the output stream, one per line.

This can be quite a lot of output if the cache is large, so be prepared.

Definition at line 1243 of file renderState.cxx.

References SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_num_entries(), SimpleHashMap< Key, Value, Compare >::get_size(), and SimpleHashMap< Key, Value, Compare >::has_element().

void RenderState::node_ref ( ) const
inline

Overrides this method to update PStats appropriately.

Definition at line 247 of file renderState.I.

References NodeCachedReferenceCount::get_referenced_bits(), and NodeCachedReferenceCount::node_ref().

bool RenderState::node_unref ( ) const
inline

Overrides this method to update PStats appropriately.

Definition at line 263 of file renderState.I.

References NodeCachedReferenceCount::get_referenced_bits().

void RenderState::register_with_read_factory ( )
static

Tells the BamReader how to create objects of type RenderState.

Definition at line 2200 of file renderState.cxx.

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

bool RenderState::unref ( ) const
virtual

This method overrides ReferenceCount::unref() to check whether the remaining reference count is entirely in the cache, and if so, it checks for and breaks a cycle in the cache involving this object.

This is designed to prevent leaks from cyclical references within the cache.

Reimplemented from ReferenceCount.

Definition at line 708 of file renderState.cxx.

References CachedTypedWritableReferenceCount::get_cache_ref_count(), ReferenceCount::get_ref_count(), and ReferenceCount::unref().

Referenced by finalize().

bool RenderState::validate_states ( )
static

Ensures that the cache is still stored in sorted order, and that none of the cache elements have been inadvertently deleted.

Returns true if so, false if there is a problem (which implies someone has modified one of the supposedly-const RenderState objects).

Definition at line 1273 of file renderState.cxx.

References compare_to(), SimpleHashMap< Key, Value, Compare >::get_key(), SimpleHashMap< Key, Value, Compare >::get_size(), SimpleHashMap< Key, Value, Compare >::is_empty(), and SimpleHashMap< Key, Value, Compare >::validate().

void RenderState::write_datagram ( BamWriter manager,
Datagram dg 
)
virtual

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