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