Panda3D
graphicsThreadingModel.I
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 graphicsThreadingModel.I
10  * @author drose
11  * @date 2003-01-27
12  */
13 
14 /**
15  *
16  */
19  _cull_name(copy._cull_name),
20  _cull_stage(copy._cull_stage),
21  _draw_name(copy._draw_name),
22  _draw_stage(copy._draw_stage),
23  _cull_sorting(copy._cull_sorting)
24 {
25 }
26 
27 /**
28  *
29  */
30 INLINE void GraphicsThreadingModel::
31 operator = (const GraphicsThreadingModel &copy) {
32  _cull_name = copy._cull_name;
33  _cull_stage = copy._cull_stage;
34  _draw_name = copy._draw_name;
35  _draw_stage = copy._draw_stage;
36  _cull_sorting = copy._cull_sorting;
37 }
38 
39 /**
40  * Returns the name of the thread that will handle culling in this model.
41  */
42 INLINE const std::string &GraphicsThreadingModel::
43 get_cull_name() const {
44  return _cull_name;
45 }
46 
47 /**
48  * Changes the name of the thread that will handle culling in this model.
49  * This won't change any windows that were already created with this model;
50  * this only has an effect on newly-opened windows.
51  */
52 INLINE void GraphicsThreadingModel::
53 set_cull_name(const std::string &cull_name) {
54  _cull_name = cull_name;
55  update_stages();
56 }
57 
58 /**
59  * Returns the pipeline stage from which the cull thread should access data.
60  * This will be 0 if the cull is run in the same thread as app, or 1 if it is
61  * its own thread.
62  */
63 INLINE int GraphicsThreadingModel::
64 get_cull_stage() const {
65  return _cull_stage;
66 }
67 
68 /**
69  * Returns the name of the thread that will handle sending the actual graphics
70  * primitives to the graphics API in this model.
71  */
72 INLINE const std::string &GraphicsThreadingModel::
73 get_draw_name() const {
74  return _draw_name;
75 }
76 
77 /**
78  * Changes the name of the thread that will handle drawing in this model.
79  * This won't change any windows that were already created with this model;
80  * this only has an effect on newly-opened windows.
81  */
82 INLINE void GraphicsThreadingModel::
83 set_draw_name(const std::string &draw_name) {
84  _draw_name = draw_name;
85  update_stages();
86 }
87 
88 /**
89  * Returns the pipeline stage from which the draw thread should access data.
90  * This will be the same value as get_cull_stage() if cull and draw are run in
91  * the same thread, or one more than that value if draw should be in its own
92  * thread.
93  */
94 INLINE int GraphicsThreadingModel::
95 get_draw_stage() const {
96  return _draw_stage;
97 }
98 
99 /**
100  * Returns true if the model involves a separate cull pass, or false if
101  * culling happens implicitly, at the same time as draw.
102  */
103 INLINE bool GraphicsThreadingModel::
105  return _cull_sorting;
106 
107 }
108 
109 /**
110  * Changes the flag that indicates whether the threading model involves a
111  * separate cull pass. This won't change any windows that were already
112  * created with this model; this only has an effect on newly-opened windows.
113  */
114 INLINE void GraphicsThreadingModel::
115 set_cull_sorting(bool cull_sorting) {
116  _cull_sorting = cull_sorting;
117  update_stages();
118 }
119 
120 /**
121  * Returns true if the threading model is a single-threaded model, or false if
122  * it involves threads.
123  */
124 INLINE bool GraphicsThreadingModel::
126  return _cull_name.empty() && _draw_name.empty();
127 }
128 
129 /**
130  * Returns true if the threading model is the default, cull-then-draw single-
131  * threaded model, or false otherwise.
132  */
133 INLINE bool GraphicsThreadingModel::
134 is_default() const {
135  return is_single_threaded() && _cull_sorting;
136 }
137 
138 
139 /**
140  *
141  */
142 INLINE void GraphicsThreadingModel::
143 output(std::ostream &out) const {
144  out << get_model();
145 }
146 
147 INLINE std::ostream &
148 operator << (std::ostream &out, const GraphicsThreadingModel &threading_model) {
149  threading_model.output(out);
150  return out;
151 }
bool is_default() const
Returns true if the threading model is the default, cull-then-draw single- threaded model,...
bool get_cull_sorting() const
Returns true if the model involves a separate cull pass, or false if culling happens implicitly,...
std::string get_model() const
Returns the string that describes the threading model.
int get_cull_stage() const
Returns the pipeline stage from which the cull thread should access data.
const std::string & get_cull_name() const
Returns the name of the thread that will handle culling in this model.
void set_cull_name(const std::string &cull_name)
Changes the name of the thread that will handle culling in this model.
bool is_single_threaded() const
Returns true if the threading model is a single-threaded model, or false if it involves threads.
int get_draw_stage() const
Returns the pipeline stage from which the draw thread should access data.
This represents the user's specification of how a particular frame is handled by the various threads.
void set_cull_sorting(bool cull_sorting)
Changes the flag that indicates whether the threading model involves a separate cull pass.
const std::string & get_draw_name() const
Returns the name of the thread that will handle sending the actual graphics primitives to the graphic...
void set_draw_name(const std::string &cull_name)
Changes the name of the thread that will handle drawing in this model.
GraphicsThreadingModel(const std::string &model=std::string())
The threading model accepts a string representing the names of the two threads that will process cull...