00001 // Filename: preparedGraphicsObjects.I 00002 // Created by: drose (23Feb04) 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: PreparedGraphicsObjects::get_name 00018 // Access: Public 00019 // Description: Returns the name of the PreparedGraphicsObjects 00020 // structure. This is an arbitrary name that serves 00021 // mainly to uniquify the context for PStats reporting. 00022 //////////////////////////////////////////////////////////////////// 00023 INLINE const string &PreparedGraphicsObjects:: 00024 get_name() const { 00025 return _name; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: PreparedGraphicsObjects::get_graphics_memory_limit 00030 // Access: Public 00031 // Description: Returns the artificial cap on graphics memory that 00032 // will be imposed on this GSG. See 00033 // set_graphics_memory_limit(). 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE size_t PreparedGraphicsObjects:: 00036 get_graphics_memory_limit() const { 00037 return _graphics_memory_lru.get_max_size(); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: PreparedGraphicsObjects::release_all 00042 // Access: Public 00043 // Description: Releases all prepared objects of all kinds at once. 00044 //////////////////////////////////////////////////////////////////// 00045 INLINE void PreparedGraphicsObjects:: 00046 release_all() { 00047 release_all_textures(); 00048 release_all_geoms(); 00049 release_all_shaders(); 00050 release_all_vertex_buffers(); 00051 release_all_index_buffers(); 00052 00053 _texture_residency.set_levels(); 00054 _vbuffer_residency.set_levels(); 00055 _ibuffer_residency.set_levels(); 00056 } 00057 00058 //////////////////////////////////////////////////////////////////// 00059 // Function: PreparedGraphicsObjects::get_num_queued 00060 // Access: Public 00061 // Description: Returns the number of objects of any kind that have 00062 // been enqueued to be prepared on this GSG. 00063 //////////////////////////////////////////////////////////////////// 00064 INLINE int PreparedGraphicsObjects:: 00065 get_num_queued() const { 00066 return (get_num_queued_textures() + 00067 get_num_queued_geoms() + 00068 get_num_queued_shaders() + 00069 get_num_queued_vertex_buffers() + 00070 get_num_queued_index_buffers()); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: PreparedGraphicsObjects::get_num_prepared 00075 // Access: Public 00076 // Description: Returns the number of objects of any kind that have 00077 // already been prepared on this GSG. 00078 //////////////////////////////////////////////////////////////////// 00079 INLINE int PreparedGraphicsObjects:: 00080 get_num_prepared() const { 00081 return (get_num_prepared_textures() + 00082 get_num_prepared_geoms() + 00083 get_num_prepared_shaders() + 00084 get_num_prepared_vertex_buffers() + 00085 get_num_prepared_index_buffers()); 00086 } 00087 00088 //////////////////////////////////////////////////////////////////// 00089 // Function: PreparedGraphicsObjects::BufferCacheKey::operator < 00090 // Access: Public 00091 // Description: 00092 //////////////////////////////////////////////////////////////////// 00093 INLINE bool PreparedGraphicsObjects::BufferCacheKey:: 00094 operator < (const PreparedGraphicsObjects::BufferCacheKey &other) const { 00095 if (_data_size_bytes != other._data_size_bytes) { 00096 return _data_size_bytes < other._data_size_bytes; 00097 } 00098 return (int)_usage_hint < (int)other._usage_hint; 00099 } 00100 00101 //////////////////////////////////////////////////////////////////// 00102 // Function: PreparedGraphicsObjects::BufferCacheKey::operator == 00103 // Access: Public 00104 // Description: 00105 //////////////////////////////////////////////////////////////////// 00106 INLINE bool PreparedGraphicsObjects::BufferCacheKey:: 00107 operator == (const PreparedGraphicsObjects::BufferCacheKey &other) const { 00108 return (_data_size_bytes == other._data_size_bytes && 00109 _usage_hint == other._usage_hint); 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: PreparedGraphicsObjects::BufferCacheKey::operator != 00114 // Access: Public 00115 // Description: 00116 //////////////////////////////////////////////////////////////////// 00117 INLINE bool PreparedGraphicsObjects::BufferCacheKey:: 00118 operator != (const PreparedGraphicsObjects::BufferCacheKey &other) const { 00119 return !operator == (other); 00120 }