15 #include "bufferResidencyTracker.h"
16 #include "bufferContext.h"
17 #include "clockObject.h"
20 PStatCollector BufferResidencyTracker::_gmem_collector(
"Graphics memory");
27 BufferResidencyTracker::
28 BufferResidencyTracker(
const string &pgo_name,
const string &type_name) :
29 _pgo_collector(_gmem_collector, pgo_name),
30 _active_resident_collector(
PStatCollector(_pgo_collector,
"Active"), type_name),
31 _active_nonresident_collector(
PStatCollector(_pgo_collector,
"Thrashing"), type_name),
32 _inactive_resident_collector(
PStatCollector(_pgo_collector,
"Inactive"), type_name),
33 _inactive_nonresident_collector(
PStatCollector(_pgo_collector,
"Nonresident"), type_name),
43 BufferResidencyTracker::
44 ~BufferResidencyTracker() {
45 _inactive_nonresident_collector.set_level(0);
46 _active_nonresident_collector.set_level(0);
47 _inactive_resident_collector.set_level(0);
48 _active_resident_collector.set_level(0);
60 if (_active_frame != this_frame) {
61 _active_frame = this_frame;
65 move_inactive(_chains[S_inactive_nonresident],
66 _chains[S_active_nonresident]);
67 move_inactive(_chains[S_inactive_resident],
68 _chains[S_active_resident]);
80 _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size());
81 _active_nonresident_collector.set_level(_chains[S_active_nonresident].get_total_size());
82 _inactive_resident_collector.set_level(_chains[S_inactive_resident].get_total_size());
83 _active_resident_collector.set_level(_chains[S_active_resident].get_total_size());
94 _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size());
95 _active_nonresident_collector.set_level(_chains[S_active_nonresident].get_total_size());
96 _inactive_resident_collector.set_level(_chains[S_inactive_resident].get_total_size());
97 _active_resident_collector.set_level(_chains[S_active_resident].get_total_size());
105 void BufferResidencyTracker::
106 write(ostream &out,
int indent_level)
const {
107 if (_chains[S_inactive_nonresident].get_count() != 0) {
108 indent(out, indent_level) <<
"Inactive nonresident:\n";
109 _chains[S_inactive_nonresident].write(out, indent_level + 2);
112 if (_chains[S_active_nonresident].get_count() != 0) {
113 indent(out, indent_level) <<
"Active nonresident:\n";
114 _chains[S_active_nonresident].write(out, indent_level + 2);
117 if (_chains[S_inactive_resident].get_count() != 0) {
118 indent(out, indent_level) <<
"Inactive resident:\n";
119 _chains[S_inactive_resident].write(out, indent_level + 2);
122 if (_chains[S_active_resident].get_count() != 0) {
123 indent(out, indent_level) <<
"Active resident:\n";
124 _chains[S_active_resident].write(out, indent_level + 2);
133 void BufferResidencyTracker::
137 nassertv((node->_residency_state & S_active) != 0);
138 node->_residency_state &= ~S_active;
static ClockObject * get_global_clock()
Returns a pointer to the global ClockObject.
BufferContext * get_next() const
This can be used along with BufferContextChain::get_first() to walk through the list of objects store...
void set_levels()
Resets the pstats levels to their appropriate values, possibly in the middle of a frame...
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
A lightweight class that represents a single element that may be timed and/or counted via stats...
BufferContext * get_first()
Returns the first BufferContext object stored in the tracker.
int get_frame_count(Thread *current_thread=Thread::get_current_thread()) const
Returns the number of times tick() has been called since the ClockObject was created, or since it was last reset.
A thread; that is, a lightweight process.
void take_from(BufferContextChain &other)
Moves all of the BufferContexts from the other tracker onto this one.
void begin_frame(Thread *current_thread)
To be called at the beginning of a frame, this initializes the active/inactive status.
void end_frame(Thread *current_thread)
To be called at the end of a frame, this updates the PStatCollectors appropriately.