Panda3D

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