00001 // Filename: pipelineCycler.I 00002 // Created by: drose (21Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 #ifdef DO_PIPELINING 00017 // The following implementations are to support the 00018 // PipelineCyclerDummyImpl or the PipelineCyclerTrueImpl. 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: PipelineCycler::Constructor (dummy or true) 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 template<class CycleDataType> 00026 INLINE PipelineCycler<CycleDataType>:: 00027 PipelineCycler(Pipeline *pipeline) : 00028 PipelineCyclerBase(new CycleDataType, pipeline) 00029 { 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: PipelineCycler::Copy Constructor (dummy or true) 00034 // Access: Public 00035 // Description: 00036 //////////////////////////////////////////////////////////////////// 00037 template<class CycleDataType> 00038 INLINE PipelineCycler<CycleDataType>:: 00039 PipelineCycler(const PipelineCycler<CycleDataType> ©) : 00040 PipelineCyclerBase(copy) 00041 { 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: PipelineCycler::Copy Assignment (dummy or true) 00046 // Access: Public 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 template<class CycleDataType> 00050 INLINE void PipelineCycler<CycleDataType>:: 00051 operator = (const PipelineCycler<CycleDataType> ©) { 00052 PipelineCyclerBase::operator = (copy); 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: PipelineCycler::read_unlocked (dummy or true) 00057 // Access: Public 00058 // Description: See PipelineCyclerBase::read_unlocked(). 00059 //////////////////////////////////////////////////////////////////// 00060 template<class CycleDataType> 00061 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00062 read_unlocked(Thread *current_thread) const { 00063 return (const CycleDataType *)PipelineCyclerBase::read_unlocked(current_thread); 00064 } 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Function: PipelineCycler::read (dummy or true) 00068 // Access: Public 00069 // Description: See PipelineCyclerBase::read(). 00070 //////////////////////////////////////////////////////////////////// 00071 template<class CycleDataType> 00072 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00073 read(Thread *current_thread) const { 00074 return (const CycleDataType *)PipelineCyclerBase::read(current_thread); 00075 } 00076 00077 //////////////////////////////////////////////////////////////////// 00078 // Function: PipelineCycler::write (dummy or true) 00079 // Access: Public 00080 // Description: See PipelineCyclerBase::write(). 00081 //////////////////////////////////////////////////////////////////// 00082 template<class CycleDataType> 00083 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00084 write(Thread *current_thread) { 00085 return (CycleDataType *)PipelineCyclerBase::write(current_thread); 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: PipelineCycler::write_upstream (dummy or true) 00090 // Access: Public 00091 // Description: See PipelineCyclerBase::write_upstream(). 00092 //////////////////////////////////////////////////////////////////// 00093 template<class CycleDataType> 00094 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00095 write_upstream(bool force_to_0, Thread *current_thread) { 00096 return (CycleDataType *)PipelineCyclerBase::write_upstream(force_to_0, current_thread); 00097 } 00098 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: PipelineCycler::elevate_read (dummy or true) 00101 // Access: Public 00102 // Description: See PipelineCyclerBase::elevate_read(). 00103 //////////////////////////////////////////////////////////////////// 00104 template<class CycleDataType> 00105 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00106 elevate_read(const CycleDataType *pointer, Thread *current_thread) { 00107 return (CycleDataType *)PipelineCyclerBase::elevate_read(pointer, current_thread); 00108 } 00109 00110 //////////////////////////////////////////////////////////////////// 00111 // Function: PipelineCycler::elevate_read_upstream (dummy or true) 00112 // Access: Public 00113 // Description: See PipelineCyclerBase::elevate_read_upstream(). 00114 //////////////////////////////////////////////////////////////////// 00115 template<class CycleDataType> 00116 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00117 elevate_read_upstream(const CycleDataType *pointer, bool force_to_0, 00118 Thread *current_thread) { 00119 return (CycleDataType *)PipelineCyclerBase::elevate_read_upstream(pointer, force_to_0, current_thread); 00120 } 00121 00122 //////////////////////////////////////////////////////////////////// 00123 // Function: PipelineCycler::read_stage_unlocked (dummy or true) 00124 // Access: Public 00125 // Description: See PipelineCyclerBase::read_stage_unlocked(). 00126 //////////////////////////////////////////////////////////////////// 00127 template<class CycleDataType> 00128 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00129 read_stage_unlocked(int pipeline_stage) const { 00130 return (const CycleDataType *)PipelineCyclerBase::read_stage_unlocked(pipeline_stage); 00131 } 00132 00133 //////////////////////////////////////////////////////////////////// 00134 // Function: PipelineCycler::read_stage (dummy or true) 00135 // Access: Public 00136 // Description: See PipelineCyclerBase::read_stage(). 00137 //////////////////////////////////////////////////////////////////// 00138 template<class CycleDataType> 00139 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00140 read_stage(int pipeline_stage, Thread *current_thread) const { 00141 return (const CycleDataType *)PipelineCyclerBase::read_stage(pipeline_stage, current_thread); 00142 } 00143 00144 //////////////////////////////////////////////////////////////////// 00145 // Function: PipelineCycler::elevate_read_stage (dummy or true) 00146 // Access: Public 00147 // Description: See PipelineCyclerBase::elevate_read_stage(). 00148 //////////////////////////////////////////////////////////////////// 00149 template<class CycleDataType> 00150 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00151 elevate_read_stage(int pipeline_stage, const CycleDataType *pointer, 00152 Thread *current_thread) { 00153 return (CycleDataType *)PipelineCyclerBase::elevate_read_stage(pipeline_stage, pointer, current_thread); 00154 } 00155 00156 //////////////////////////////////////////////////////////////////// 00157 // Function: PipelineCycler::elevate_read_stage_upstream (dummy or true) 00158 // Access: Public 00159 // Description: See PipelineCyclerBase::elevate_read_stage_upstream(). 00160 //////////////////////////////////////////////////////////////////// 00161 template<class CycleDataType> 00162 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00163 elevate_read_stage_upstream(int pipeline_stage, const CycleDataType *pointer, 00164 bool force_to_0, Thread *current_thread) { 00165 return (CycleDataType *)PipelineCyclerBase::elevate_read_stage_upstream(pipeline_stage, pointer, force_to_0, current_thread); 00166 } 00167 00168 //////////////////////////////////////////////////////////////////// 00169 // Function: PipelineCycler::write_stage (dummy or true) 00170 // Access: Public 00171 // Description: See PipelineCyclerBase::write_stage(). 00172 //////////////////////////////////////////////////////////////////// 00173 template<class CycleDataType> 00174 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00175 write_stage(int pipeline_stage, Thread *current_thread) { 00176 return (CycleDataType *)PipelineCyclerBase::write_stage(pipeline_stage, current_thread); 00177 } 00178 00179 //////////////////////////////////////////////////////////////////// 00180 // Function: PipelineCycler::write_stage_upstream (dummy or true) 00181 // Access: Public 00182 // Description: See PipelineCyclerBase::write_stage_upstream(). 00183 //////////////////////////////////////////////////////////////////// 00184 template<class CycleDataType> 00185 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00186 write_stage_upstream(int pipeline_stage, bool force_to_0, 00187 Thread *current_thread) { 00188 return (CycleDataType *)PipelineCyclerBase::write_stage_upstream(pipeline_stage, force_to_0, current_thread); 00189 } 00190 00191 //////////////////////////////////////////////////////////////////// 00192 // Function: PipelineCycler::cheat (dummy or true) 00193 // Access: Public 00194 // Description: Returns a pointer without counting it. This is only 00195 // intended for use as the return value for certain 00196 // nassertr() functions, so the application can recover 00197 // after a failure to manage the read and write pointers 00198 // correctly. You should never call this function 00199 // directly. 00200 //////////////////////////////////////////////////////////////////// 00201 template<class CycleDataType> 00202 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00203 cheat() const { 00204 return (CycleDataType *)PipelineCyclerBase::cheat(); 00205 } 00206 00207 #else // !DO_PIPELINING 00208 // The following implementations are provided for when pipelining is 00209 // not compiled in. They are trivial functions that do as little as 00210 // possible. 00211 00212 //////////////////////////////////////////////////////////////////// 00213 // Function: PipelineCycler::Constructor (trivial) 00214 // Access: Public 00215 // Description: 00216 //////////////////////////////////////////////////////////////////// 00217 template<class CycleDataType> 00218 INLINE PipelineCycler<CycleDataType>:: 00219 PipelineCycler(Pipeline *pipeline) : 00220 PipelineCyclerBase(&_typed_data, pipeline) 00221 { 00222 } 00223 00224 //////////////////////////////////////////////////////////////////// 00225 // Function: PipelineCycler::Copy Constructor (trivial) 00226 // Access: Public 00227 // Description: 00228 //////////////////////////////////////////////////////////////////// 00229 template<class CycleDataType> 00230 INLINE PipelineCycler<CycleDataType>:: 00231 PipelineCycler(const PipelineCycler<CycleDataType> ©) : 00232 PipelineCyclerBase(&_typed_data), 00233 _typed_data(copy._typed_data) 00234 { 00235 } 00236 00237 //////////////////////////////////////////////////////////////////// 00238 // Function: PipelineCycler::Copy Assignment (trivial) 00239 // Access: Public 00240 // Description: 00241 //////////////////////////////////////////////////////////////////// 00242 template<class CycleDataType> 00243 INLINE void PipelineCycler<CycleDataType>:: 00244 operator = (const PipelineCycler<CycleDataType> ©) { 00245 _typed_data = copy._typed_data; 00246 } 00247 00248 //////////////////////////////////////////////////////////////////// 00249 // Function: PipelineCycler::read_unlocked (trivial) 00250 // Access: Public 00251 // Description: See PipelineCyclerBase::read_unlocked(). 00252 //////////////////////////////////////////////////////////////////// 00253 template<class CycleDataType> 00254 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00255 read_unlocked(Thread *) const { 00256 return &_typed_data; 00257 } 00258 00259 //////////////////////////////////////////////////////////////////// 00260 // Function: PipelineCycler::read (trivial) 00261 // Access: Public 00262 // Description: See PipelineCyclerBase::read(). 00263 //////////////////////////////////////////////////////////////////// 00264 template<class CycleDataType> 00265 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00266 read(Thread *) const { 00267 return &_typed_data; 00268 } 00269 00270 //////////////////////////////////////////////////////////////////// 00271 // Function: PipelineCycler::write (trivial) 00272 // Access: Public 00273 // Description: See PipelineCyclerBase::write(). 00274 //////////////////////////////////////////////////////////////////// 00275 template<class CycleDataType> 00276 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00277 write(Thread *) { 00278 return &_typed_data; 00279 } 00280 00281 //////////////////////////////////////////////////////////////////// 00282 // Function: PipelineCycler::write_upstream (trivial) 00283 // Access: Public 00284 // Description: See PipelineCyclerBase::write_upstream(). 00285 //////////////////////////////////////////////////////////////////// 00286 template<class CycleDataType> 00287 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00288 write_upstream(bool, Thread *) { 00289 return &_typed_data; 00290 } 00291 00292 //////////////////////////////////////////////////////////////////// 00293 // Function: PipelineCycler::elevate_read (trivial) 00294 // Access: Public 00295 // Description: See PipelineCyclerBase::elevate_read(). 00296 //////////////////////////////////////////////////////////////////// 00297 template<class CycleDataType> 00298 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00299 elevate_read(const CycleDataType *, Thread *) { 00300 return &_typed_data; 00301 } 00302 00303 //////////////////////////////////////////////////////////////////// 00304 // Function: PipelineCycler::elevate_read_upstream (trivial) 00305 // Access: Public 00306 // Description: See PipelineCyclerBase::elevate_read_upstream(). 00307 //////////////////////////////////////////////////////////////////// 00308 template<class CycleDataType> 00309 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00310 elevate_read_upstream(const CycleDataType *, bool, Thread *) { 00311 return &_typed_data; 00312 } 00313 00314 //////////////////////////////////////////////////////////////////// 00315 // Function: PipelineCycler::read_stage_unlocked (trivial) 00316 // Access: Public 00317 // Description: See PipelineCyclerBase::read_stage_unlocked(). 00318 //////////////////////////////////////////////////////////////////// 00319 template<class CycleDataType> 00320 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00321 read_stage_unlocked(int) const { 00322 return &_typed_data; 00323 } 00324 00325 //////////////////////////////////////////////////////////////////// 00326 // Function: PipelineCycler::read_stage (trivial) 00327 // Access: Public 00328 // Description: See PipelineCyclerBase::read_stage(). 00329 //////////////////////////////////////////////////////////////////// 00330 template<class CycleDataType> 00331 INLINE const CycleDataType *PipelineCycler<CycleDataType>:: 00332 read_stage(int, Thread *) const { 00333 return &_typed_data; 00334 } 00335 00336 //////////////////////////////////////////////////////////////////// 00337 // Function: PipelineCycler::elevate_read_stage (trivial) 00338 // Access: Public 00339 // Description: See PipelineCyclerBase::elevate_read_stage(). 00340 //////////////////////////////////////////////////////////////////// 00341 template<class CycleDataType> 00342 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00343 elevate_read_stage(int, const CycleDataType *, Thread *) { 00344 return &_typed_data; 00345 } 00346 00347 //////////////////////////////////////////////////////////////////// 00348 // Function: PipelineCycler::elevate_read_stage_upstream (trivial) 00349 // Access: Public 00350 // Description: See PipelineCyclerBase::elevate_read_stage_upstream(). 00351 //////////////////////////////////////////////////////////////////// 00352 template<class CycleDataType> 00353 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00354 elevate_read_stage_upstream(int, const CycleDataType *, bool, Thread *) { 00355 return &_typed_data; 00356 } 00357 00358 //////////////////////////////////////////////////////////////////// 00359 // Function: PipelineCycler::write_stage (trivial) 00360 // Access: Public 00361 // Description: See PipelineCyclerBase::write_stage(). 00362 //////////////////////////////////////////////////////////////////// 00363 template<class CycleDataType> 00364 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00365 write_stage(int, Thread *) { 00366 return &_typed_data; 00367 } 00368 00369 //////////////////////////////////////////////////////////////////// 00370 // Function: PipelineCycler::write_stage_upstream (trivial) 00371 // Access: Public 00372 // Description: See PipelineCyclerBase::write_stage_upstream(). 00373 //////////////////////////////////////////////////////////////////// 00374 template<class CycleDataType> 00375 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00376 write_stage_upstream(int, bool, Thread *) { 00377 return &_typed_data; 00378 } 00379 00380 //////////////////////////////////////////////////////////////////// 00381 // Function: PipelineCycler::cheat (trivial) 00382 // Access: Public 00383 // Description: Returns a pointer without counting it. This is only 00384 // intended for use as the return value for certain 00385 // nassertr() functions, so the application can recover 00386 // after a failure to manage the read and write pointers 00387 // correctly. You should never call this function 00388 // directly. 00389 //////////////////////////////////////////////////////////////////// 00390 template<class CycleDataType> 00391 INLINE CycleDataType *PipelineCycler<CycleDataType>:: 00392 cheat() const { 00393 return (CycleDataType *)&_typed_data; 00394 } 00395 00396 00397 #endif // DO_PIPELINING