Panda3D
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 associated object.
16  */
17 INLINE TypedWritableReferenceCount *BufferContext::
18 get_object() const {
19  return _object;
20 }
21 
22 /**
23  * Returns the number of bytes previously reported for the data object. This
24  * is used to track changes in the data object's allocated size; if it changes
25  * from this, we need to create a new buffer. This is also used to track
26  * memory utilization in PStats.
27  */
28 INLINE size_t BufferContext::
29 get_data_size_bytes() const {
30  return _data_size_bytes;
31 }
32 
33 /**
34  * Returns the UpdateSeq that was recorded the last time mark_loaded() was
35  * called.
36  */
37 INLINE UpdateSeq BufferContext::
38 get_modified() const {
39  return _modified;
40 }
41 
42 /**
43  * Returns the active flag associated with this object. An object is
44  * considered "active" if it was rendered in the current frame.
45  */
46 INLINE bool BufferContext::
47 get_active() const {
48  return (_residency_state & BufferResidencyTracker::S_active) != 0;
49 }
50 
51 /**
52  * Returns the resident flag associated with this object. An object is
53  * considered "resident" if it appears to be resident in texture memory.
54  */
55 INLINE bool BufferContext::
56 get_resident() const {
57  return (_residency_state & BufferResidencyTracker::S_resident) != 0;
58 }
59 
60 /**
61  * Changes the active flag associated with this object. An object is
62  * considered "active" if it was rendered in the current frame.
63  */
64 INLINE void BufferContext::
65 set_active(bool flag) {
66  if (flag) {
67  _residency_state |= BufferResidencyTracker::S_active;
68  // Assume that rendering the object automatically makes it resident.
69  _residency_state |= BufferResidencyTracker::S_resident;
70  } else {
71  _residency_state &= ~BufferResidencyTracker::S_active;
72  }
73  set_owning_chain(&_residency->_chains[_residency_state]);
74 }
75 
76 /**
77  * Changes the resident flag associated with this object. An object is
78  * considered "resident" if it appears to be resident in texture memory.
79  */
80 INLINE void BufferContext::
81 set_resident(bool flag) {
82  if (flag) {
83  _residency_state |= BufferResidencyTracker::S_resident;
84  } else {
85  _residency_state &= ~BufferResidencyTracker::S_resident;
86  }
87  set_owning_chain(&_residency->_chains[_residency_state]);
88 }
89 
90 /**
91  * This can be used along with BufferContextChain::get_first() to walk through
92  * the list of objects stored on a tracker.
93  */
95 get_next() const {
96  nassertr(_owning_chain != nullptr, nullptr);
97  if ((BufferContextChain *)_next == _owning_chain) {
98  return nullptr;
99  }
100  return (BufferContext *)_next;
101 }
102 
103 /**
104  * Should be called (usually by a derived class) when the on-card size of this
105  * object has changed.
106  */
107 INLINE void BufferContext::
108 update_data_size_bytes(size_t new_data_size_bytes) {
109  if (_owning_chain != nullptr) {
110  _owning_chain->adjust_bytes((int)new_data_size_bytes - (int)_data_size_bytes);
111  }
112  _data_size_bytes = new_data_size_bytes;
113 }
114 
115 /**
116  * Should be called (usually by a derived class) when the modified counter for
117  * this object has changed.
118  */
119 INLINE void BufferContext::
120 update_modified(UpdateSeq new_modified) {
121  _modified = new_modified;
122 }
BufferContext * get_next() const
This can be used along with BufferContextChain::get_first() to walk through the list of objects store...
Definition: bufferContext.I:95
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
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 ...
void set_resident(bool flag)
Changes the resident flag associated with this object.
Definition: bufferContext.I:81
A base class for things which need to inherit from both TypedWritable and from ReferenceCount.
void set_active(bool flag)
Changes the active flag associated with this object.
Definition: bufferContext.I:65
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:37