00001 // Filename: vertexBufferContext.I00002 // Created by: drose (17Mar05)00003 //00004 ////////////////////////////////////////////////////////////////////00005 //00006 // PANDA 3D SOFTWARE00007 // Copyright (c) Carnegie Mellon University. All rights reserved.00008 //00009 // All use of this software is subject to the terms of the revised BSD00010 // license. You should have received a copy of this license along00011 // with this source code in a file named "LICENSE."00012 //00013 ////////////////////////////////////////////////////////////////////00014
00015
00016 ////////////////////////////////////////////////////////////////////00017 // Function: VertexBufferContext::Constructor00018 // Access: Public00019 // Description:00020 ////////////////////////////////////////////////////////////////////00021 INLINE VertexBufferContext::
00022 VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) :
00023 BufferContext(&pgo->_vbuffer_residency),
00024 AdaptiveLruPage(0),
00025 _data(data)
00026 {
00027 }
00028
00029 ////////////////////////////////////////////////////////////////////00030 // Function: VertexBufferContext::get_data00031 // Access: Public00032 // Description: Returns the pointer to the client-side array data00033 // object.00034 ////////////////////////////////////////////////////////////////////00035 INLINE GeomVertexArrayData *VertexBufferContext::00036get_data() const {
00037 return _data;
00038 }
00039
00040 ////////////////////////////////////////////////////////////////////00041 // Function: VertexBufferContext::changed_size00042 // Access: Public00043 // Description: Returns true if the data has changed size since the00044 // last time mark_loaded() was called.00045 ////////////////////////////////////////////////////////////////////00046 INLINE boolVertexBufferContext::00047changed_size(constGeomVertexArrayDataHandle *reader) const {
00048 nassertr(reader->get_object() == _data, false);
00049 returnget_data_size_bytes() != (size_t)reader->get_data_size_bytes();
00050 }
00051
00052 ////////////////////////////////////////////////////////////////////00053 // Function: VertexBufferContext::changed_usage_hint00054 // Access: Public00055 // Description: Returns true if the data has changed its usage hint00056 // since the last time mark_loaded() was called.00057 ////////////////////////////////////////////////////////////////////00058 INLINE boolVertexBufferContext::00059changed_usage_hint(constGeomVertexArrayDataHandle *reader) const {
00060 nassertr(reader->get_object() == _data, false);
00061 return _usage_hint != reader->get_usage_hint();
00062 }
00063
00064 ////////////////////////////////////////////////////////////////////00065 // Function: VertexBufferContext::was_modified00066 // Access: Public00067 // Description: Returns true if the data has been modified since the00068 // last time mark_loaded() was called.00069 ////////////////////////////////////////////////////////////////////00070 INLINE boolVertexBufferContext::00071was_modified(constGeomVertexArrayDataHandle *reader) const {
00072 nassertr(reader->get_object() == _data, false);
00073 returnget_modified() != reader->get_modified();
00074 }
00075
00076 ////////////////////////////////////////////////////////////////////00077 // Function: VertexBufferContext::update_data_size_bytes00078 // Access: Public00079 // Description: Should be called (usually by a derived class) when00080 // the on-card size of this object has changed.00081 ////////////////////////////////////////////////////////////////////00082 INLINE voidVertexBufferContext::00083update_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: VertexBufferContext::mark_loaded00090 // Access: Public00091 // Description: Should be called after the VertexBufferContext has been00092 // loaded into graphics memory, this updates the00093 // internal flags for changed_size() and modified().00094 ////////////////////////////////////////////////////////////////////00095 INLINE voidVertexBufferContext::00096mark_loaded(constGeomVertexArrayDataHandle *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: VertexBufferContext::mark_unloaded00108 // Access: Public00109 // Description: Should be called after the buffer has been forced00110 // out of graphics memory.00111 ////////////////////////////////////////////////////////////////////00112 INLINE voidVertexBufferContext::00113mark_unloaded() {
00114 update_modified(UpdateSeq::old());
00115 set_resident(false);
00116 }