From 696bc31861c6078309dcbdf6e728ada2fa3cf0e5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 5 Aug 2020 11:19:09 +0200 Subject: [PATCH] Moving over more allocations to the memory pool --- include/openspace/rendering/renderable.h | 3 ++- include/openspace/scene/rotation.h | 3 ++- include/openspace/scene/scale.h | 3 ++- include/openspace/scene/scenegraphnode.h | 11 +++++----- include/openspace/scene/timeframe.h | 3 ++- include/openspace/scene/translation.h | 3 ++- include/openspace/util/memorymanager.h | 2 +- modules/base/rendering/renderabletrail.h | 3 ++- modules/base/rotation/timelinerotation.cpp | 4 ++-- modules/base/rotation/timelinerotation.h | 2 +- modules/base/timeframe/timeframeunion.h | 2 +- .../base/translation/timelinetranslation.cpp | 4 ++-- .../base/translation/timelinetranslation.h | 3 ++- modules/space/rotation/spicerotation.h | 2 +- src/rendering/renderable.cpp | 8 +++---- src/scene/rotation.cpp | 8 +++---- src/scene/scale.cpp | 8 +++---- src/scene/scenegraphnode.cpp | 21 ++++++------------- src/scene/timeframe.cpp | 4 ++-- src/scene/translation.cpp | 8 +++---- 20 files changed, 51 insertions(+), 54 deletions(-) diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 1b2817c946..281c5ef85b 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -30,6 +30,7 @@ #include #include #include +#include namespace ghoul { class Dictionary; } namespace ghoul::opengl { @@ -58,7 +59,7 @@ public: Overlay = 16 }; - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Renderable(const ghoul::Dictionary& dictionary); diff --git a/include/openspace/scene/rotation.h b/include/openspace/scene/rotation.h index 995543935f..ce6970716e 100644 --- a/include/openspace/scene/rotation.h +++ b/include/openspace/scene/rotation.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class Rotation : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Rotation(const ghoul::Dictionary& dictionary); diff --git a/include/openspace/scene/scale.h b/include/openspace/scene/scale.h index 117db6bafd..ef9230d32d 100644 --- a/include/openspace/scene/scale.h +++ b/include/openspace/scene/scale.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class Scale : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Scale(); diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 25a35417d7..a3e41254b6 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -141,7 +141,6 @@ public: const PerformanceRecord& performanceRecord() const; - void setRenderable(std::unique_ptr renderable); const Renderable* renderable() const; Renderable* renderable(); @@ -169,19 +168,19 @@ private: PerformanceRecord _performanceRecord = { 0, 0, 0, 0, 0 }; - std::unique_ptr _renderable; + ghoul::mm_unique_ptr _renderable; properties::StringProperty _guiPath; properties::StringProperty _guiDisplayName; // Transformation defined by ephemeris, rotation and scale struct { - std::unique_ptr translation; - std::unique_ptr rotation; - std::unique_ptr scale; + ghoul::mm_unique_ptr translation; + ghoul::mm_unique_ptr rotation; + ghoul::mm_unique_ptr scale; } _transform; - std::unique_ptr _timeFrame; + ghoul::mm_unique_ptr _timeFrame; // Cached transform data glm::dvec3 _worldPositionCached = glm::dvec3(0.0); diff --git a/include/openspace/scene/timeframe.h b/include/openspace/scene/timeframe.h index 95d5aff38c..ec66a07b0b 100644 --- a/include/openspace/scene/timeframe.h +++ b/include/openspace/scene/timeframe.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace ghoul { class Dictionary; } @@ -40,7 +41,7 @@ namespace documentation { struct Documentation; } class TimeFrame : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); TimeFrame(); diff --git a/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index 9a027f1e07..f40e90bd17 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ namespace documentation { struct Documentation; } class Translation : public properties::PropertyOwner { public: - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); Translation(); diff --git a/include/openspace/util/memorymanager.h b/include/openspace/util/memorymanager.h index 94f42e55d8..b1be10738d 100644 --- a/include/openspace/util/memorymanager.h +++ b/include/openspace/util/memorymanager.h @@ -31,7 +31,7 @@ namespace openspace { class MemoryManager { public: - ghoul::MemoryPool<2 * 1024 * 1024, false> PersistentMemory; + ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory; ghoul::MemoryPool<10 * 1024, false> TemporaryMemory; }; diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index 7c6338ea75..d3698cac2d 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -125,7 +126,7 @@ protected: std::vector _indexArray; /// The Translation object that provides the position of the individual trail points - std::unique_ptr _translation; + ghoul::mm_unique_ptr _translation; /// The RenderInformation contains information filled in by the concrete subclasses to /// be used by this class. diff --git a/modules/base/rotation/timelinerotation.cpp b/modules/base/rotation/timelinerotation.cpp index 533fd21e47..53657cc1cf 100644 --- a/modules/base/rotation/timelinerotation.cpp +++ b/modules/base/rotation/timelinerotation.cpp @@ -74,7 +74,7 @@ TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) { for (const std::string& timeString : timeStrings) { const double t = Time::convertTime(timeString); - std::unique_ptr rotation = + ghoul::mm_unique_ptr rotation = Rotation::createFromDictionary( keyframes.value(timeString) ); @@ -87,7 +87,7 @@ TimelineRotation::TimelineRotation(const ghoul::Dictionary& dictionary) { glm::dmat3 TimelineRotation::matrix(const UpdateData& data) const { const double now = data.time.j2000Seconds(); - using KeyframePointer = const Keyframe>*; + using KeyframePointer = const Keyframe>*; KeyframePointer prev = _timeline.lastKeyframeBefore(now, true); KeyframePointer next = _timeline.firstKeyframeAfter(now, true); diff --git a/modules/base/rotation/timelinerotation.h b/modules/base/rotation/timelinerotation.h index a5f6a3b41a..7e1a7d9132 100644 --- a/modules/base/rotation/timelinerotation.h +++ b/modules/base/rotation/timelinerotation.h @@ -41,7 +41,7 @@ public: static documentation::Documentation Documentation(); private: - Timeline> _timeline; + Timeline> _timeline; }; } // namespace openspace diff --git a/modules/base/timeframe/timeframeunion.h b/modules/base/timeframe/timeframeunion.h index 0b3c761859..27a0344e7b 100644 --- a/modules/base/timeframe/timeframeunion.h +++ b/modules/base/timeframe/timeframeunion.h @@ -42,7 +42,7 @@ public: static documentation::Documentation Documentation(); private: - std::vector> _timeFrames; + std::vector> _timeFrames; }; } // namespace openspace diff --git a/modules/base/translation/timelinetranslation.cpp b/modules/base/translation/timelinetranslation.cpp index 396e39e27f..6cf6da3195 100644 --- a/modules/base/translation/timelinetranslation.cpp +++ b/modules/base/translation/timelinetranslation.cpp @@ -74,7 +74,7 @@ TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) { for (const std::string& timeString : timeStrings) { const double t = Time::convertTime(timeString); - std::unique_ptr translation = + ghoul::mm_unique_ptr translation = Translation::createFromDictionary( keyframes.value(timeString) ); @@ -87,7 +87,7 @@ TimelineTranslation::TimelineTranslation(const ghoul::Dictionary& dictionary) { glm::dvec3 TimelineTranslation::position(const UpdateData& data) const { const double now = data.time.j2000Seconds(); - using KeyframePointer = const Keyframe>*; + using KeyframePointer = const Keyframe>*; KeyframePointer prev = _timeline.lastKeyframeBefore(now, true); KeyframePointer next = _timeline.firstKeyframeAfter(now, true); diff --git a/modules/base/translation/timelinetranslation.h b/modules/base/translation/timelinetranslation.h index 86ef39af60..238922edd0 100644 --- a/modules/base/translation/timelinetranslation.h +++ b/modules/base/translation/timelinetranslation.h @@ -27,6 +27,7 @@ #include #include +#include namespace openspace { @@ -42,7 +43,7 @@ public: static documentation::Documentation Documentation(); private: - Timeline> _timeline; + Timeline> _timeline; }; } // namespace openspace diff --git a/modules/space/rotation/spicerotation.h b/modules/space/rotation/spicerotation.h index b1c0cb3ec5..c10c31e38c 100644 --- a/modules/space/rotation/spicerotation.h +++ b/modules/space/rotation/spicerotation.h @@ -46,7 +46,7 @@ public: private: properties::StringProperty _sourceFrame; properties::StringProperty _destinationFrame; - std::unique_ptr _timeFrame; + ghoul::mm_unique_ptr _timeFrame; }; } // namespace openspace diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index a74ca1147b..453e040829 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -100,7 +100,7 @@ documentation::Documentation Renderable::Documentation() { }; } -std::unique_ptr Renderable::createFromDictionary( +ghoul::mm_unique_ptr Renderable::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Renderable"); @@ -111,10 +111,10 @@ std::unique_ptr Renderable::createFromDictionary( ghoul_assert(factory, "Renderable factory did not exist"); Renderable* result = factory->create( renderableType, - dictionary/*, - &global::memoryManager.PersistentMemory*/ + dictionary, + &global::memoryManager.PersistentMemory ); - return std::unique_ptr(result); + return ghoul::mm_unique_ptr(result); } diff --git a/src/scene/rotation.cpp b/src/scene/rotation.cpp index 7e184bf53b..9c26296f87 100644 --- a/src/scene/rotation.cpp +++ b/src/scene/rotation.cpp @@ -61,7 +61,7 @@ documentation::Documentation Rotation::Documentation() { }; } -std::unique_ptr Rotation::createFromDictionary( +ghoul::mm_unique_ptr Rotation::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Rotation"); @@ -70,10 +70,10 @@ std::unique_ptr Rotation::createFromDictionary( auto factory = FactoryManager::ref().factory(); Rotation* result = factory->create( rotationType, - dictionary/*, - &global::memoryManager.PersistentMemory*/ + dictionary, + &global::memoryManager.PersistentMemory ); - return std::unique_ptr(result); + return ghoul::mm_unique_ptr(result); } Rotation::Rotation() : properties::PropertyOwner({ "Rotation" }) {} diff --git a/src/scene/scale.cpp b/src/scene/scale.cpp index d8fc7fdac4..2083dcb172 100644 --- a/src/scene/scale.cpp +++ b/src/scene/scale.cpp @@ -60,7 +60,7 @@ documentation::Documentation Scale::Documentation() { }; } -std::unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { +ghoul::mm_unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Scale"); std::string scaleType = dictionary.value(KeyType); @@ -68,11 +68,11 @@ std::unique_ptr Scale::createFromDictionary(const ghoul::Dictionary& dict auto factory = FactoryManager::ref().factory(); Scale* result = factory->create( scaleType, - dictionary/*, - &global::memoryManager.PersistentMemory*/ + dictionary, + &global::memoryManager.PersistentMemory ); result->setIdentifier("Scale"); - return std::unique_ptr(result); + return ghoul::mm_unique_ptr(result); } Scale::Scale() : properties::PropertyOwner({ "Scale" }) {} diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index ae6176981c..935f54852d 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -146,7 +146,6 @@ ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( ); SceneGraphNode* n = global::memoryManager.PersistentMemory.alloc(); - //SceneGraphNode* n = new SceneGraphNode; ghoul::mm_unique_ptr result = ghoul::mm_unique_ptr(n); #ifdef Debugging_Core_SceneGraphNode_Indices @@ -316,17 +315,14 @@ SceneGraphNode::SceneGraphNode() , _guiPath(GuiPathInfo) , _guiDisplayName(GuiNameInfo) , _transform { - std::unique_ptr( - new StaticTranslation - //global::memoryManager.PersistentMemory.alloc() + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() ), - std::unique_ptr( - new StaticRotation - //global::memoryManager.PersistentMemory.alloc() + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() ), - std::unique_ptr( - new StaticScale - //global::memoryManager.PersistentMemory.alloc() + ghoul::mm_unique_ptr( + global::memoryManager.PersistentMemory.alloc() ) } , _boundingSphere(properties::FloatProperty(BoundingSphereInfo, 0.f)) @@ -944,11 +940,6 @@ float SceneGraphNode::boundingSphere() const { return _boundingSphere; } -// renderable -void SceneGraphNode::setRenderable(std::unique_ptr renderable) { - _renderable = std::move(renderable); -} - const Renderable* SceneGraphNode::renderable() const { return _renderable.get(); } diff --git a/src/scene/timeframe.cpp b/src/scene/timeframe.cpp index 01282e18ca..ce01f44227 100644 --- a/src/scene/timeframe.cpp +++ b/src/scene/timeframe.cpp @@ -60,7 +60,7 @@ documentation::Documentation TimeFrame::Documentation() { }; } -std::unique_ptr TimeFrame::createFromDictionary( +ghoul::mm_unique_ptr TimeFrame::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "TimeFrame"); @@ -74,7 +74,7 @@ std::unique_ptr TimeFrame::createFromDictionary( &global::memoryManager.PersistentMemory*/ ); result->setIdentifier("TimeFrame"); - return std::unique_ptr(result); + return ghoul::mm_unique_ptr(result); } TimeFrame::TimeFrame() : properties::PropertyOwner({ "TimeFrame" }) {} diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index fdec079e68..17d1aa1bbb 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -60,7 +60,7 @@ documentation::Documentation Translation::Documentation() { }; } -std::unique_ptr Translation::createFromDictionary( +ghoul::mm_unique_ptr Translation::createFromDictionary( const ghoul::Dictionary& dictionary) { documentation::testSpecificationAndThrow(Documentation(), dictionary, "Translation"); @@ -70,11 +70,11 @@ std::unique_ptr Translation::createFromDictionary( = FactoryManager::ref().factory(); Translation* result = factory->create( translationType, - dictionary/*, - &global::memoryManager.PersistentMemory*/ + dictionary, + &global::memoryManager.PersistentMemory ); result->setIdentifier("Translation"); - return std::unique_ptr(result); + return ghoul::mm_unique_ptr(result); } Translation::Translation() : properties::PropertyOwner({ "Translation" }) {}