Panda3D

pipelineCycler.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 pipelineCycler.I
10 * @author drose
11 * @date 2002-02-21
12 */
13
14 #ifdef DO_PIPELINING
15 // The following implementations are to support the PipelineCyclerDummyImpl or
16 // the PipelineCyclerTrueImpl.
17
18 /**
19 *
20 */
21 template<class CycleDataType>
22 INLINE PipelineCycler<CycleDataType>::
23 PipelineCycler(Pipeline *pipeline) :
24 PipelineCyclerBase(new CycleDataType, pipeline)
25 {
26 }
27
28 /**
29 *
30 */
31 template<class CycleDataType>
32 INLINE PipelineCycler<CycleDataType>::
33 PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) :
34 PipelineCyclerBase(new CycleDataType(std::move(initial_data)), pipeline)
35 {
36 }
37
38 /**
39 *
40 */
41 template<class CycleDataType>
42 INLINE PipelineCycler<CycleDataType>::
43 PipelineCycler(const PipelineCycler<CycleDataType> &copy) :
44 PipelineCyclerBase(copy)
45 {
46 }
47
48 /**
49 *
50 */
51 template<class CycleDataType>
52 INLINE void PipelineCycler<CycleDataType>::
53 operator = (const PipelineCycler<CycleDataType> &copy) {
54 PipelineCyclerBase::operator = (copy);
55 }
56
57 /**
58 * See PipelineCyclerBase::read_unlocked().
59 */
60 template<class CycleDataType>
61 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
62 read_unlocked(Thread *current_thread) const {
63 return (const CycleDataType *)PipelineCyclerBase::read_unlocked(current_thread);
64 }
65
66 /**
67 * See PipelineCyclerBase::read().
68 */
69 template<class CycleDataType>
70 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
71 read(Thread *current_thread) const {
72 return (const CycleDataType *)PipelineCyclerBase::read(current_thread);
73 }
74
75 /**
76 * See PipelineCyclerBase::write().
77 */
78 template<class CycleDataType>
79 INLINE CycleDataType *PipelineCycler<CycleDataType>::
80 write(Thread *current_thread) {
81 return (CycleDataType *)PipelineCyclerBase::write(current_thread);
82 }
83
84 /**
85 * See PipelineCyclerBase::write_upstream().
86 */
87 template<class CycleDataType>
88 INLINE CycleDataType *PipelineCycler<CycleDataType>::
89 write_upstream(bool force_to_0, Thread *current_thread) {
90 return (CycleDataType *)PipelineCyclerBase::write_upstream(force_to_0, current_thread);
91 }
92
93 /**
94 * See PipelineCyclerBase::elevate_read().
95 */
96 template<class CycleDataType>
97 INLINE CycleDataType *PipelineCycler<CycleDataType>::
98 elevate_read(const CycleDataType *pointer, Thread *current_thread) {
99 return (CycleDataType *)PipelineCyclerBase::elevate_read(pointer, current_thread);
100 }
101
102 /**
103 * See PipelineCyclerBase::elevate_read_upstream().
104 */
105 template<class CycleDataType>
106 INLINE CycleDataType *PipelineCycler<CycleDataType>::
107 elevate_read_upstream(const CycleDataType *pointer, bool force_to_0,
108 Thread *current_thread) {
109 return (CycleDataType *)PipelineCyclerBase::elevate_read_upstream(pointer, force_to_0, current_thread);
110 }
111
112 /**
113 * See PipelineCyclerBase::read_stage_unlocked().
114 */
115 template<class CycleDataType>
116 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
117 read_stage_unlocked(int pipeline_stage) const {
118 return (const CycleDataType *)PipelineCyclerBase::read_stage_unlocked(pipeline_stage);
119 }
120
121 /**
122 * See PipelineCyclerBase::read_stage().
123 */
124 template<class CycleDataType>
125 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
126 read_stage(int pipeline_stage, Thread *current_thread) const {
127 return (const CycleDataType *)PipelineCyclerBase::read_stage(pipeline_stage, current_thread);
128 }
129
130 /**
131 * See PipelineCyclerBase::elevate_read_stage().
132 */
133 template<class CycleDataType>
134 INLINE CycleDataType *PipelineCycler<CycleDataType>::
135 elevate_read_stage(int pipeline_stage, const CycleDataType *pointer,
136 Thread *current_thread) {
137 return (CycleDataType *)PipelineCyclerBase::elevate_read_stage(pipeline_stage, pointer, current_thread);
138 }
139
140 /**
141 * See PipelineCyclerBase::elevate_read_stage_upstream().
142 */
143 template<class CycleDataType>
144 INLINE CycleDataType *PipelineCycler<CycleDataType>::
145 elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer,
146 bool force_to_0, Thread *current_thread) {
147 return (CycleDataType *)PipelineCyclerBase::elevate_read_stage_upstream(pipeline_stage, pointer, force_to_0, current_thread);
148 }
149
150 /**
151 * See PipelineCyclerBase::write_stage().
152 */
153 template<class CycleDataType>
154 INLINE CycleDataType *PipelineCycler<CycleDataType>::
155 write_stage(int pipeline_stage, Thread *current_thread) {
156 return (CycleDataType *)PipelineCyclerBase::write_stage(pipeline_stage, current_thread);
157 }
158
159 /**
160 * See PipelineCyclerBase::write_stage_upstream().
161 */
162 template<class CycleDataType>
163 INLINE CycleDataType *PipelineCycler<CycleDataType>::
164 write_stage_upstream(int pipeline_stage, bool force_to_0,
165 Thread *current_thread) {
166 return (CycleDataType *)PipelineCyclerBase::write_stage_upstream(pipeline_stage, force_to_0, current_thread);
167 }
168
169 /**
170 * Returns a pointer without counting it. This is only intended for use as
171 * the return value for certain nassertr() functions, so the application can
172 * recover after a failure to manage the read and write pointers correctly.
173 * You should never call this function directly.
174 */
175 template<class CycleDataType>
176 INLINE CycleDataType *PipelineCycler<CycleDataType>::
177 cheat() const {
178 return (CycleDataType *)PipelineCyclerBase::cheat();
179 }
180
181 #else // !DO_PIPELINING
182 // The following implementations are provided for when pipelining is not
183 // compiled in. They are trivial functions that do as little as possible.
184
185 /**
186 *
187 */
188 template<class CycleDataType>
189 INLINE PipelineCycler<CycleDataType>::
190 PipelineCycler(Pipeline *pipeline) :
191 PipelineCyclerBase(&_typed_data, pipeline)
192 {
193 }
194
195 /**
196 *
197 */
198 template<class CycleDataType>
199 INLINE PipelineCycler<CycleDataType>::
200 PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) :
201 _typed_data(std::move(initial_data)),
202 PipelineCyclerBase(&_typed_data, pipeline)
203 {
204 }
205
206 /**
207 *
208 */
209 template<class CycleDataType>
210 INLINE PipelineCycler<CycleDataType>::
211 PipelineCycler(const PipelineCycler<CycleDataType> &copy) :
212 PipelineCyclerBase(&_typed_data),
213 _typed_data(copy._typed_data)
214 {
215 }
216
217 /**
218 *
219 */
220 template<class CycleDataType>
221 INLINE void PipelineCycler<CycleDataType>::
222 operator = (const PipelineCycler<CycleDataType> &copy) {
223 _typed_data = copy._typed_data;
224 }
225
226 /**
227 * See PipelineCyclerBase::read_unlocked().
228 */
229 template<class CycleDataType>
230 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
231 read_unlocked(Thread *) const {
232 return &_typed_data;
233 }
234
235 /**
236 * See PipelineCyclerBase::read().
237 */
238 template<class CycleDataType>
239 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
240 read(Thread *) const {
241 return &_typed_data;
242 }
243
244 /**
245 * See PipelineCyclerBase::write().
246 */
247 template<class CycleDataType>
248 INLINE CycleDataType *PipelineCycler<CycleDataType>::
249 write(Thread *) {
250 return &_typed_data;
251 }
252
253 /**
254 * See PipelineCyclerBase::write_upstream().
255 */
256 template<class CycleDataType>
257 INLINE CycleDataType *PipelineCycler<CycleDataType>::
258 write_upstream(bool, Thread *) {
259 return &_typed_data;
260 }
261
262 /**
263 * See PipelineCyclerBase::elevate_read().
264 */
265 template<class CycleDataType>
266 INLINE CycleDataType *PipelineCycler<CycleDataType>::
267 elevate_read(const CycleDataType *, Thread *) {
268 return &_typed_data;
269 }
270
271 /**
272 * See PipelineCyclerBase::elevate_read_upstream().
273 */
274 template<class CycleDataType>
275 INLINE CycleDataType *PipelineCycler<CycleDataType>::
276 elevate_read_upstream(const CycleDataType *, bool, Thread *) {
277 return &_typed_data;
278 }
279
280 /**
281 * See PipelineCyclerBase::read_stage_unlocked().
282 */
283 template<class CycleDataType>
284 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
285 read_stage_unlocked(int) const {
286 return &_typed_data;
287 }
288
289 /**
290 * See PipelineCyclerBase::read_stage().
291 */
292 template<class CycleDataType>
293 INLINE const CycleDataType *PipelineCycler<CycleDataType>::
294 read_stage(int, Thread *) const {
295 return &_typed_data;
296 }
297
298 /**
299 * See PipelineCyclerBase::elevate_read_stage().
300 */
301 template<class CycleDataType>
302 INLINE CycleDataType *PipelineCycler<CycleDataType>::
303 elevate_read_stage(int, const CycleDataType *, Thread *) {
304 return &_typed_data;
305 }
306
307 /**
308 * See PipelineCyclerBase::elevate_read_stage_upstream().
309 */
310 template<class CycleDataType>
311 INLINE CycleDataType *PipelineCycler<CycleDataType>::
312 elevate_read_stage_upstream(int, const CycleDataType *, bool, Thread *) {
313 return &_typed_data;
314 }
315
316 /**
317 * See PipelineCyclerBase::write_stage().
318 */
319 template<class CycleDataType>
320 INLINE CycleDataType *PipelineCycler<CycleDataType>::
321 write_stage(int, Thread *) {
322 return &_typed_data;
323 }
324
325 /**
326 * See PipelineCyclerBase::write_stage_upstream().
327 */
328 template<class CycleDataType>
329 INLINE CycleDataType *PipelineCycler<CycleDataType>::
330 write_stage_upstream(int, bool, Thread *) {
331 return &_typed_data;
332 }
333
334 /**
335 * Returns a pointer without counting it. This is only intended for use as
336 * the return value for certain nassertr() functions, so the application can
337 * recover after a failure to manage the read and write pointers correctly.
338 * You should never call this function directly.
339 */
340 template<class CycleDataType>
341 INLINE CycleDataType *PipelineCycler<CycleDataType>::
342 cheat() const {
343 return (CycleDataType *)&_typed_data;
344 }
345
346
347 #endif // DO_PIPELINING
Pipeline
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition: pipeline.h:38
Thread
A thread; that is, a lightweight process.
Definition: thread.h:46
PipelineCyclerTrivialImpl
This is the trivial, non-threaded implementation of PipelineCyclerBase.
Definition: pipelineCyclerTrivialImpl.h:41
PipelineCyclerTrivialImpl::cheat
CycleData * cheat() const
Returns a pointer without counting it.
Definition: pipelineCyclerTrivialImpl.I:311
PipelineCyclerTrivialImpl::elevate_read_stage_upstream
CycleData * elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
Definition: pipelineCyclerTrivialImpl.I:280
PipelineCyclerTrivialImpl::read_stage_unlocked
const CycleData * read_stage_unlocked(int pipeline_stage) const
Returns a const CycleData pointer, filled with the data for the indicated stage of the pipeline.
Definition: pipelineCyclerTrivialImpl.I:201
PipelineCyclerTrivialImpl::elevate_read_upstream
CycleData * elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer, like elevate_read(), but also propagates...
Definition: pipelineCyclerTrivialImpl.I:164
PipelineCyclerTrivialImpl::elevate_read_stage
CycleData * elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
Definition: pipelineCyclerTrivialImpl.I:266
PipelineCyclerTrivialImpl::write
CycleData * write(Thread *current_thread)
Returns a non-const CycleData pointer, filled with a unique copy of the data for the current stage of...
Definition: pipelineCyclerTrivialImpl.I:107
PipelineCyclerTrivialImpl::read_unlocked
const CycleData * read_unlocked(Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the current stage of the pipeline as seen...
Definition: pipelineCyclerTrivialImpl.I:58
PipelineCyclerTrivialImpl::write_upstream
CycleData * write_upstream(bool force_to_0, Thread *current_thread)
This special variant on write() will automatically propagate changes back to upstream pipeline stages...
Definition: pipelineCyclerTrivialImpl.I:136
PipelineCyclerTrivialImpl::write_stage_upstream
CycleData * write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread)
Returns a pointer suitable for writing to the nth stage of the pipeline.
Definition: pipelineCyclerTrivialImpl.I:252
PipelineCyclerTrivialImpl::read
const CycleData * read(Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the current stage of the pipeline as seen...
Definition: pipelineCyclerTrivialImpl.I:72
PipelineCyclerTrivialImpl::read_stage
const CycleData * read_stage(int pipeline_stage, Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the indicated pipeline stage.
Definition: pipelineCyclerTrivialImpl.I:215
PipelineCyclerTrivialImpl::elevate_read
CycleData * elevate_read(const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
Definition: pipelineCyclerTrivialImpl.I:150
PipelineCyclerTrivialImpl::write_stage
CycleData * write_stage(int pipeline_stage, Thread *current_thread)
Returns a pointer suitable for writing to the nth stage of the pipeline.
Definition: pipelineCyclerTrivialImpl.I:237
PipelineCycler
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
Definition: pipelineCycler.h:46
PipelineCycler::read_stage
const CycleDataType * read_stage(int pipeline_stage, Thread *current_thread) const
See PipelineCyclerBase::read_stage().
Definition: pipelineCycler.I:294
PipelineCycler::cheat
CycleDataType * cheat() const
Returns a pointer without counting it.
Definition: pipelineCycler.I:342
PipelineCycler::elevate_read_stage_upstream
CycleDataType * elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::elevate_read_stage_upstream().
Definition: pipelineCycler.I:312
PipelineCycler::read_stage_unlocked
const CycleDataType * read_stage_unlocked(int pipeline_stage) const
See PipelineCyclerBase::read_stage_unlocked().
Definition: pipelineCycler.I:285
PipelineCycler::write_upstream
CycleDataType * write_upstream(bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::write_upstream().
Definition: pipelineCycler.I:258
PipelineCycler::write_stage_upstream
CycleDataType * write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::write_stage_upstream().
Definition: pipelineCycler.I:330
PipelineCycler::write
CycleDataType * write(Thread *current_thread)
See PipelineCyclerBase::write().
Definition: pipelineCycler.I:249
PipelineCycler::elevate_read_upstream
CycleDataType * elevate_read_upstream(const CycleDataType *pointer, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::elevate_read_upstream().
Definition: pipelineCycler.I:276
PipelineCycler::read
const CycleDataType * read(Thread *current_thread) const
See PipelineCyclerBase::read().
Definition: pipelineCycler.I:240
PipelineCycler::write_stage
CycleDataType * write_stage(int pipeline_stage, Thread *current_thread)
See PipelineCyclerBase::write_stage().
Definition: pipelineCycler.I:321
PipelineCycler::read_unlocked
const CycleDataType * read_unlocked(Thread *current_thread) const
See PipelineCyclerBase::read_unlocked().
Definition: pipelineCycler.I:231
PipelineCycler::elevate_read
CycleDataType * elevate_read(const CycleDataType *pointer, Thread *current_thread)
See PipelineCyclerBase::elevate_read().
Definition: pipelineCycler.I:267
PipelineCycler::elevate_read_stage
CycleDataType * elevate_read_stage(int pipeline_stage, const CycleDataType *pointer, Thread *current_thread)
See PipelineCyclerBase::elevate_read_stage().
Definition: pipelineCycler.I:303