Panda3D
 All Classes Functions Variables Enumerations
graphicsThreadingModel.I
1 // Filename: graphicsThreadingModel.I
2 // Created by: drose (27Jan03)
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: GraphicsThreadingModel::Copy Constructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
23  _cull_name(copy._cull_name),
24  _cull_stage(copy._cull_stage),
25  _draw_name(copy._draw_name),
26  _draw_stage(copy._draw_stage),
27  _cull_sorting(copy._cull_sorting)
28 {
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: GraphicsThreadingModel::Copy Assignment Operator
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 INLINE void GraphicsThreadingModel::
37 operator = (const GraphicsThreadingModel &copy) {
38  _cull_name = copy._cull_name;
39  _cull_stage = copy._cull_stage;
40  _draw_name = copy._draw_name;
41  _draw_stage = copy._draw_stage;
42  _cull_sorting = copy._cull_sorting;
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: GraphicsThreadingModel::get_cull_name
47 // Access: Published
48 // Description: Returns the name of the thread that will handle
49 // culling in this model.
50 ////////////////////////////////////////////////////////////////////
51 INLINE const string &GraphicsThreadingModel::
52 get_cull_name() const {
53  return _cull_name;
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: GraphicsThreadingModel::set_cull_name
58 // Access: Published
59 // Description: Changes the name of the thread that will handle
60 // culling in this model. This won't change any windows
61 // that were already created with this model; this only
62 // has an effect on newly-opened windows.
63 ////////////////////////////////////////////////////////////////////
64 INLINE void GraphicsThreadingModel::
65 set_cull_name(const string &cull_name) {
66  _cull_name = cull_name;
67  update_stages();
68 }
69 
70 ////////////////////////////////////////////////////////////////////
71 // Function: GraphicsThreadingModel::get_cull_stage
72 // Access: Published
73 // Description: Returns the pipeline stage from which the cull thread
74 // should access data. This will be 0 if the cull is
75 // run in the same thread as app, or 1 if it is its own
76 // thread.
77 ////////////////////////////////////////////////////////////////////
78 INLINE int GraphicsThreadingModel::
79 get_cull_stage() const {
80  return _cull_stage;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: GraphicsThreadingModel::get_draw_name
85 // Access: Published
86 // Description: Returns the name of the thread that will handle
87 // sending the actual graphics primitives to the
88 // graphics API in this model.
89 ////////////////////////////////////////////////////////////////////
90 INLINE const string &GraphicsThreadingModel::
91 get_draw_name() const {
92  return _draw_name;
93 }
94 
95 ////////////////////////////////////////////////////////////////////
96 // Function: GraphicsThreadingModel::set_draw_name
97 // Access: Published
98 // Description: Changes the name of the thread that will handle
99 // drawing in this model. This won't change any windows
100 // that were already created with this model; this only
101 // has an effect on newly-opened windows.
102 ////////////////////////////////////////////////////////////////////
103 INLINE void GraphicsThreadingModel::
104 set_draw_name(const string &draw_name) {
105  _draw_name = draw_name;
106  update_stages();
107 }
108 
109 ////////////////////////////////////////////////////////////////////
110 // Function: GraphicsThreadingModel::get_draw_stage
111 // Access: Published
112 // Description: Returns the pipeline stage from which the draw thread
113 // should access data. This will be the same value as
114 // get_cull_stage() if cull and draw are run in the same
115 // thread, or one more than that value if draw should be
116 // in its own thread.
117 ////////////////////////////////////////////////////////////////////
118 INLINE int GraphicsThreadingModel::
119 get_draw_stage() const {
120  return _draw_stage;
121 }
122 
123 ////////////////////////////////////////////////////////////////////
124 // Function: GraphicsThreadingModel::get_cull_sorting
125 // Access: Published
126 // Description: Returns true if the model involves a separate cull
127 // pass, or false if culling happens implicitly, at the
128 // same time as draw.
129 ////////////////////////////////////////////////////////////////////
130 INLINE bool GraphicsThreadingModel::
132  return _cull_sorting;
133 
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: GraphicsThreadingModel::set_cull_sorting
138 // Access: Published
139 // Description: Changes the flag that indicates whether the threading
140 // model involves a separate cull pass. This won't
141 // change any windows that were already created with
142 // this model; this only has an effect on newly-opened
143 // windows.
144 ////////////////////////////////////////////////////////////////////
145 INLINE void GraphicsThreadingModel::
146 set_cull_sorting(bool cull_sorting) {
147  _cull_sorting = cull_sorting;
148  update_stages();
149 }
150 
151 ////////////////////////////////////////////////////////////////////
152 // Function: GraphicsThreadingModel::is_single_threaded
153 // Access: Published
154 // Description: Returns true if the threading model is a
155 // single-threaded model, or false if it involves
156 // threads.
157 ////////////////////////////////////////////////////////////////////
158 INLINE bool GraphicsThreadingModel::
160  return _cull_name.empty() && _draw_name.empty();
161 }
162 
163 ////////////////////////////////////////////////////////////////////
164 // Function: GraphicsThreadingModel::is_default
165 // Access: Published
166 // Description: Returns true if the threading model is the default,
167 // cull-then-draw single-threaded model, or false
168 // otherwise.
169 ////////////////////////////////////////////////////////////////////
170 INLINE bool GraphicsThreadingModel::
171 is_default() const {
172  return is_single_threaded() && _cull_sorting;
173 }
174 
175 
176 ////////////////////////////////////////////////////////////////////
177 // Function: GraphicsThreadingModel::output
178 // Access: Published
179 // Description:
180 ////////////////////////////////////////////////////////////////////
181 INLINE void GraphicsThreadingModel::
182 output(ostream &out) const {
183  out << get_model();
184 }
185 
186 INLINE ostream &
187 operator << (ostream &out, const GraphicsThreadingModel &threading_model) {
188  threading_model.output(out);
189  return out;
190 }
string get_model() const
Returns the string that describes the threading model.
void set_cull_name(const string &cull_name)
Changes the name of the thread that will handle culling in this model.
void set_draw_name(const string &cull_name)
Changes the name of the thread that will handle drawing in this model.
GraphicsThreadingModel(const string &model=string())
The threading model accepts a string representing the names of the two threads that will process cull...
int get_cull_stage() const
Returns the pipeline stage from which the cull thread should access data.
bool get_cull_sorting() const
Returns true if the model involves a separate cull pass, or false if culling happens implicitly...
int get_draw_stage() const
Returns the pipeline stage from which the draw thread should access data.
const string & get_cull_name() const
Returns the name of the thread that will handle culling in this model.
const string & get_draw_name() const
Returns the name of the thread that will handle sending the actual graphics primitives to the graphic...
This represents the user&#39;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...
bool is_single_threaded() const
Returns true if the threading model is a single-threaded model, or false if it involves threads...
bool is_default() const
Returns true if the threading model is the default, cull-then-draw single-threaded model...