18 #include "pandabase.h" 20 #include "renderAttrib.h" 21 #include "nodeCachedReferenceCount.h" 22 #include "pointerTo.h" 24 #include "updateSeq.h" 25 #include "pStatCollector.h" 26 #include "renderModeAttrib.h" 27 #include "texMatrixAttrib.h" 28 #include "geomMunger.h" 29 #include "weakPointerTo.h" 30 #include "lightReMutex.h" 31 #include "lightMutex.h" 32 #include "deletedChain.h" 33 #include "simpleHashMap.h" 34 #include "cacheStats.h" 35 #include "renderAttribRegistry.h" 58 RenderState(
const RenderState ©);
59 void operator = (
const RenderState ©);
62 virtual ~RenderState();
63 ALLOC_DELETED_CHAIN(RenderState);
68 int compare_to(
const RenderState &other)
const;
69 int compare_sort(
const RenderState &other)
const;
70 int compare_mask(
const RenderState &other, SlotMask compare_mask)
const;
71 INLINE
size_t get_hash()
const;
73 INLINE
bool is_empty()
const;
75 INLINE
bool has_cull_callback()
const;
78 INLINE
static CPT(RenderState) make_empty();
79 INLINE
static CPT(RenderState) make_full_default();
80 static CPT(RenderState) make(
const RenderAttrib *attrib,
int override = 0);
81 static CPT(RenderState) make(
const RenderAttrib *attrib1,
83 static CPT(RenderState) make(
const RenderAttrib *attrib1,
86 static CPT(RenderState) make(
const RenderAttrib *attrib1,
90 static CPT(RenderState) make(
const RenderAttrib *attrib1,
95 static CPT(RenderState) make(
const RenderAttrib *
const *attrib,
96 int num_attribs,
int override = 0);
98 CPT(RenderState) compose(
const RenderState *other)
const;
99 CPT(RenderState) invert_compose(
const RenderState *other)
const;
101 CPT(RenderState) add_attrib(
const RenderAttrib *attrib,
int override = 0)
const;
102 CPT(RenderState) set_attrib(
const RenderAttrib *attrib)
const;
103 CPT(RenderState) set_attrib(
const RenderAttrib *attrib,
int override)
const;
104 INLINE CPT(RenderState) remove_attrib(
TypeHandle type)
const;
105 CPT(RenderState) remove_attrib(
int slot)
const;
107 CPT(RenderState) adjust_all_priorities(
int adjustment)
const;
109 INLINE
bool has_attrib(
TypeHandle type)
const;
110 INLINE
bool has_attrib(
int slot)
const;
113 INLINE
const RenderAttrib *get_attrib_def(
int slot)
const;
114 INLINE
int get_override(
TypeHandle type)
const;
115 INLINE
int get_override(
int slot)
const;
117 INLINE CPT(RenderState) get_unique()
const;
119 virtual bool unref()
const;
126 INLINE
int get_composition_cache_num_entries()
const;
127 INLINE
int get_invert_composition_cache_num_entries()
const;
129 INLINE
int get_composition_cache_size()
const;
130 INLINE
const RenderState *get_composition_cache_source(
int n)
const;
131 INLINE
const RenderState *get_composition_cache_result(
int n)
const;
132 INLINE
int get_invert_composition_cache_size()
const;
133 INLINE
const RenderState *get_invert_composition_cache_source(
int n)
const;
134 INLINE
const RenderState *get_invert_composition_cache_result(
int n)
const;
135 EXTENSION(PyObject *get_composition_cache()
const);
136 EXTENSION(PyObject *get_invert_composition_cache()
const);
138 const RenderState *get_auto_shader_state()
const;
140 void output(ostream &out)
const;
141 void write(ostream &out,
int indent_level)
const;
143 static int get_max_priority();
145 static int get_num_states();
146 static int get_num_unused_states();
147 static int clear_cache();
148 static void clear_munger_cache();
149 static int garbage_collect();
150 static void list_cycles(ostream &out);
151 static void list_states(ostream &out);
152 static bool validate_states();
153 EXTENSION(
static PyObject *get_states());
158 INLINE
int get_draw_order()
const;
159 INLINE
int get_bin_index()
const;
160 int get_geom_rendering(
int geom_rendering)
const;
163 static void bin_removed(
int bin_index);
165 INLINE
static void flush_level();
168 template<
class AttribType>
169 INLINE
bool get_attrib(
const AttribType *&attrib)
const;
170 template<
class AttribType>
171 INLINE
void get_attrib_def(
const AttribType *&attrib)
const;
175 INLINE
void check_hash()
const;
176 bool validate_filled_slots()
const;
177 INLINE
bool do_cache_unref()
const;
178 INLINE
bool do_node_unref()
const;
179 INLINE
void calc_hash();
181 void assign_auto_shader_state();
182 CPT(RenderState) do_calc_auto_shader_state();
184 class CompositionCycleDescEntry {
186 INLINE CompositionCycleDescEntry(
const RenderState *obj,
187 const RenderState *result,
190 const RenderState *_obj;
191 const RenderState *_result;
196 static CPT(RenderState) return_new(RenderState *state);
197 static CPT(RenderState) return_unique(RenderState *state);
198 CPT(RenderState) do_compose(
const RenderState *other)
const;
199 CPT(RenderState) do_invert_compose(
const RenderState *other)
const;
200 void detect_and_break_cycles();
201 static bool r_detect_cycles(
const RenderState *start_state,
202 const RenderState *current_state,
204 CompositionCycleDesc *cycle_desc);
205 static bool r_detect_reverse_cycles(
const RenderState *start_state,
206 const RenderState *current_state,
208 CompositionCycleDesc *cycle_desc);
211 void remove_cache_pointers();
213 void determine_bin_index();
214 void determine_cull_callback();
217 INLINE
void set_destructing();
218 INLINE
bool is_destructing()
const;
220 INLINE
void consider_update_pstats(
int old_referenced_bits)
const;
221 static void update_pstats(
int old_referenced_bits,
int new_referenced_bits);
224 static void init_states();
240 static States *_states;
241 static CPT(RenderState) _empty_state;
242 static CPT(RenderState) _full_default_state;
256 INLINE Composition();
257 INLINE Composition(
const Composition ©);
261 const RenderState *_result;
269 CompositionCache _composition_cache;
270 CompositionCache _invert_composition_cache;
280 Mungers::const_iterator _last_mi;
288 static int _garbage_index;
305 INLINE Attribute(
const RenderAttrib *attrib,
int override);
306 INLINE Attribute(
int override = 0);
307 INLINE Attribute(
const Attribute ©);
308 INLINE
void operator = (
const Attribute ©);
309 INLINE
void set(
const RenderAttrib *attrib,
int override);
310 INLINE
int compare_to(
const Attribute &other)
const;
315 Attribute *_attributes;
319 SlotMask _filled_slots;
327 const RenderState *_auto_shader_state;
330 F_checked_bin_index = 0x000001,
331 F_checked_cull_callback = 0x000002,
332 F_has_cull_callback = 0x000004,
333 F_is_destructing = 0x000008,
334 F_hash_known = 0x000010,
338 vector_int *_read_overrides;
346 static void register_with_read_factory();
350 virtual void finalize(
BamReader *manager);
360 static void init_type() {
361 NodeCachedReferenceCount::init_type();
362 register_type(_type_handle,
"RenderState",
363 NodeCachedReferenceCount::get_class_type());
366 return get_class_type();
368 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
378 INLINE ostream &operator << (ostream &out,
const RenderState &state) {
383 #include "renderState.I"
This is the base class for a number of render attributes (other than transform) that may be set on sc...
This class further specializes CachedTypedWritableReferenceCount to also add a node_ref_count, for the purposes of counting the number of times the object is referenced by a "node", presumably a PandaNode.
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Base class for objects that can be written to and read from Bam files.
A lightweight reentrant mutex.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
void node_ref() const
Explicitly increments the reference count.
This template class implements an unordered map of keys to data, implemented as a hashtable...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is our own Panda specialization on the default STL list.
This is our own Panda specialization on the default STL vector.
A lightweight class that represents a single element that may be timed and/or counted via stats...
bool cache_unref() const
Explicitly decrements the cache reference count and the normal reference count simultaneously.
This class is used to associate each RenderAttrib with a different slot index at runtime, so we can store a list of RenderAttribs in the RenderState object, and very quickly look them up by type.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
bool node_unref() const
Explicitly decrements the node reference count and the normal reference count simultaneously.
The default class template does not define any methods.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
This is used to track the utilization of the TransformState and RenderState caches, for low-level performance tuning information.
Encapsulates all the communication with a particular instance of a given rendering backend...
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
This is a sequence number that increments monotonically.
This is a standard, non-reentrant mutex, similar to the Mutex class.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
virtual bool unref() const
Explicitly decrements the reference count.