From 3ed3b51a6c6d16cd39bb830f3ec06889b4594960 Mon Sep 17 00:00:00 2001 From: Christian Adamsson Date: Mon, 29 Jun 2020 11:45:49 +0200 Subject: [PATCH] Cache pipeline fixed --- .../rendering/renderablestreamnodes.cpp | 31 +++++++++++++++++-- .../rendering/renderablestreamnodes.h | 5 ++- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp index 298114b953..770489ee35 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.cpp @@ -62,7 +62,7 @@ namespace { constexpr const GLuint VaFiltering = 2; // MUST CORRESPOND TO THE SHADER PROGRAM constexpr const GLuint VaIndex = 3; // MUST CORRESPOND TO THE SHADER PROGRAM - constexpr int8_t CurrentCacheVersion = 1; + constexpr int8_t CurrentCacheVersion = 2; // ----- KEYS POSSIBLE IN MODFILE. EXPECTED DATA TYPE OF VALUE IN [BRACKETS] ----- // // ---------------------------- MANDATORY MODFILE KEYS ---------------------------- // @@ -361,6 +361,32 @@ namespace openspace { if (!_loadingStatesDynamically) { std::string _file = "StreamnodesCacheindex"; + //if the files doesn't exist we create them, this is just so that we then can cache the actual binary files + if (!FileSys.fileExists(_file)) { + std::ofstream fileStream(_file, std::ofstream::binary); + std::ofstream fileStream2("StreamnodesCacheColor", std::ofstream::binary); + std::ofstream fileStream3("StreamnodesCacheRadius", std::ofstream::binary); + std::ofstream fileStream4("StreamnodesCachePosition", std::ofstream::binary); + + fileStream.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); + fileStream2.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); + fileStream3.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); + fileStream4.write( + reinterpret_cast(&CurrentCacheVersion), + sizeof(int8_t) + ); + + + } std::string cachedFile = FileSys.cacheManager()->cachedFilename( _file, ghoul::filesystem::CacheManager::Persistent::Yes @@ -681,6 +707,7 @@ namespace openspace { return false; } + // Ensure that the source folder exists and then extract // the files with the same extension as ghoul::filesystem::Directory sourceFolder(sourceFolderPath); @@ -896,7 +923,7 @@ namespace openspace { const std::string earth = "Earth"; SceneGraphNode* earthnode = sceneGraphNode(earth); glm::dvec3 earthpos = earthnode->worldPosition(); - LDEBUG("earthpos x: " + std::to_string(earthpos.x)); + // LDEBUG("earthpos x: " + std::to_string(earthpos.x)); // Flow/Particles _shaderProgram->setUniform(_uniformCache.streamColor, _pStreamColor); _shaderProgram->setUniform(_uniformCache.nodeSize, _pNodeSize); diff --git a/modules/fieldlinessequence/rendering/renderablestreamnodes.h b/modules/fieldlinessequence/rendering/renderablestreamnodes.h index 48d90b20dc..ba65f5eba7 100644 --- a/modules/fieldlinessequence/rendering/renderablestreamnodes.h +++ b/modules/fieldlinessequence/rendering/renderablestreamnodes.h @@ -84,14 +84,13 @@ namespace openspace { // ------------------------------------ STRINGS ------------------------------------// // Name of the Node std::string _identifier; - // ------------------------------------- FLAGS -------------------------------------// // Used for 'runtime-states'. True when loading a new state from disk on another // thread. bool _isLoadingStateFromDisk = false; // False => states are stored in RAM (using 'in-RAM-states'), True => states are // loaded from disk during runtime (using 'runtime-states') - bool _loadingStatesDynamically = true; + bool _loadingStatesDynamically = false; // Used for 'runtime-states': True if new 'runtime-state' must be loaded from disk. // False => the previous frame's state should still be shown bool _mustLoadNewStateFromDisk = true; @@ -109,7 +108,7 @@ namespace openspace { // Active index of _startTimes int _activeTriggerTimeIndex = -1; // Number of states in the sequence - size_t _nStates = 274; + size_t _nStates = 4; // In setup it is used to scale JSON coordinates. During runtime it is used to scale // domain limits. float _scalingFactor = 1.f;