Panda3D
Loading...
Searching...
No Matches
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
27struct 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 */
38class EXPCL_PANDA_PIPELINE Pipeline : public Namable {
39public:
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_cycler(PipelineCyclerTrueImpl *cycler, bool dirty);
54 void add_dirty_cycler(PipelineCyclerTrueImpl *cycler);
55 void remove_cycler(PipelineCyclerTrueImpl *cycler);
56
57 INLINE int get_num_cyclers() const;
58 INLINE int get_num_dirty_cyclers() const;
59
60#ifdef DEBUG_THREADS
61 typedef void CallbackFunc(TypeHandle type, int count, void *data);
62 void iterate_all_cycler_types(CallbackFunc *func, void *data) const;
63 void iterate_dirty_cycler_types(CallbackFunc *func, void *data) const;
64#endif // DEBUG_THREADS
65
66#endif // THREADED_PIPELINE
67
68private:
69 int _num_stages;
70
71 static void make_render_pipeline();
72 static Pipeline *_render_pipeline;
73
74#ifdef THREADED_PIPELINE
77
78 int _num_cyclers;
79 int _num_dirty_cyclers;
80
81#ifdef DEBUG_THREADS
82 typedef pmap<TypeHandle, int> TypeCount;
83 TypeCount _all_cycler_types, _dirty_cycler_types;
84
85 static void inc_cycler_type(TypeCount &count, TypeHandle type, int addend);
86#endif // DEBUG_THREADS
87
88 // This is true only during cycle().
89 bool _cycling;
90
91 // This increases with every cycle run. If the _dirty field of a cycler is
92 // set to the same value as this, it indicates that it is scheduled for the
93 // next cycle.
94 unsigned int _next_cycle_seq;
95
96 // This lock is always held during cycle().
97 ReMutex _cycle_lock;
98
99 // This lock protects the data stored on this Pipeline.
100 Mutex _lock;
101#endif // THREADED_PIPELINE
102};
103
104#include "pipeline.I"
105
106#endif
A standard mutex, or mutual exclusion lock.
Definition pmutex.h:40
A base class for all things which can have a name.
Definition namable.h:26
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition pipeline.h:38
A reentrant mutex.
Definition reMutex.h:34
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
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.