47class EXPCL_PANDA_PGRAPH RenderState :
public NodeCachedReferenceCount {
52 RenderState(
const RenderState ©);
55 virtual ~RenderState();
56 ALLOC_DELETED_CHAIN(RenderState);
58 RenderState &operator = (
const RenderState ©) =
delete;
60 typedef RenderAttribRegistry::SlotMask SlotMask;
63 int compare_to(
const RenderState &other)
const;
73 INLINE
static CPT(RenderState) make_empty();
90 int num_attribs,
int override = 0);
92 CPT(RenderState)
compose(
const RenderState *other)
const;
98 INLINE CPT(RenderState) remove_attrib(
TypeHandle type)
const;
99 CPT(RenderState) remove_attrib(
int slot)
const;
103 INLINE
bool has_attrib(
TypeHandle type)
const;
104 INLINE
bool has_attrib(
int slot)
const;
106 ALWAYS_INLINE
const RenderAttrib *get_attrib(
int slot)
const;
107 INLINE
const RenderAttrib *get_attrib_def(
int slot)
const;
108 INLINE
int get_override(
TypeHandle type)
const;
109 INLINE
int get_override(
int slot)
const;
111 MAKE_MAP_PROPERTY(attribs, has_attrib, get_attrib);
113 INLINE CPT(RenderState) get_unique()
const;
115 virtual bool unref()
const;
122 INLINE
size_t get_composition_cache_num_entries()
const;
123 INLINE
size_t get_invert_composition_cache_num_entries()
const;
125 INLINE
size_t get_composition_cache_size()
const;
126 INLINE
const RenderState *get_composition_cache_source(
size_t n)
const;
127 INLINE
const RenderState *get_composition_cache_result(
size_t n)
const;
128 INLINE
size_t get_invert_composition_cache_size()
const;
129 INLINE
const RenderState *get_invert_composition_cache_source(
size_t n)
const;
130 INLINE
const RenderState *get_invert_composition_cache_result(
size_t n)
const;
131 EXTENSION(PyObject *get_composition_cache()
const);
132 EXTENSION(PyObject *get_invert_composition_cache()
const);
134 void output(std::ostream &out)
const;
135 void write(std::ostream &out,
int indent_level)
const;
147 EXTENSION(
static PyObject *get_states());
148 EXTENSION(
static PyObject *get_unused_states());
153 INLINE
int get_draw_order()
const;
154 INLINE
int get_bin_index()
const;
163 template<
class AttribType>
164 INLINE
bool get_attrib(
const AttribType *&attrib)
const;
165 template<
class AttribType>
166 INLINE
bool get_attrib(CPT(AttribType) &attrib)
const;
167 template<
class AttribType>
168 INLINE
void get_attrib_def(
const AttribType *&attrib)
const;
169 template<
class AttribType>
170 INLINE
void get_attrib_def(CPT(AttribType) &attrib)
const;
176 INLINE
void cache_unref_only()
const;
179 INLINE
void check_hash()
const;
180 bool validate_filled_slots()
const;
181 INLINE
bool do_cache_unref()
const;
182 INLINE
bool do_node_unref()
const;
183 INLINE
void calc_hash();
186 class CompositionCycleDescEntry {
188 INLINE CompositionCycleDescEntry(
const RenderState *obj,
189 const RenderState *result,
192 const RenderState *_obj;
193 const RenderState *_result;
196 typedef pvector<CompositionCycleDescEntry> CompositionCycleDesc;
198 static CPT(RenderState) return_new(RenderState *state);
199 static CPT(RenderState) return_unique(RenderState *state);
200 CPT(RenderState) do_compose(
const RenderState *other)
const;
201 CPT(RenderState) do_invert_compose(
const RenderState *other)
const;
202 void detect_and_break_cycles();
203 static bool r_detect_cycles(
const RenderState *start_state,
204 const RenderState *current_state,
206 CompositionCycleDesc *cycle_desc);
207 static bool r_detect_reverse_cycles(
const RenderState *start_state,
208 const RenderState *current_state,
210 CompositionCycleDesc *cycle_desc);
213 void remove_cache_pointers();
215 void determine_bin_index();
216 void determine_cull_callback();
219 INLINE
void set_destructing();
220 INLINE
bool is_destructing()
const;
222 INLINE
void consider_update_pstats(
int old_referenced_bits)
const;
223 static void update_pstats(
int old_referenced_bits,
int new_referenced_bits);
241 static States *_states;
242 static const RenderState *_empty_state;
256 INLINE Composition();
257 INLINE Composition(
const Composition ©);
261 const RenderState *_result;
269 CompositionCache _composition_cache;
270 CompositionCache _invert_composition_cache;
278 mutable Mungers _mungers;
279 mutable int _last_mi;
283 typedef SimpleHashMap<size_t, WCPT(RenderState), size_t_hash> MungedStates;
284 mutable MungedStates _munged_states;
292 static size_t _garbage_index;
309 INLINE Attribute(
const RenderAttrib *attrib,
int override);
310 INLINE Attribute(
int override = 0);
311 INLINE Attribute(
const Attribute ©);
312 INLINE
void operator = (
const Attribute ©);
313 INLINE
void set(
const RenderAttrib *attrib,
int override);
314 INLINE
int compare_to(
const Attribute &other)
const;
319 Attribute _attributes[RenderAttribRegistry::_max_slots];
323 SlotMask _filled_slots;
332 F_checked_bin_index = 0x000001,
333 F_checked_cull_callback = 0x000002,
334 F_has_cull_callback = 0x000004,
335 F_is_destructing = 0x000008,
336 F_hash_known = 0x000010,
340 vector_int *_read_overrides;
362 static void init_type() {
363 NodeCachedReferenceCount::init_type();
365 NodeCachedReferenceCount::get_class_type());
368 return get_class_type();
370 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
375 friend class GraphicsStateGuardian;
376 friend class RenderAttribRegistry;
378 friend class ShaderGenerator;
379 friend class StateMunger;
384INLINE
void PointerToBase<RenderState>::update_type(
To *ptr) {}
386INLINE std::ostream &operator << (std::ostream &out,
const RenderState &state) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is used to track the utilization of the TransformState and RenderState caches,...
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
bool cache_unref() const
Explicitly decrements the cache reference count and the normal reference count simultaneously.
void cache_ref_only() const
Decrements the cache reference count without affecting the normal reference count.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
A class to retrieve the individual data elements previously stored in a Datagram.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
The default class template does not define any methods.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
This is a standard, non-reentrant mutex, similar to the Mutex class.
A lightweight reentrant mutex.
bool node_unref() const
Explicitly decrements the node reference count and the normal reference count simultaneously.
void node_ref() const
Explicitly increments the reference count.
A lightweight class that represents a single element that may be timed and/or counted via stats.
virtual bool unref() const
Explicitly decrements the reference count.
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
size_t get_hash() const
Returns a suitable hash value for phash_map.
int compare_to(const RenderState &other) const
Provides an arbitrary ordering among all unique RenderStates, so we can store the essentially differe...
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 compar...
static ConstPointerTo< RenderState > make(const RenderAttrib *attrib, int override=0)
Returns a RenderState with one attribute set.
ConstPointerTo< RenderState > adjust_all_priorities(int adjustment) const
Returns a new RenderState object that represents the same as the source state, with all attributes' o...
static void register_with_read_factory()
Tells the BamReader how to create objects of type RenderState.
static int get_num_states()
Returns the total number of unique RenderState objects allocated in the world.
static void list_states(std::ostream &out)
Lists all of the RenderStates in the cache to the output stream, one per line.
ConstPointerTo< RenderState > set_attrib(const RenderAttrib *attrib) const
Returns a new RenderState object that represents the same as the source state, with the new RenderAtt...
bool is_empty() const
Returns true if the state is empty, false otherwise.
static int garbage_collect()
Performs a garbage-collection cycle.
bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const
Calls cull_callback() on each attrib.
bool has_cull_callback() const
Returns true if any of the RenderAttribs in this state request a cull_callback(), false if none of th...
static void bin_removed(int bin_index)
Intended to be called by CullBinManager::remove_bin(), this informs all the RenderStates in the world...
int compare_sort(const RenderState &other) const
Returns -1, 0, or 1 according to the relative sorting of these two RenderStates, with regards to rend...
ConstPointerTo< RenderState > add_attrib(const RenderAttrib *attrib, int override=0) const
Returns a new RenderState object that represents the same as the source state, with the new RenderAtt...
static void init_states()
Make sure the global _states map is allocated.
static void clear_munger_cache()
Completely empties the cache of state + gsg -> munger, for all states and all gsg's.
static bool validate_states()
Ensures that the cache is still stored in sorted order, and that none of the cache elements have been...
static int get_max_priority()
Returns the maximum priority number (sometimes called override) that may be set on any node.
static void flush_level()
Flushes the PStatCollectors used during traversal.
static TypedWritable * change_this(TypedWritable *old_ptr, BamReader *manager)
Called immediately after complete_pointers(), this gives the object a chance to adjust its own pointe...
static void list_cycles(std::ostream &out)
Detects all of the reference-count cycles in the cache and reports them to standard output.
static int clear_cache()
Empties the cache of composed RenderStates.
ConstPointerTo< RenderState > compose(const RenderState *other) const
Returns a new RenderState object that represents the composition of this state with the other state.
int get_geom_rendering(int geom_rendering) const
Returns the union of the Geom::GeomRendering bits that will be required once this RenderState is appl...
ConstPointerTo< RenderState > invert_compose(const RenderState *other) const
Returns a new RenderState object that represents the composition of this state's inverse with the oth...
static int get_num_unused_states()
Returns the total number of RenderState objects that have been allocated but have no references outsi...
This template class implements an unordered map of keys to data, implemented as a hashtable.
TypeHandle is the identifier used to differentiate C++ class types.
Base class for objects that can be written to and read from Bam files.
virtual void finalize(BamReader *manager)
Called by the BamReader to perform any final actions needed for setting up the object after all objec...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class's make_from_bam() method to read in all...
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual int complete_pointers(TypedWritable **p_list, BamReader *manager)
Receives an array of pointers, one for each time manager->read_pointer() was called in fillin().
This is a sequence number that increments monotonically.
This is our own Panda specialization on the default STL list.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.