00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_BUFFER_OBJECT_CACHE_H_
00025 #define _SO_BUFFER_OBJECT_CACHE_H_
00026
00027 #include <Inventor/SbBase.h>
00028 #include <Inventor/STL/map>
00029 #include <Inventor/STL/list>
00030
00031 class SoBufferObject;
00032 class SoCpuBufferObject;
00033 class SbThreadSpinlock;
00034
00035 #ifdef _WIN32
00036 #pragma warning( push )
00037 #pragma warning(disable:4251)
00038 #endif
00039
00056 class SoCpuBufferObjectCache
00057 {
00058 public:
00059
00063 virtual void flush();
00064
00070 virtual void resize( const size_t newSize );
00071
00075 virtual size_t getSize( );
00076
00077 private:
00081 SoCpuBufferObjectCache();
00082
00084 virtual ~SoCpuBufferObjectCache();
00085
00098 virtual SoCpuBufferObject* getBufferRef( const uint64_t bufferId );
00099
00112 virtual uint64_t addInCache( SoCpuBufferObject* bufferObject );
00113
00127 virtual bool releaseBufferRef ( const uint64_t bufferId );
00128
00137 SoCpuBufferObject* getBuffer(const uint64_t bufferId);
00138
00139 private:
00140
00141
00142 void getInternalCounter( uint64_t &nbCacheAccess, uint64_t& nbCacheDefault);
00143 void resetInternalCounter( );
00144
00145
00146
00147 virtual bool deleteFromCache( const uint64_t bufferId );
00148
00149
00150 uint64_t getMappingIdfromSig(const uint64_t& cacheSig);
00151
00152 private:
00153
00154
00155
00156 SoCpuBufferObject* getBufferInternal(const uint64_t bufferId);
00157
00158
00159 typedef std::map<uint64_t, SoCpuBufferObject*> cacheListType;
00160 typedef std::map<uint64_t, uint64_t> bufferSignatureMap;
00161 typedef std::list<uint64_t> lruBufferIdsType;
00162
00163 cacheListType m_cacheList;
00164 bufferSignatureMap m_bufferIdToSigMap;
00165 bufferSignatureMap m_bufferSigToIdMap;
00166
00167 lruBufferIdsType lruBufferIds;
00168
00169
00170 size_t m_maxCacheSize;
00171
00172
00173 uint64_t getUniqueId();
00174 uint64_t m_lasUniqId;
00175
00176
00177 void makeRoomInCache();
00178
00179
00180 SbThreadSpinlock *m_cacheListLock;
00181
00182
00183 uint64_t m_perfNbCacheAccess ;
00184 uint64_t m_perfNbCacheDefault;
00185 };
00186
00187 #ifdef WIN32
00188 #pragma warning( pop )
00189 #endif
00190
00191 #endif //_SO_BUFFER_OBJECT_CACHE_H_
00192
00193
00194