Panda3D
 All Classes Functions Variables Enumerations
bufferContext.I
1 // Filename: bufferContext.I
2 // Created by: drose (16Mar06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: BufferContext::get_data_size_bytes
18 // Access: Public
19 // Description: Returns the number of bytes previously reported for
20 // the data object. This is used to track changes in
21 // the data object's allocated size; if it changes from
22 // this, we need to create a new buffer. This is also
23 // used to track memory utilization in PStats.
24 ////////////////////////////////////////////////////////////////////
25 INLINE size_t BufferContext::
27  return _data_size_bytes;
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: BufferContext::get_modified
32 // Access: Public
33 // Description: Returns the UpdateSeq that was recorded the last time
34 // mark_loaded() was called.
35 ////////////////////////////////////////////////////////////////////
37 get_modified() const {
38  return _modified;
39 }
40 
41 ////////////////////////////////////////////////////////////////////
42 // Function: BufferContext::get_active
43 // Access: Public
44 // Description: Returns the active flag associated with this object.
45 // An object is considered "active" if it was rendered
46 // in the current frame.
47 ////////////////////////////////////////////////////////////////////
48 INLINE bool BufferContext::
49 get_active() const {
50  return (_residency_state & BufferResidencyTracker::S_active) != 0;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: BufferContext::get_resident
55 // Access: Public
56 // Description: Returns the resident flag associated with this
57 // object. An object is considered "resident" if it
58 // appears to be resident in texture memory.
59 ////////////////////////////////////////////////////////////////////
60 INLINE bool BufferContext::
61 get_resident() const {
62  return (_residency_state & BufferResidencyTracker::S_resident) != 0;
63 }
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: BufferContext::set_active
67 // Access: Public
68 // Description: Changes the active flag associated with this object.
69 // An object is considered "active" if it was rendered
70 // in the current frame.
71 ////////////////////////////////////////////////////////////////////
72 INLINE void BufferContext::
73 set_active(bool flag) {
74  if (flag) {
75  _residency_state |= BufferResidencyTracker::S_active;
76  // Assume that rendering the object automatically makes it
77  // resident.
78  _residency_state |= BufferResidencyTracker::S_resident;
79  } else {
80  _residency_state &= ~BufferResidencyTracker::S_active;
81  }
82  set_owning_chain(&_residency->_chains[_residency_state]);
83 }
84 
85 ////////////////////////////////////////////////////////////////////
86 // Function: BufferContext::set_resident
87 // Access: Public
88 // Description: Changes the resident flag associated with this
89 // object. An object is considered "resident" if it
90 // appears to be resident in texture memory.
91 ////////////////////////////////////////////////////////////////////
92 INLINE void BufferContext::
93 set_resident(bool flag) {
94  if (flag) {
95  _residency_state |= BufferResidencyTracker::S_resident;
96  } else {
97  _residency_state &= ~BufferResidencyTracker::S_resident;
98  }
99  set_owning_chain(&_residency->_chains[_residency_state]);
100 }
101 
102 ////////////////////////////////////////////////////////////////////
103 // Function: BufferContext::get_next
104 // Access: Public
105 // Description: This can be used along with
106 // BufferContextChain::get_first() to walk through the
107 // list of objects stored on a tracker.
108 ////////////////////////////////////////////////////////////////////
110 get_next() const {
111  nassertr(_owning_chain != (BufferContextChain *)NULL, NULL);
112  if ((BufferContextChain *)_next == _owning_chain) {
113  return NULL;
114  }
115  return (BufferContext *)_next;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function: BufferContext::update_data_size_bytes
120 // Access: Public
121 // Description: Should be called (usually by a derived class) when
122 // the on-card size of this object has changed.
123 ////////////////////////////////////////////////////////////////////
124 INLINE void BufferContext::
125 update_data_size_bytes(size_t new_data_size_bytes) {
126  if (_owning_chain != (BufferContextChain *)NULL) {
127  _owning_chain->adjust_bytes((int)new_data_size_bytes - (int)_data_size_bytes);
128  }
129  _data_size_bytes = new_data_size_bytes;
130 }
131 
132 ////////////////////////////////////////////////////////////////////
133 // Function: BufferContext::update_modified
134 // Access: Public
135 // Description: Should be called (usually by a derived class) when
136 // the modified counter for this object has changed.
137 ////////////////////////////////////////////////////////////////////
138 INLINE void BufferContext::
139 update_modified(UpdateSeq new_modified) {
140  _modified = new_modified;
141 }
BufferContext * get_next() const
This can be used along with BufferContextChain::get_first() to walk through the list of objects store...
bool get_resident() const
Returns the resident flag associated with this object.
Definition: bufferContext.I:61
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:41
This class is used to keep track of the current state of all the BufferContexts for a particular grap...
void update_data_size_bytes(size_t new_data_size_bytes)
Should be called (usually by a derived class) when the on-card size of this object has changed...
This class maintains a linked list of BufferContexts that might be allocated on the graphics card in ...
size_t get_data_size_bytes() const
Returns the number of bytes previously reported for the data object.
Definition: bufferContext.I:26
void set_resident(bool flag)
Changes the resident flag associated with this object.
Definition: bufferContext.I:93
UpdateSeq get_modified() const
Returns the UpdateSeq that was recorded the last time mark_loaded() was called.
Definition: bufferContext.I:37
void set_active(bool flag)
Changes the active flag associated with this object.
Definition: bufferContext.I:73
bool get_active() const
Returns the active flag associated with this object.
Definition: bufferContext.I:49
void update_modified(UpdateSeq new_modified)
Should be called (usually by a derived class) when the modified counter for this object has changed...
This is a sequence number that increments monotonically.
Definition: updateSeq.h:43