VR-Forces 4.10 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgFileCache.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
18 
19 #include <vrvCore/DtFileCache.h>
20 
22 #include <vrvUtil/signalslib.h>
23 
24 #include <osgDB/ReaderWriter>
25 
26 #define _WINSOCKAPI_
27 
28 #include <tbb/atomic.h>
29 #include <tbb/spin_rw_mutex.h>
30 
31 namespace osg
32 {
33  class Drawable;
34  class GraphicsContext;
35  class Node;
36  class Texture;
37  class Object;
38 }
39 
40 namespace makVrv
41 {
42  class DtMeifConverter;
43  class DtMetaFileManager;
44  class DtOsgShaderManager;
45  class DtOsgShaderFilesCache;
46  class DtEffectControllerFactory;
47  class DtReadFileCallback;
48  class DtModelDefinition;
49 
55  {
56  public:
57 
60  friend class DtOsgFileCacheCreator;
61 
63  virtual ~DtOsgFileCache();
64 
67  virtual void initSingletonDependencies();
68 
70  virtual void releaseResources()
71  {
72  releaseResources(0);
73  }
74 
76  virtual void releaseResources(osg::State* state);
77 
79  virtual void setFromRecord( const makArchives::DtCacheSettingsRecord& rec );
80 
84  static void optimizeNodeGeometry(osg::Node* node);
85 
89  osg::Node* readNodeFile( const std::string& inputFilename,
90  const LoadFileOptions& loadFileOptions);
91 
94  inline osg::ref_ptr<osg::Node> findNodeFile( const std::string& inputFilename )
95  {
96  return ts_findNodeFile(inputFilename);
97  }
98 
102  osg::Image* readImageFile( const std::string& inputFilename,
103  const LoadFileOptions& loadFileOptions);
104 
107  virtual osg::Texture* getTextureInstance(const std::string& filePath,
108  osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
109  osg::Texture::WrapMode s, osg::Texture::WrapMode t,
110  const LoadFileOptions& loadFileOptions);
111 
115  virtual void ts_getTextureInstance(const std::string& filePath,
116  osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter,
117  osg::Texture::WrapMode s, osg::Texture::WrapMode t,
118  const LoadFileOptions& loadFileOptions, osg::ref_ptr<osg::Texture>& texture);
119 
121  virtual void runMergeDuplicateTextureVisitor(osg::Node& node);
122 
124  virtual void encodeOptionsString(const LoadFileOptions& loadFileOptions,
125  osgDB::ReaderWriter::Options& options) const;
126 
128  virtual void decodeOptions(const osgDB::ReaderWriter::Options& options,
129  LoadFileOptions& loadFileOptions) const;
130 
132  DtMetaFileManager* metaFileManager();
133 
137  void cleanDataFilePathList(FilePathList& fileList);
138 
143  boost::signalslib::signal<void (osg::Node*, const std::string& origFileName,
144  const std::string& actualFileName)> signal_nodeFileLoaded;
145 
150  boost::signalslib::signal<void (osg::Image*, const std::string& origFileName,
151  const std::string& actualFileName)> signal_imageFileLoaded;
152 
157  boost::signalslib::signal<void(osg::Object*, const std::string& origFileName,
158  const std::string& actualFileName)> signal_objectFileLoaded;
159 
163  boost::signalslib::signal<void (const std::string& filename,
164  osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)>
166 
170  boost::signalslib::signal<void (const std::string& filename,
171  osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)>
173 
177  boost::signalslib::signal<void(const std::string& filename,
178  osgDB::ReaderWriter::ReadResult&, const osgDB::ReaderWriter::Options*)>
180 
182  virtual const DtOsgShaderFilesCache& shaderFilesCache(void) const;
183 
187  virtual const std::string& loadShaderSource(const std::string& shaderFile) const;
188 
191  virtual std::string ts_getTextureFilePathAndSetNameIfNotSet(const osg::Texture* baseTexture) const;
192 
194  virtual void ts_setEffectTextureName(osg::ref_ptr<osg::Texture>& effectTexture, const std::string& validFile) const;
195 
197  virtual void ts_setEffectTextureFilterAndHardwareMipMapGen(osg::Texture* effectTexture, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, bool hardwareMipMapGen) const;
198 
200  virtual void ts_compareAndSwapIgnoreHint(osg::Texture* effectTexture, bool oldVal, bool newVal) const;
201 
206  virtual bool ts_checkAndSetIgnoreHint(osg::Object* obj, bool val, const char* hint) const;
207 
210  virtual bool ts_ignore(osg::Object* obj, const char* hint) const;
211 
213  virtual const DtEffectControllerShaderCache& effectControllerShaderCache(void) const;
214 
216  virtual void setNumActivePagerThreads(int active);
217 
219  virtual int numActivePagerThreads();
220 
222  virtual int numImageProcessingTasks() const;
223 
225  virtual void setNumDiguyWorkerThreads(int num);
226 
229  virtual void incrementNumSleepingPagerThreads();
230 
232  virtual void decrementNumSleepingPagerThreads();
233 
235  virtual DtOsgShaderManager& shaderManager(void);
236 
238  virtual const DtOsgShaderManager& shaderManager(void) const;
239 
241  virtual void ts_flushInstancingCache(bool multipass,
242  bool flushNodes, bool flushTextures, bool flushImages);
243 
244  protected:
245 
246  friend class DtReadFileCallback;
247 
249  virtual osg::ref_ptr<osg::Node> ts_readNodeFile( const std::string& inputFilename,
250  const LoadFileOptions& loadFileOptions, const osg::UserDataContainer *optionsUserData);
251 
253  virtual osg::ref_ptr<osg::Node> ts_readCdbNodeFile(const std::string& inputFilename,
254  const LoadFileOptions& loadFileOptions, const osg::UserDataContainer *optionsUserData);
255 
257  virtual osg::ref_ptr<osg::Node> ts_findNodeFile( const std::string& inputFilename );
258 
260  virtual osg::ref_ptr<osg::Image> ts_readImageFile( const std::string& inputFilename,
261  const LoadFileOptions& loadFileOptions,
262  const osg::UserDataContainer* optionsUserData =0L);
263 
265  virtual osg::ref_ptr<osg::Image> ts_readCdbImageFile(const std::string& inputFilename,
266  const LoadFileOptions& loadFileOptions,
267  const osg::UserDataContainer* optionsUserData = 0L);
268 
270  virtual osg::ref_ptr<osg::Object> ts_readObject(
271  const std::string& filename, const osgDB::ReaderWriter::Options* options);
272 
274  void ts_encryptImage( const std::string& inputFileName,
275  const std::string& outputFilename, const osgDB::ReaderWriter::Options* options, bool printToConsole);
276 
278  bool ts_resolveRelativeFilename( const LoadFileOptions& loadFileOptions,
279  std::string& absoluteInputFilename );
280 
282  virtual void ts_clearInstancingCache();
283 
284 
286  virtual void applyEffectTexture(osg::Node* node, const std::string& extension,
287  bool isCdb, osgDB::ReaderWriter::Options* option);
288 
290  DtOsgFileCache(DtDe& de);
291 
294  virtual bool save(const std::string& origFilename,
295  const std::string& cachedFilename, bool optimize);
296 
298  bool saveToAcceleratedFile( const std::string& origFileName,
299  osg::Node* nodeRef, const std::string& cachedFilename,
300  bool writeExternalReferences);
301 
303  virtual void addMetaFlightOptions(std::string& optionsString);
304 
306  virtual bool needsShaderGeneration(const std::string& extension, const LoadFileOptions& options) const;
307 
309  virtual void updateGlobalOptions();
310 
312  virtual void slot_onDdsFlipChanged(bool flip);
313 
315  virtual void slot_instancingChanged(bool enabled);
316 
317  // check if an attrData object is in the cache (only for FLT and CDB)
318  virtual bool getAttrFromLocalCache(const std::string& filename, osg::Object** attrData);
319 
321  virtual void writeCacheFile(osg::ref_ptr<osg::Node> node, const std::string& acceleratedFileLocation, DtCVMarkerSeries& series);
322 
324  virtual void shadersGeneration(osg::ref_ptr<osg::Node> node, const std::string& fileToLoad);
325 
328  virtual void squishImage(const std::string& fileToLoad, const std::string& acceleratedFilename, DtCVMarkerSeries& objectCreation,
329  osg::ref_ptr<osg::Image> image, bool writeAcceleratedFile, bool isCDB);
330 
335  virtual void saveImageFilename(const std::string& absoluteInputFilename, osg::Image* image);
336 
338  virtual osg::ref_ptr<osg::Image> isImageAlreadyInCache(const std::string& cacheKey, const std::string& inputExtension, const LoadFileOptions& loadFileOptions);
339 
340  protected:
341 
342  typedef boost::unordered_map<std::string,std::string> RelativePathCache;
343 
347  typedef std::map< std::string, osg::ref_ptr<osg::Object> > AttrCacheMap;
349 
351  unsigned int myMaxFlushNodeCount;
352  unsigned int myMaxFlushImageCount;
353 
354  tbb::spin_rw_mutex myRelativePathMutex;
358 
362 
363  // effect controller shader cache
365 
367 
368  // determines threading behavior
370  tbb::atomic<int> myNumSleepingPagerThreads;
371  tbb::atomic<int> myNumDiguyWorkerThreads;
372  };
373 
377  {
378 
379  public:
380 
382  virtual DtFileCache* create(DtDe& de);
383 
384  };
385 }
386 
387 // Include the inl to solve a circular dependency problem for gcc
388 #include <vrvOsg/DtOsgReferencedCollection.inl>
389 
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
tbb::spin_rw_mutex myRelativePathMutex
Definition: DtOsgFileCache.h:354
RelativePathCache myRelativePathCache
Definition: DtOsgFileCache.h:355
Contains makVrv::DtTextureCollection class.
virtual void releaseResources()
Release all rendering resources.
Definition: DtOsgFileCache.h:70
std::map< std::string, osg::ref_ptr< osg::Object > > AttrCacheMap
Definition: DtOsgFileCache.h:347
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Class responsible for converting images into MAK encrypted image files.
Definition: DtMeifConverter.h:25
AttrCacheMap myAttrCacheMap
Definition: DtOsgFileCache.h:348
DtOsgReferencedCollection< osg::Node > myNodeCollection
Definition: DtOsgFileCache.h:344
Creates a series/span line in the CV tool.
Definition: DtConcurrencyViewerMacros.h:27
The abstract creator for the abstract DtFileCache class.
Definition: DtFileCache.h:273
tbb::atomic< int > myNumDiguyWorkerThreads
Definition: DtOsgFileCache.h:371
brief DtEffectControllerShaderCache is a cache for shaders used by effect texture controller ...
Definition: DtEffectControllerShaderCache.h:26
unsigned int myMaxFlushImageCount
Definition: DtOsgFileCache.h:352
osg::ref_ptr< osg::Node > findNodeFile(const std::string &inputFilename)
Find a node file.
Definition: DtOsgFileCache.h:94
class for holding loader shader files, so that they are not repeatedly loaded from disk ...
Definition: DtOsgShaderFilesCache.h:27
boost::signalslib::signal< void(const std::string &filename, osgDB::ReaderWriter::ReadResult &, const osgDB::ReaderWriter::Options *)> signal_readObjectCallback
Signaled emitted when osg calls readObject.
Definition: DtOsgFileCache.h:179
The DtOsgFileCache creator.
Definition: DtOsgFileCache.h:376
boost::signalslib::signal< void(const std::string &filename, osgDB::ReaderWriter::ReadResult &, const osgDB::ReaderWriter::Options *)> signal_readNodeCallback
Signaled emitted when osg calls readNodeFile.
Definition: DtOsgFileCache.h:165
Handles the set up and processing of .meta files.
Definition: DtMetaFileManager.h:36
int myNumActivePagerThreads
Definition: DtOsgFileCache.h:369
Contains makVrv::DtFileCache class.
The OSG implementation of makVrv::DtOsgFileCache.
Definition: DtOsgFileCache.h:54
DtOsgReferencedCollection< osg::Image > myImageCollection
Definition: DtOsgFileCache.h:346
boost::signalslib::signal< void(const std::string &filename, osgDB::ReaderWriter::ReadResult &, const osgDB::ReaderWriter::Options *)> signal_readImageCallback
Signaled emitted when osg calls readImageFile.
Definition: DtOsgFileCache.h:172
boost::unordered_map< std::string, std::string > RelativePathCache
Definition: DtOsgFileCache.h:342
Contains the DtEffectControllerShaderCache class declaration.
DtOsgShaderManager & myShaderManager
Definition: DtOsgFileCache.h:359
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2 &size, const ImVec2 &uv0=ImVec2(0, 0), const ImVec2 &uv1=ImVec2(1, 1), const ImVec4 &tint_col=ImVec4(1, 1, 1, 1), const ImVec4 &border_col=ImVec4(0, 0, 0, 0))
boost::signalslib::signal< void(osg::Node *, const std::string &origFileName, const std::string &actualFileName)> signal_nodeFileLoaded
Signal emitted whenever a Node file is loaded from disk.
Definition: DtOsgFileCache.h:144
DtOsgShaderFilesCache & myShaderFilesCache
Definition: DtOsgFileCache.h:360
DtEffectControllerShaderCache myEffectControllerShaderCache
Definition: DtOsgFileCache.h:364
DtMetaFileManager * myMetaFileManager
Definition: DtOsgFileCache.h:357
Definition: DtFileCache.h:60
tbb::atomic< int > myNumSleepingPagerThreads
Definition: DtOsgFileCache.h:370
osg::ref_ptr< DtReadFileCallback > myReadFileCallback
Definition: DtOsgFileCache.h:366
DtOsgShaderManager injects custom shaders into the scenes, and keeps their uniform parameters set to ...
Definition: DtOsgShaderManager.h:41
Record for the settings associated with the VRV caching.
Definition: DtCacheSettingsRecord.h:17
Definition: DtReadFileCallback.h:21
DtEffectControllerFactory & myEffectControllerFactory
Definition: DtOsgFileCache.h:361
boost::signalslib::signal< void(osg::Image *, const std::string &origFileName, const std::string &actualFileName)> signal_imageFileLoaded
Signal emitted whenever an image file is loaded from disk.
Definition: DtOsgFileCache.h:151
The scene object creators are registered with the scene object factory for accessing DtSceneObjectCre...
Definition: DtEffectControllerFactory.h:31
DtMeifConverter * myImageCompressor
Definition: DtOsgFileCache.h:356
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
boost::signalslib::signal< void(osg::Object *, const std::string &origFileName, const std::string &actualFileName)> signal_objectFileLoaded
Signal emitted whenever an object file is loaded from disk.
Definition: DtOsgFileCache.h:158
Contains makVrv::DtOsgReferencedCollection class.
unsigned int myMaxFlushTextureCount
Definition: DtOsgFileCache.h:350
Contains the DtCVMarkerSeries and DtCVMarkerSeries class declarations responsible for wrapping up to ...
unsigned int myMaxFlushNodeCount
Definition: DtOsgFileCache.h:351
Handles the caching of files.
Definition: DtFileCache.h:52
DtOsgReferencedCollection< DtTextureCollection > myTextureCollection
Definition: DtOsgFileCache.h:345
Contains the DtEffectControllerContainer class.

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)