Panda3D
Loading...
Searching...
No Matches
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 */
21template<class CycleDataType>
23PipelineCycler(Pipeline *pipeline) :
24 PipelineCyclerBase(new CycleDataType, pipeline)
25{
26}
27
28/**
29 *
30 */
31template<class CycleDataType>
33PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) :
34 PipelineCyclerBase(new CycleDataType(std::move(initial_data)), pipeline)
35{
36}
37
38/**
39 *
40 */
41template<class CycleDataType>
45{
46}
47
48/**
49 *
50 */
51template<class CycleDataType>
54 PipelineCyclerBase::operator = (copy);
57/**
58 * See PipelineCyclerBase::read_unlocked().
59 */
60template<class CycleDataType>
61INLINE const CycleDataType *PipelineCycler<CycleDataType>::
62read_unlocked(Thread *current_thread) const {
63 return (const CycleDataType *)PipelineCyclerBase::read_unlocked(current_thread);
66/**
67 * See PipelineCyclerBase::read().
68 */
69template<class CycleDataType>
70INLINE const CycleDataType *PipelineCycler<CycleDataType>::
71read(Thread *current_thread) const {
72 return (const CycleDataType *)PipelineCyclerBase::read(current_thread);
73}
74
75/**
76 * See PipelineCyclerBase::write().
77 */
78template<class CycleDataType>
79INLINE CycleDataType *PipelineCycler<CycleDataType>::
80write(Thread *current_thread) {
81 return (CycleDataType *)PipelineCyclerBase::write(current_thread);
82}
83
84/**
85 * See PipelineCyclerBase::write_upstream().
86 */
87template<class CycleDataType>
88INLINE CycleDataType *PipelineCycler<CycleDataType>::
89write_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 */
96template<class CycleDataType>
97INLINE CycleDataType *PipelineCycler<CycleDataType>::
98elevate_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 */
105template<class CycleDataType>
106INLINE CycleDataType *PipelineCycler<CycleDataType>::
107elevate_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 */
115template<class CycleDataType>
116INLINE const CycleDataType *PipelineCycler<CycleDataType>::
117read_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 */
124template<class CycleDataType>
125INLINE const CycleDataType *PipelineCycler<CycleDataType>::
126read_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 */
133template<class CycleDataType>
134INLINE CycleDataType *PipelineCycler<CycleDataType>::
135elevate_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 */
143template<class CycleDataType>
144INLINE CycleDataType *PipelineCycler<CycleDataType>::
145elevate_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 */
153template<class CycleDataType>
154INLINE CycleDataType *PipelineCycler<CycleDataType>::
155write_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 */
162template<class CycleDataType>
163INLINE CycleDataType *PipelineCycler<CycleDataType>::
164write_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 */
175template<class CycleDataType>
176INLINE CycleDataType *PipelineCycler<CycleDataType>::
177cheat() 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 */
188template<class CycleDataType>
190PipelineCycler(Pipeline *pipeline) :
191 PipelineCyclerBase(&_typed_data, pipeline)
192{
193}
194
195/**
196 *
197 */
198template<class CycleDataType>
200PipelineCycler(CycleDataType &&initial_data, Pipeline *pipeline) :
201 _typed_data(std::move(initial_data)),
202 PipelineCyclerBase(&_typed_data, pipeline)
203{
204}
205
206/**
207 *
208 */
209template<class CycleDataType>
212 PipelineCyclerBase(&_typed_data),
213 _typed_data(copy._typed_data)
214{
215}
216
217/**
218 *
219 */
220template<class CycleDataType>
223 _typed_data = copy._typed_data;
224}
225
226/**
227 * See PipelineCyclerBase::read_unlocked().
228 */
229template<class CycleDataType>
230INLINE const CycleDataType *PipelineCycler<CycleDataType>::
231read_unlocked(Thread *) const {
232 return &_typed_data;
233}
234
235/**
236 * See PipelineCyclerBase::read().
237 */
238template<class CycleDataType>
239INLINE const CycleDataType *PipelineCycler<CycleDataType>::
240read(Thread *) const {
241 return &_typed_data;
242}
243
244/**
245 * See PipelineCyclerBase::write().
246 */
247template<class CycleDataType>
249write(Thread *) {
250 return &_typed_data;
251}
252
253/**
254 * See PipelineCyclerBase::write_upstream().
255 */
256template<class CycleDataType>
258write_upstream(bool, Thread *) {
259 return &_typed_data;
260}
261
262/**
263 * See PipelineCyclerBase::elevate_read().
264 */
265template<class CycleDataType>
267elevate_read(const CycleDataType *, Thread *) {
268 return &_typed_data;
269}
270
271/**
272 * See PipelineCyclerBase::elevate_read_upstream().
273 */
274template<class CycleDataType>
276elevate_read_upstream(const CycleDataType *, bool, Thread *) {
277 return &_typed_data;
278}
279
280/**
281 * See PipelineCyclerBase::read_stage_unlocked().
282 */
283template<class CycleDataType>
284INLINE const CycleDataType *PipelineCycler<CycleDataType>::
285read_stage_unlocked(int) const {
286 return &_typed_data;
287}
288
289/**
290 * See PipelineCyclerBase::read_stage().
291 */
292template<class CycleDataType>
293INLINE const CycleDataType *PipelineCycler<CycleDataType>::
294read_stage(int, Thread *) const {
295 return &_typed_data;
296}
297
298/**
299 * See PipelineCyclerBase::elevate_read_stage().
300 */
301template<class CycleDataType>
303elevate_read_stage(int, const CycleDataType *, Thread *) {
304 return &_typed_data;
305}
306
307/**
308 * See PipelineCyclerBase::elevate_read_stage_upstream().
309 */
310template<class CycleDataType>
312elevate_read_stage_upstream(int, const CycleDataType *, bool, Thread *) {
313 return &_typed_data;
314}
315
316/**
317 * See PipelineCyclerBase::write_stage().
318 */
319template<class CycleDataType>
321write_stage(int, Thread *) {
322 return &_typed_data;
323}
324
325/**
326 * See PipelineCyclerBase::write_stage_upstream().
327 */
328template<class CycleDataType>
330write_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 */
340template<class CycleDataType>
342cheat() const {
343 return (CycleDataType *)&_typed_data;
344}
345
346
347#endif // DO_PIPELINING
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition pipeline.h:38
A thread; that is, a lightweight process.
Definition thread.h:46
STL namespace.
This is the trivial, non-threaded implementation of PipelineCyclerBase.
CycleData * cheat() const
Returns a pointer without counting it.
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.
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.
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...
CycleData * elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
CycleData * write(Thread *current_thread)
Returns a non-const CycleData pointer, filled with a unique copy of the data for the current stage of...
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...
CycleData * write_upstream(bool force_to_0, Thread *current_thread)
This special variant on write() will automatically propagate changes back to upstream pipeline stages...
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.
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...
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.
CycleData * elevate_read(const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
CycleData * write_stage(int pipeline_stage, Thread *current_thread)
Returns a pointer suitable for writing to the nth stage of the pipeline.
This class maintains different copies of a page of data between stages of the graphics pipeline (or a...
const CycleDataType * read_stage(int pipeline_stage, Thread *current_thread) const
See PipelineCyclerBase::read_stage().
CycleDataType * cheat() const
Returns a pointer without counting it.
CycleDataType * elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::elevate_read_stage_upstream().
const CycleDataType * read_stage_unlocked(int pipeline_stage) const
See PipelineCyclerBase::read_stage_unlocked().
CycleDataType * write_upstream(bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::write_upstream().
CycleDataType * write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::write_stage_upstream().
CycleDataType * write(Thread *current_thread)
See PipelineCyclerBase::write().
CycleDataType * elevate_read_upstream(const CycleDataType *pointer, bool force_to_0, Thread *current_thread)
See PipelineCyclerBase::elevate_read_upstream().
const CycleDataType * read(Thread *current_thread) const
See PipelineCyclerBase::read().
CycleDataType * write_stage(int pipeline_stage, Thread *current_thread)
See PipelineCyclerBase::write_stage().
const CycleDataType * read_unlocked(Thread *current_thread) const
See PipelineCyclerBase::read_unlocked().
CycleDataType * elevate_read(const CycleDataType *pointer, Thread *current_thread)
See PipelineCyclerBase::elevate_read().
CycleDataType * elevate_read_stage(int pipeline_stage, const CycleDataType *pointer, Thread *current_thread)
See PipelineCyclerBase::elevate_read_stage().