19 PStatCollector BufferResidencyTracker::_gmem_collector(
"Graphics memory");
24 BufferResidencyTracker::
25 BufferResidencyTracker(
const std::string &pgo_name,
const std::string &type_name) :
26 _pgo_collector(_gmem_collector, pgo_name),
27 _active_resident_collector(
PStatCollector(_pgo_collector,
"Active"), type_name),
28 _active_nonresident_collector(
PStatCollector(_pgo_collector,
"Thrashing"), type_name),
29 _inactive_resident_collector(
PStatCollector(_pgo_collector,
"Inactive"), type_name),
30 _inactive_nonresident_collector(
PStatCollector(_pgo_collector,
"Nonresident"), type_name),
38 BufferResidencyTracker::
39 ~BufferResidencyTracker() {
40 _inactive_nonresident_collector.set_level(0);
41 _active_nonresident_collector.set_level(0);
42 _inactive_resident_collector.set_level(0);
43 _active_resident_collector.set_level(0);
53 if (_active_frame != this_frame) {
54 _active_frame = this_frame;
58 move_inactive(_chains[S_inactive_nonresident],
59 _chains[S_active_nonresident]);
60 move_inactive(_chains[S_inactive_resident],
61 _chains[S_active_resident]);
71 _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size());
72 _active_nonresident_collector.set_level(_chains[S_active_nonresident].get_total_size());
73 _inactive_resident_collector.set_level(_chains[S_inactive_resident].get_total_size());
74 _active_resident_collector.set_level(_chains[S_active_resident].get_total_size());
83 _inactive_nonresident_collector.set_level(_chains[S_inactive_nonresident].get_total_size());
84 _active_nonresident_collector.set_level(_chains[S_active_nonresident].get_total_size());
85 _inactive_resident_collector.set_level(_chains[S_inactive_resident].get_total_size());
86 _active_resident_collector.set_level(_chains[S_active_resident].get_total_size());
92 void BufferResidencyTracker::
93 write(std::ostream &out,
int indent_level)
const {
94 if (_chains[S_inactive_nonresident].get_count() != 0) {
95 indent(out, indent_level) <<
"Inactive nonresident:\n";
96 _chains[S_inactive_nonresident].write(out, indent_level + 2);
99 if (_chains[S_active_nonresident].get_count() != 0) {
100 indent(out, indent_level) <<
"Active nonresident:\n";
101 _chains[S_active_nonresident].write(out, indent_level + 2);
104 if (_chains[S_inactive_resident].get_count() != 0) {
105 indent(out, indent_level) <<
"Inactive resident:\n";
106 _chains[S_inactive_resident].write(out, indent_level + 2);
109 if (_chains[S_active_resident].get_count() != 0) {
110 indent(out, indent_level) <<
"Active resident:\n";
111 _chains[S_active_resident].write(out, indent_level + 2);
118 void BufferResidencyTracker::
121 while (node !=
nullptr) {
122 nassertv((node->_residency_state & S_active) != 0);
123 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...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
get_frame_count
Returns the number of times tick() has been called since the ClockObject was created,...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.