Panda3D
 All Classes Functions Variables Enumerations
pipeline.h
1 // Filename: pipeline.h
2 // Created by: drose (21Feb02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PIPELINE_H
16 #define PIPELINE_H
17 
18 #include "pandabase.h"
19 #include "pipelineCyclerLinks.h"
20 #include "namable.h"
21 #include "pset.h"
22 #include "reMutex.h"
23 #include "reMutexHolder.h"
24 #include "selectThreadImpl.h" // for THREADED_PIPELINE definition
25 
26 struct PipelineCyclerTrueImpl;
27 
28 ////////////////////////////////////////////////////////////////////
29 // Class : Pipeline
30 // Description : This class manages a staged pipeline of data, for
31 // instance the render pipeline, so that each stage of
32 // the pipeline can simultaneously access different
33 // copies of the same data. It actually maintains a
34 // collection of PipelineCycler objects, and manages the
35 // turning of all of them at once.
36 //
37 // There is one default Pipeline object, the render
38 // pipeline. Other specialty pipelines may be created
39 // as needed.
40 ////////////////////////////////////////////////////////////////////
41 class EXPCL_PANDA_PIPELINE Pipeline : public Namable {
42 public:
43  Pipeline(const string &name, int num_stages);
44  ~Pipeline();
45 
46  INLINE static Pipeline *get_render_pipeline();
47 
48  void cycle();
49 
50  void set_num_stages(int num_stages);
51  INLINE void set_min_stages(int min_stages);
52  INLINE int get_num_stages() const;
53 
54 #ifdef THREADED_PIPELINE
55  void add_cycler(PipelineCyclerTrueImpl *cycler);
56  void add_dirty_cycler(PipelineCyclerTrueImpl *cycler);
57  void remove_cycler(PipelineCyclerTrueImpl *cycler);
58 
59  INLINE int get_num_cyclers() const;
60  INLINE int get_num_dirty_cyclers() const;
61 
62 #ifdef DEBUG_THREADS
63  typedef void CallbackFunc(TypeHandle type, int count, void *data);
64  void iterate_all_cycler_types(CallbackFunc *func, void *data) const;
65  void iterate_dirty_cycler_types(CallbackFunc *func, void *data) const;
66 #endif // DEBUG_THREADS
67 
68 #endif // THREADED_PIPELINE
69 
70 private:
71  int _num_stages;
72 
73  static void make_render_pipeline();
74  static Pipeline *_render_pipeline;
75 
76 #ifdef THREADED_PIPELINE
77  PipelineCyclerLinks _clean;
78  PipelineCyclerLinks _dirty;
79 
80  int _num_cyclers;
81  int _num_dirty_cyclers;
82 
83 #ifdef DEBUG_THREADS
84  typedef pmap<TypeHandle, int> TypeCount;
85  TypeCount _all_cycler_types, _dirty_cycler_types;
86 
87  static void inc_cycler_type(TypeCount &count, TypeHandle type, int addend);
88 #endif // DEBUG_THREADS
89 
90  // This is true only during cycle().
91  bool _cycling;
92 
93  ReMutex _lock;
94 #endif // THREADED_PIPELINE
95 };
96 
97 #include "pipeline.I"
98 
99 #endif
100 
This is our own Panda specialization on the default STL map.
Definition: pmap.h:52
A base class for all things which can have a name.
Definition: namable.h:29
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition: pipeline.h:41
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
A reentrant mutex.
Definition: reMutex.h:36