Panda3D
|
00001 // Filename: pipeline.h 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 #ifndef PIPELINE_H 00016 #define PIPELINE_H 00017 00018 #include "pandabase.h" 00019 #include "pipelineCyclerLinks.h" 00020 #include "namable.h" 00021 #include "pset.h" 00022 #include "reMutex.h" 00023 #include "reMutexHolder.h" 00024 #include "selectThreadImpl.h" // for THREADED_PIPELINE definition 00025 00026 struct PipelineCyclerTrueImpl; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : Pipeline 00030 // Description : This class manages a staged pipeline of data, for 00031 // instance the render pipeline, so that each stage of 00032 // the pipeline can simultaneously access different 00033 // copies of the same data. It actually maintains a 00034 // collection of PipelineCycler objects, and manages the 00035 // turning of all of them at once. 00036 // 00037 // There is one default Pipeline object, the render 00038 // pipeline. Other specialty pipelines may be created 00039 // as needed. 00040 //////////////////////////////////////////////////////////////////// 00041 class EXPCL_PANDA_PIPELINE Pipeline : public Namable { 00042 public: 00043 Pipeline(const string &name, int num_stages); 00044 ~Pipeline(); 00045 00046 INLINE static Pipeline *get_render_pipeline(); 00047 00048 void cycle(); 00049 00050 void set_num_stages(int num_stages); 00051 INLINE void set_min_stages(int min_stages); 00052 INLINE int get_num_stages() const; 00053 00054 #ifdef THREADED_PIPELINE 00055 void add_cycler(PipelineCyclerTrueImpl *cycler); 00056 void add_dirty_cycler(PipelineCyclerTrueImpl *cycler); 00057 void remove_cycler(PipelineCyclerTrueImpl *cycler); 00058 00059 INLINE int get_num_cyclers() const; 00060 INLINE int get_num_dirty_cyclers() const; 00061 00062 #ifdef DEBUG_THREADS 00063 typedef void CallbackFunc(TypeHandle type, int count, void *data); 00064 void iterate_all_cycler_types(CallbackFunc *func, void *data) const; 00065 void iterate_dirty_cycler_types(CallbackFunc *func, void *data) const; 00066 #endif // DEBUG_THREADS 00067 00068 #endif // THREADED_PIPELINE 00069 00070 private: 00071 int _num_stages; 00072 00073 static void make_render_pipeline(); 00074 static Pipeline *_render_pipeline; 00075 00076 #ifdef THREADED_PIPELINE 00077 PipelineCyclerLinks _clean; 00078 PipelineCyclerLinks _dirty; 00079 00080 int _num_cyclers; 00081 int _num_dirty_cyclers; 00082 00083 #ifdef DEBUG_THREADS 00084 typedef pmap<TypeHandle, int> TypeCount; 00085 TypeCount _all_cycler_types, _dirty_cycler_types; 00086 00087 static void inc_cycler_type(TypeCount &count, TypeHandle type, int addend); 00088 #endif // DEBUG_THREADS 00089 00090 // This is true only during cycle(). 00091 bool _cycling; 00092 00093 ReMutex _lock; 00094 #endif // THREADED_PIPELINE 00095 }; 00096 00097 #include "pipeline.I" 00098 00099 #endif 00100