VR-Forces 5.0.1 Developer's Guide
 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) 2021 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 
245  virtual int numNodes() const;
246 
248  virtual int numTextures() const;
249 
251  virtual int numImages() const;
252 
254  virtual void addImguiTextureUI(unsigned int contextID);
255 
257  virtual void connectImguiSignal();
258 
259  protected:
260 
261  friend class DtReadFileCallback;
262 
264  virtual osg::ref_ptr<osg::Node> ts_readNodeFile( const std::string& inputFilename,
265  const LoadFileOptions& loadFileOptions, const osg::UserDataContainer *optionsUserData);
266 
268  virtual osg::ref_ptr<osg::Node> ts_readCdbNodeFile(const std::string& inputFilename,
269  const LoadFileOptions& loadFileOptions, const osg::UserDataContainer *optionsUserData);
270 
272  virtual osg::ref_ptr<osg::Node> ts_findNodeFile( const std::string& inputFilename );
273 
275  virtual osg::ref_ptr<osg::Image> ts_readImageFile( const std::string& inputFilename,
276  const LoadFileOptions& loadFileOptions,
277  const osg::UserDataContainer* optionsUserData =0L);
278 
280  virtual osg::ref_ptr<osg::Image> ts_readCdbImageFile(const std::string& inputFilename,
281  const LoadFileOptions& loadFileOptions,
282  const osg::UserDataContainer* optionsUserData = 0L);
283 
285  virtual osg::ref_ptr<osg::Object> ts_readObject(
286  const std::string& filename, const osgDB::ReaderWriter::Options* options);
287 
289  void ts_encryptImage( const std::string& inputFileName,
290  const std::string& outputFilename, const osgDB::ReaderWriter::Options* options, bool printToConsole);
291 
293  bool ts_resolveRelativeFilename( const LoadFileOptions& loadFileOptions,
294  std::string& absoluteInputFilename );
295 
297  virtual void ts_clearInstancingCache();
298 
299 
301  virtual void applyEffectTexture(osg::Node* node, const std::string& extension,
302  bool isCdb, osgDB::ReaderWriter::Options* option);
303 
305  DtOsgFileCache(DtDe& de);
306 
309  virtual bool save(const std::string& origFilename,
310  const std::string& cachedFilename, bool optimize);
311 
313  bool saveToAcceleratedFile( const std::string& origFileName,
314  osg::Node* nodeRef, const std::string& cachedFilename,
315  bool writeExternalReferences);
316 
318  virtual void addMetaFlightOptions(std::string& optionsString);
319 
321  virtual bool needsShaderGeneration(const std::string& extension, const LoadFileOptions& options) const;
322 
324  virtual void updateGlobalOptions();
325 
327  virtual void slot_onDdsFlipChanged(bool flip);
328 
330  virtual void slot_instancingChanged(bool enabled);
331 
332  // check if an attrData object is in the cache (only for FLT and CDB)
333  virtual bool getAttrFromLocalCache(const std::string& filename, osg::Object** attrData);
334 
336  virtual void writeCacheFile(osg::ref_ptr<osg::Node> node, const std::string& acceleratedFileLocation, DtCVMarkerSeries& series);
337 
339  virtual void shadersGeneration(osg::ref_ptr<osg::Node> node, const std::string& fileToLoad);
340 
343  virtual void squishImage(const std::string& fileToLoad, const std::string& acceleratedFilename, DtCVMarkerSeries& objectCreation,
344  osg::ref_ptr<osg::Image> image, bool writeAcceleratedFile, bool isCDB);
345 
350  virtual void saveImageFilename(const std::string& absoluteInputFilename, osg::Image* image);
351 
353  virtual osg::ref_ptr<osg::Image> getCachedImage(const std::string& cacheKey, const std::string& inputExtension, const LoadFileOptions& loadFileOptions);
354 
355  protected:
356 
357  typedef boost::unordered_map<std::string,std::string> RelativePathCache;
358 
362  typedef std::map< std::string, osg::ref_ptr<osg::Object> > AttrCacheMap;
364 
365  tbb::spin_rw_mutex myRelativePathMutex;
369 
373 
374  // effect controller shader cache
376 
379 
380  // determines threading behavior
382  tbb::atomic<int> myNumSleepingPagerThreads;
383  tbb::atomic<int> myNumDiguyWorkerThreads;
384  };
385 
389  {
390 
391  public:
392 
394  virtual DtFileCache* create(DtDe& de);
395 
396  };
397 }
398 
399 // Include the inl to solve a circular dependency problem for gcc
400 #include <vrvOsg/DtOsgReferencedCollection.inl>
401 
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
tbb::spin_rw_mutex myRelativePathMutex
Definition: DtOsgFileCache.h:365
RelativePathCache myRelativePathCache
Definition: DtOsgFileCache.h:366
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:362
#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:363
DtOsgReferencedCollection< osg::Node > myNodeCollection
Definition: DtOsgFileCache.h:359
Creates a series/span line in the CV tool.
Definition: DtConcurrencyViewerMacros.h:27
The abstract creator for the abstract DtFileCache class.
Definition: DtFileCache.h:257
tbb::atomic< int > myNumDiguyWorkerThreads
Definition: DtOsgFileCache.h:383
brief DtEffectControllerShaderCache is a cache for shaders used by effect texture controller ...
Definition: DtEffectControllerShaderCache.h:26
osg::ref_ptr< osg::Node > findNodeFile(const std::string &inputFilename)
Find a node file. If the file was already cached then a copy will be returned.
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. This signal is emitted every time read object is called r...
Definition: DtOsgFileCache.h:179
The DtOsgFileCache creator..
Definition: DtOsgFileCache.h:388
boost::signalslib::signal< void(const std::string &filename, osgDB::ReaderWriter::ReadResult &, const osgDB::ReaderWriter::Options *)> signal_readNodeCallback
Signaled emitted when osg calls readNodeFile. This signal is emitted every time read image is called ...
Definition: DtOsgFileCache.h:165
Handles the set up and processing of .meta files. Meta files contain extra information about nodes in...
Definition: DtMetaFileManager.h:36
int myNumActivePagerThreads
Definition: DtOsgFileCache.h:381
Contains makVrv::DtFileCache class.
The OSG implementation of makVrv::DtOsgFileCache. This will cache files as .ive&#39;s for quicker load ti...
Definition: DtOsgFileCache.h:54
DtOsgReferencedCollection< osg::Image > myImageCollection
Definition: DtOsgFileCache.h:361
boost::signalslib::signal< void(const std::string &filename, osgDB::ReaderWriter::ReadResult &, const osgDB::ReaderWriter::Options *)> signal_readImageCallback
Signaled emitted when osg calls readImageFile. This signal is emitted every time read image is called...
Definition: DtOsgFileCache.h:172
boost::unordered_map< std::string, std::string > RelativePathCache
Definition: DtOsgFileCache.h:357
Contains the DtEffectControllerShaderCache class declaration.
DtOsgShaderManager & myShaderManager
Definition: DtOsgFileCache.h:370
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. When instancing is enabled then each file wi...
Definition: DtOsgFileCache.h:144
DtOsgShaderFilesCache & myShaderFilesCache
Definition: DtOsgFileCache.h:371
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
DtEffectControllerShaderCache myEffectControllerShaderCache
Definition: DtOsgFileCache.h:375
DtMetaFileManager * myMetaFileManager
Definition: DtOsgFileCache.h:368
Definition: DtFileCache.h:44
tbb::atomic< int > myNumSleepingPagerThreads
Definition: DtOsgFileCache.h:382
osg::ref_ptr< DtReadFileCallback > myReadFileCallback
Definition: DtOsgFileCache.h:377
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:372
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. When instancing is enabled then each file ...
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:367
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
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. When instancing is enabled then each file...
Definition: DtOsgFileCache.h:158
Contains makVrv::DtOsgReferencedCollection class.
Contains the DtCVMarkerSeries and DtCVMarkerSeries class declarations responsible for wrapping up to ...
Handles the caching of files. Includes functions for excluding files with certain extensions from bei...
Definition: DtFileCache.h:36
DtOsgReferencedCollection< DtTextureCollection > myTextureCollection
Definition: DtOsgFileCache.h:360
DtSignalConnectionManager myConnections
Definition: DtOsgFileCache.h:378
Contains the DtEffectControllerContainer class.

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)