Panda3D
indexBufferContext.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 indexBufferContext.I
10  * @author drose
11  * @date 2005-03-17
12  */
13 
14 /**
15  *
16  */
17 INLINE IndexBufferContext::
18 IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) :
19  BufferContext(&pgo->_ibuffer_residency, data),
21 {
22 }
23 
24 /**
25  * Returns the pointer to the client-side array data object.
26  */
28 get_data() const {
29  return (GeomPrimitive *)_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 IndexBufferContext::
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 IndexBufferContext::
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 IndexBufferContext::
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 IndexBufferContext::
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 IndexBufferContext has been loaded into graphics
74  * memory, this updates the internal flags for changed_size() and modified().
75  */
76 INLINE void IndexBufferContext::
78  nassertv(reader->get_object() == get_data());
80  update_modified(reader->get_modified());
81  _usage_hint = reader->get_usage_hint();
82 
83  // Assume the buffer is now resident.
84  set_resident(true);
85 }
86 
87 /**
88  * Should be called after the buffer has been forced out of graphics memory.
89  */
90 INLINE void IndexBufferContext::
92  update_modified(UpdateSeq::old());
93  set_resident(false);
94 }
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
Definition: bufferContext.h:38
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
Definition: geomPrimitive.h:56
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
A table of objects that are saved within the graphics context for reference by handle later.
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 was_modified(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has been modified since the last time mark_loaded() was called.
bool changed_usage_hint(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has changed its usage hint since the last time mark_loaded() was called.
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
void mark_unloaded()
Should be called after the buffer has been forced out of graphics memory.
get_modified
Returns the UpdateSeq that was recorded the last time mark_loaded() was called.
Definition: bufferContext.h:54
void mark_loaded(const GeomPrimitivePipelineReader *reader)
Should be called after the IndexBufferContext has been loaded into graphics memory,...
GeomPrimitive * get_data() const
Returns the pointer to the client-side array data object.
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
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
bool changed_size(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has changed size 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.