Panda3D
vertexBufferContext.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 vertexBufferContext.I
10  * @author drose
11  * @date 2005-03-17
12  */
13 
14 /**
15  *
16  */
17 INLINE VertexBufferContext::
18 VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) :
19  BufferContext(&pgo->_vbuffer_residency, data),
21 {
22 }
23 
24 /**
25  * Returns the pointer to the client-side array data object.
26  */
28 get_data() const {
29  return (GeomVertexArrayData *)_object;
30 }
31 
32 /**
33  * Returns true if the data has changed size since the last time mark_loaded()
34  * was called.
35  */
36 INLINE bool VertexBufferContext::
38  nassertr(reader->get_object() == get_data(), false);
39  return get_data_size_bytes() != (size_t)reader->get_data_size_bytes();
40 }
41 
42 /**
43  * Returns true if the data has changed its usage hint since the last time
44  * mark_loaded() was called.
45  */
46 INLINE bool VertexBufferContext::
48  nassertr(reader->get_object() == get_data(), false);
49  return _usage_hint != reader->get_usage_hint();
50 }
51 
52 /**
53  * Returns true if the data has been modified since the last time
54  * mark_loaded() was called.
55  */
56 INLINE bool VertexBufferContext::
58  nassertr(reader->get_object() == get_data(), false);
59  return get_modified() != reader->get_modified();
60 }
61 
62 /**
63  * Should be called (usually by a derived class) when the on-card size of this
64  * object has changed.
65  */
66 INLINE void VertexBufferContext::
67 update_data_size_bytes(size_t new_data_size_bytes) {
68  BufferContext::update_data_size_bytes(new_data_size_bytes);
69  AdaptiveLruPage::set_lru_size(new_data_size_bytes);
70 }
71 
72 /**
73  * Should be called after the VertexBufferContext has been loaded into
74  * graphics memory, this updates the internal flags for changed_size() and
75  * modified().
76  */
77 INLINE void VertexBufferContext::
79  nassertv(reader->get_object() == get_data());
80  update_data_size_bytes(reader->get_data_size_bytes());
81  update_modified(reader->get_modified());
82  _usage_hint = reader->get_usage_hint();
83 
84  // Assume the buffer is now resident.
85  set_resident(true);
86 }
87 
88 /**
89  * Should be called after the buffer has been forced out of graphics memory.
90  */
91 INLINE void VertexBufferContext::
93  update_modified(UpdateSeq::old());
94  set_resident(false);
95 }
bool was_modified(const GeomVertexArrayDataHandle *reader) const
Returns true if the data has been modified since the last time mark_loaded() was called.
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 is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
Definition: adaptiveLru.I:176
void mark_unloaded()
Should be called after the buffer has been forced out of graphics memory.
This data object is returned by GeomVertexArrayData::get_handle() or modify_handle().
A table of objects that are saved within the graphics context for reference by handle later.
void mark_loaded(const GeomVertexArrayDataHandle *reader)
Should be called after the VertexBufferContext has been loaded into graphics memory,...
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.
void set_resident(bool flag)
Changes the resident flag associated with this object.
Definition: bufferContext.I:81
One atomic piece that may be managed by a AdaptiveLru chain.
Definition: adaptiveLru.h:135
get_modified
Returns the UpdateSeq that was recorded the last time mark_loaded() was called.
Definition: bufferContext.h:54
bool changed_usage_hint(const GeomVertexArrayDataHandle *reader) const
Returns true if the data has changed its usage hint since the last time mark_loaded() was called.
GeomVertexArrayData * get_data() const
Returns the pointer to the client-side array data object.
bool changed_size(const GeomVertexArrayDataHandle *reader) const
Returns true if the data has changed size since the last time mark_loaded() was called.
void update_modified(UpdateSeq new_modified)
Should be called (usually by a derived class) when the modified counter for this object has changed.
get_data_size_bytes
Returns the number of bytes previously reported for the data object.
Definition: bufferContext.h:53
This is the data for one array of a GeomVertexData structure.