00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef BUFFERRESIDENCYTRACKER_H
00016 #define BUFFERRESIDENCYTRACKER_H
00017
00018 #include "pandabase.h"
00019 #include "bufferContextChain.h"
00020 #include "pStatCollector.h"
00021
00022 class BufferContext;
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class EXPCL_PANDA_GOBJ BufferResidencyTracker {
00037 public:
00038 BufferResidencyTracker(const string &pgo_name, const string &type_name);
00039 ~BufferResidencyTracker();
00040
00041 void begin_frame(Thread *current_thread);
00042 void end_frame(Thread *current_thread);
00043 void set_levels();
00044
00045 INLINE BufferContextChain &get_inactive_nonresident();
00046 INLINE BufferContextChain &get_active_nonresident();
00047 INLINE BufferContextChain &get_inactive_resident();
00048 INLINE BufferContextChain &get_active_resident();
00049
00050 void write(ostream &out, int indent_level) const;
00051
00052 private:
00053 void move_inactive(BufferContextChain &inactive, BufferContextChain &active);
00054
00055 private:
00056 enum State {
00057
00058 S_active = 0x01,
00059 S_resident = 0x02,
00060
00061
00062 S_inactive_nonresident = 0x00,
00063 S_active_nonresident = 0x01,
00064 S_inactive_resident = 0x02,
00065 S_active_resident = 0x03,
00066
00067
00068 S_num_states = 4,
00069 };
00070
00071
00072 BufferContextChain _chains[S_num_states];
00073
00074
00075 static PStatCollector _gmem_collector;
00076 PStatCollector _pgo_collector;
00077
00078
00079
00080 PStatCollector _active_resident_collector;
00081 PStatCollector _active_nonresident_collector;
00082 PStatCollector _inactive_resident_collector;
00083 PStatCollector _inactive_nonresident_collector;
00084
00085
00086 int _active_frame;
00087 friend class BufferContext;
00088 };
00089
00090 #include "bufferResidencyTracker.I"
00091
00092 #endif