Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE IndexBufferContext::
18IndexBufferContext(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 */
28get_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 */
37changed_size(const GeomPrimitivePipelineReader *reader) const {
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 */
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 */
57was_modified(const GeomPrimitivePipelineReader *reader) const {
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 */
67update_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 */
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 */
92 update_modified(UpdateSeq::old());
93 set_resident(false);
94}
One atomic piece that may be managed by a AdaptiveLru chain.
void set_lru_size(size_t lru_size)
Specifies the size of this page, presumably in bytes, although any unit is possible.
This is a base class for those kinds of SavedContexts that occupy an easily-measured (and substantial...
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.
get_modified
Returns the UpdateSeq that was recorded the last time mark_loaded() was called.
void set_resident(bool flag)
Changes the resident flag associated with this object.
get_data_size_bytes
Returns the number of bytes previously reported for the 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.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
int get_data_size_bytes() const
Returns the number of bytes stored in the vertices array.
This is an abstract base class for a family of classes that represent the fundamental geometry primit...
void mark_unloaded()
Should be called after the buffer has been forced out of 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.
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.
bool changed_size(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has changed size since the last time mark_loaded() was called.
void mark_loaded(const GeomPrimitivePipelineReader *reader)
Should be called after the IndexBufferContext has been loaded into graphics memory,...
bool was_modified(const GeomPrimitivePipelineReader *reader) const
Returns true if the data has been modified since the last time mark_loaded() was called.
GeomPrimitive * get_data() const
Returns the pointer to the client-side array data object.
A table of objects that are saved within the graphics context for reference by handle later.