Panda3D
|
00001 // Filename: indexBufferContext.I 00002 // Created by: drose (17Mar05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: IndexBufferContext::Constructor 00018 // Access: Public 00019 // Description: 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE IndexBufferContext:: 00022 IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : 00023 BufferContext(&pgo->_ibuffer_residency), 00024 AdaptiveLruPage(0), 00025 _data(data) 00026 { 00027 } 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: IndexBufferContext::get_data 00031 // Access: Public 00032 // Description: Returns the pointer to the client-side array data 00033 // object. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE GeomPrimitive *IndexBufferContext:: 00036 get_data() const { 00037 return _data; 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: IndexBufferContext::changed_size 00042 // Access: Public 00043 // Description: Returns true if the data has changed size since the 00044 // last time mark_loaded() was called. 00045 //////////////////////////////////////////////////////////////////// 00046 INLINE bool IndexBufferContext:: 00047 changed_size(const GeomPrimitivePipelineReader *reader) const { 00048 nassertr(reader->get_object() == _data, false); 00049 return get_data_size_bytes() != (size_t)reader->get_data_size_bytes(); 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: IndexBufferContext::changed_usage_hint 00054 // Access: Public 00055 // Description: Returns true if the data has changed its usage hint 00056 // since the last time mark_loaded() was called. 00057 //////////////////////////////////////////////////////////////////// 00058 INLINE bool IndexBufferContext:: 00059 changed_usage_hint(const GeomPrimitivePipelineReader *reader) const { 00060 nassertr(reader->get_object() == _data, false); 00061 return _usage_hint != reader->get_usage_hint(); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: IndexBufferContext::was_modified 00066 // Access: Public 00067 // Description: Returns true if the data has been modified since the 00068 // last time mark_loaded() was called. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE bool IndexBufferContext:: 00071 was_modified(const GeomPrimitivePipelineReader *reader) const { 00072 nassertr(reader->get_object() == _data, false); 00073 return get_modified() != reader->get_modified(); 00074 } 00075 00076 //////////////////////////////////////////////////////////////////// 00077 // Function: IndexBufferContext::update_data_size_bytes 00078 // Access: Public 00079 // Description: Should be called (usually by a derived class) when 00080 // the on-card size of this object has changed. 00081 //////////////////////////////////////////////////////////////////// 00082 INLINE void IndexBufferContext:: 00083 update_data_size_bytes(size_t new_data_size_bytes) { 00084 BufferContext::update_data_size_bytes(new_data_size_bytes); 00085 AdaptiveLruPage::set_lru_size(new_data_size_bytes); 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: IndexBufferContext::mark_loaded 00090 // Access: Public 00091 // Description: Should be called after the IndexBufferContext has been 00092 // loaded into graphics memory, this updates the 00093 // internal flags for changed_size() and modified(). 00094 //////////////////////////////////////////////////////////////////// 00095 INLINE void IndexBufferContext:: 00096 mark_loaded(const GeomPrimitivePipelineReader *reader) { 00097 nassertv(reader->get_object() == _data); 00098 update_data_size_bytes(reader->get_data_size_bytes()); 00099 update_modified(reader->get_modified()); 00100 _usage_hint = reader->get_usage_hint(); 00101 00102 // Assume the buffer is now resident. 00103 set_resident(true); 00104 } 00105 00106 //////////////////////////////////////////////////////////////////// 00107 // Function: IndexBufferContext::mark_unloaded 00108 // Access: Public 00109 // Description: Should be called after the buffer has been forced 00110 // out of graphics memory. 00111 //////////////////////////////////////////////////////////////////// 00112 INLINE void IndexBufferContext:: 00113 mark_unloaded() { 00114 update_modified(UpdateSeq::old()); 00115 set_resident(false); 00116 }