diff --git a/include/openspace/engine/globals.h b/include/openspace/engine/globals.h index 0bf76957f5..5b9159abd7 100644 --- a/include/openspace/engine/globals.h +++ b/include/openspace/engine/globals.h @@ -59,7 +59,6 @@ namespace interaction { class SessionRecording; class ShortcutManager; } // namespace interaction -namespace performance { class PerformanceManager; } namespace properties { class PropertyOwner; } namespace scripting { class ScriptEngine; @@ -96,7 +95,6 @@ interaction::KeybindingManager& gKeybindingManager(); interaction::NavigationHandler& gNavigationHandler(); interaction::SessionRecording& gSessionRecording(); interaction::ShortcutManager& gShortcutManager(); -performance::PerformanceManager& gPerformanceManager(); properties::PropertyOwner& gRootPropertyOwner(); properties::PropertyOwner& gScreenSpaceRootPropertyOwner(); scripting::ScriptEngine& gScriptEngine(); @@ -134,8 +132,6 @@ static interaction::KeybindingManager& keybindingManager = detail::gKeybindingMa static interaction::NavigationHandler& navigationHandler = detail::gNavigationHandler(); static interaction::SessionRecording& sessionRecording = detail::gSessionRecording(); static interaction::ShortcutManager& shortcutManager = detail::gShortcutManager(); -static performance::PerformanceManager& performanceManager = - detail::gPerformanceManager(); static properties::PropertyOwner& rootPropertyOwner = detail::gRootPropertyOwner(); static properties::PropertyOwner& screenSpaceRootPropertyOwner = detail::gScreenSpaceRootPropertyOwner(); diff --git a/include/openspace/performance/performancelayout.h b/include/openspace/performance/performancelayout.h deleted file mode 100644 index 85d325cf45..0000000000 --- a/include/openspace/performance/performancelayout.h +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ -#define __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ - -#include - -namespace openspace::performance { - -struct PerformanceLayout { - constexpr static const int8_t Version = 0; - constexpr static const int LengthName = 256; - constexpr static const int NumberValues = 256; - constexpr static const int MaxValues = 1024; - - PerformanceLayout(); - - struct SceneGraphPerformanceLayout { - char name[LengthName]; - float renderTime[NumberValues]; - float updateRenderable[NumberValues]; - float updateTranslation[NumberValues]; - float updateRotation[NumberValues]; - float updateScaling[NumberValues]; - }; - SceneGraphPerformanceLayout sceneGraphEntries[MaxValues] = {}; - int16_t nScaleGraphEntries = 0; - - struct FunctionPerformanceLayout { - char name[LengthName]; - float time[NumberValues]; - }; - FunctionPerformanceLayout functionEntries[MaxValues] = {}; - int16_t nFunctionEntries = 0; -}; - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCELAYOUT___H__ diff --git a/include/openspace/performance/performancemanager.h b/include/openspace/performance/performancemanager.h deleted file mode 100644 index 4c37fd5b81..0000000000 --- a/include/openspace/performance/performancemanager.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ -#define __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ - -#include -#include -#include -#include - -namespace ghoul { class SharedMemory; } -namespace openspace { class SceneGraphNode; } - -namespace openspace::performance { - -struct PerformanceLayout; - -class PerformanceManager { -public: - static void CreateGlobalSharedMemory(); - static void DestroyGlobalSharedMemory(); - - void setEnabled(bool enabled); - bool isEnabled() const; - - void resetPerformanceMeasurements(); - - void storeIndividualPerformanceMeasurement(const std::string& identifier, - long long microseconds); - void storeScenePerformanceMeasurements( - const std::vector& sceneNodes); - - void outputLogs(); - - void writeData(std::ofstream& out, const std::vector& data); - - std::string formatLogName(std::string nodeName); - - void logDir(std::string dir); - const std::string& logDir() const; - void prefix(std::string prefix); - const std::string& prefix() const; - - void enableLogging(); - void disableLogging(); - void toggleLogging(); - void setLogging(bool enabled); - bool loggingEnabled() const; - - PerformanceLayout* performanceData(); - -private: - bool _performanceMeasurementEnabled = false; - bool _loggingEnabled = false; - - std::string _logDir; - std::string _prefix; - std::string _ext = "log"; - - std::map individualPerformanceLocations; - - std::unique_ptr _performanceMemory; - - size_t _currentTick = 0; - - void tick(); - bool createLogDir(); -}; - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCEMANAGER___H__ diff --git a/include/openspace/performance/performancemeasurement.h b/include/openspace/performance/performancemeasurement.h deleted file mode 100644 index 3222a72479..0000000000 --- a/include/openspace/performance/performancemeasurement.h +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ -#define __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ - -#include -#include - -namespace openspace::performance { - -class PerformanceManager; - -class PerformanceMeasurement { -public: - PerformanceMeasurement(std::string identifier); - ~PerformanceMeasurement(); - -private: - std::string _identifier; - std::chrono::high_resolution_clock::time_point _startTime; -}; - -#define __MERGE_PerfMeasure(a,b) a##b -#define __LABEL_PerfMeasure(a) __MERGE_PerfMeasure(unique_name_, a) - -/// Declare a new variable for measuring the performance of the current block -#define PerfMeasure(name) \ - auto __LABEL_PerfMeasure(__LINE__) = \ - openspace::performance::PerformanceMeasurement((name)) - -} // namespace openspace::performance - -#endif // __OPENSPACE_CORE___PERFORMANCEMEASUREMENT___H__ diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index f850018ea2..152f494e0c 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -179,8 +179,6 @@ private: Camera* _camera = nullptr; Scene* _scene = nullptr; - properties::BoolProperty _doPerformanceMeasurements; - std::unique_ptr _renderer; RendererImplementation _rendererImplementation = RendererImplementation::Invalid; ghoul::Dictionary _rendererData; diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 67cb8add12..a877bbdcaf 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -71,14 +71,6 @@ public: BooleanType(UpdateScene); - struct PerformanceRecord { - long long renderTime; // time in ns - long long updateTimeRenderable; // time in ns - long long updateTimeTranslation; // time in ns - long long updateTimeRotation; // time in ns - long long updateTimeScaling; // time in ns - }; - static constexpr const char* RootNodeIdentifier = "Root"; static constexpr const char* KeyIdentifier = "Identifier"; static constexpr const char* KeyParentName = "Parent"; @@ -138,8 +130,6 @@ public: SceneGraphNode* childNode(const std::string& identifier); - const PerformanceRecord& performanceRecord() const; - void setRenderable(std::unique_ptr renderable); const Renderable* renderable() const; Renderable* renderable(); @@ -166,8 +156,6 @@ private: // might be a node that is not very interesting (for example barycenters) properties::BoolProperty _guiHidden; - PerformanceRecord _performanceRecord = { 0, 0, 0, 0, 0 }; - std::unique_ptr _renderable; properties::StringProperty _guiPath; diff --git a/include/openspace/util/updatestructures.h b/include/openspace/util/updatestructures.h index 3baf2ac3cc..0613821590 100644 --- a/include/openspace/util/updatestructures.h +++ b/include/openspace/util/updatestructures.h @@ -45,13 +45,11 @@ struct UpdateData { TransformData modelTransform; const Time time; const Time previousFrameTime; - const bool doPerformanceMeasurement; }; struct RenderData { const Camera& camera; const Time time; - bool doPerformanceMeasurement = false; int renderBinMask = -1; TransformData modelTransform; }; diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index b489867cf0..e2c182744a 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -237,8 +237,7 @@ void RenderableTrailOrbit::update(const UpdateData& data) { const glm::vec3 p = _translation->position({ {}, data.time, - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -434,8 +433,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( const glm::vec3 p = _translation->position({ {}, Time(_lastPointTime), - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -474,8 +472,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails( const glm::vec3 p = _translation->position({ {}, Time(_firstPointTime), - Time(0.0), - false + Time(0.0) }); _vertexArray[_primaryRenderInformation.first] = { p.x, p.y, p.z }; @@ -517,7 +514,7 @@ void RenderableTrailOrbit::fullSweep(double time) { const double secondsPerPoint = _period / (_resolution - 1); // starting at 1 because the first position is a floating current one for (int i = 1; i < _resolution; ++i) { - const glm::vec3 p = _translation->position({ {}, Time(time), Time(0.0), false }); + const glm::vec3 p = _translation->position({ {}, Time(time), Time(0.0) }); _vertexArray[i] = { p.x, p.y, p.z }; time -= secondsPerPoint; diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 966ffd51af..5efe975a24 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -227,8 +227,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) { const glm::vec3 p = _translation->position({ {}, Time(_start + i * totalSampleInterval), - Time(0.0), - false + Time(0.0) }); _vertexArray[i] = { p.x, p.y, p.z }; } diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 6eed17af08..7cbb118249 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -34,8 +34,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index 0662c50566..aacf1f8e04 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -350,7 +350,6 @@ RenderData ShadowComponent::begin(const RenderData& data) { RenderData lightRenderData{ *_lightCamera, data.time, - data.doPerformanceMeasurement, data.renderBinMask, data.modelTransform }; diff --git a/modules/imgui/CMakeLists.txt b/modules/imgui/CMakeLists.txt index 0e043a9479..f75334125b 100644 --- a/modules/imgui/CMakeLists.txt +++ b/modules/imgui/CMakeLists.txt @@ -35,7 +35,6 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/guihelpcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guijoystickcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guimissioncomponent.h - ${CMAKE_CURRENT_SOURCE_DIR}/include/guiperformancecomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guiparallelcomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guipropertycomponent.h ${CMAKE_CURRENT_SOURCE_DIR}/include/guishortcutscomponent.h @@ -55,7 +54,6 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/guihelpcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guijoystickcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guimissioncomponent.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/guiperformancecomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guiparallelcomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guipropertycomponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/guishortcutscomponent.cpp diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index a4a873c267..7cc9fd6fab 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -184,9 +184,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() ||gui._sceneProperty.isEnabled()) { return gui.keyCallback(key, mod, action); } else { @@ -200,9 +198,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.charCallback(codepoint, modifier); } else { @@ -229,9 +225,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { } // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.mouseButtonCallback(button, action); } else { @@ -245,9 +239,7 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { ZoneScopedN("ImGUI") // A list of all the windows that can show up by themselves - if (gui.isEnabled() || gui._performance.isEnabled() || - gui._sceneProperty.isEnabled()) - { + if (gui.isEnabled() || gui._sceneProperty.isEnabled()) { return gui.mouseWheelCallback(posY); } else { diff --git a/modules/imgui/include/gui.h b/modules/imgui/include/gui.h index e428631d89..d2f4af5976 100644 --- a/modules/imgui/include/gui.h +++ b/modules/imgui/include/gui.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -63,7 +62,7 @@ namespace openspace::gui { namespace detail { constexpr int nComponents() { - const int nRegularComponents = 16; + const int nRegularComponents = 15; int totalComponents = nRegularComponents; #ifdef OPENSPACE_MODULE_ISWA_ENABLED @@ -106,7 +105,6 @@ public: GuiFilePathComponent _filePath; GuiAssetComponent _asset; GuiGlobeBrowsingComponent _globeBrowsing; - GuiPerformanceComponent _performance; GuiPropertyComponent _globalProperty; GuiPropertyComponent _sceneProperty; @@ -153,8 +151,6 @@ private: &_joystick, &_filePath, - &_performance, - &_help }; diff --git a/modules/imgui/include/guiperformancecomponent.h b/modules/imgui/include/guiperformancecomponent.h deleted file mode 100644 index 36bbd7c146..0000000000 --- a/modules/imgui/include/guiperformancecomponent.h +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#ifndef __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ -#define __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ - -#include - -#include -#include -#include - -namespace ghoul { class SharedMemory; } - -namespace openspace::gui { - -class GuiPerformanceComponent : public GuiComponent { -public: - GuiPerformanceComponent(); - ~GuiPerformanceComponent(); - - void render() override; - -protected: - std::unique_ptr _performanceMemory; - - properties::IntProperty _sortingSelection; - - properties::BoolProperty _sceneGraphIsEnabled; - properties::BoolProperty _functionsIsEnabled; - properties::BoolProperty _outputLogs; -}; - -} // namespace openspace::gui - -#endif // __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__ diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index 04a6dd092b..d9b4ed4bc2 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -443,12 +442,6 @@ void GUI::endFrame() { ghoul::opengl::updateUniformLocations(*_program, _uniformCache, UniformNames); } - _performance.setEnabled(global::performanceManager.isEnabled()); - - if (_performance.isEnabled()) { - _performance.render(); - } - if (_isEnabled) { render(); @@ -461,8 +454,7 @@ void GUI::endFrame() { ImGui::Render(); - const bool shouldRender = _performance.isEnabled() || _isEnabled; - if (!shouldRender) { + if (!_isEnabled) { return; } diff --git a/modules/imgui/src/guiperformancecomponent.cpp b/modules/imgui/src/guiperformancecomponent.cpp deleted file mode 100644 index 7a7a495e3d..0000000000 --- a/modules/imgui/src/guiperformancecomponent.cpp +++ /dev/null @@ -1,457 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - enum Sorting { - NoSorting = -1, - UpdateTranslation = 0, - UpdateRotation = 1, - UpdateScaling = 2, - UpdateRender = 3, - Render = 4, - Total = 5 - }; - - constexpr openspace::properties::Property::PropertyInfo SortingSelectionInfo = { - "SortingSelection", - "Sorting", - "This value determines the sorting order of the performance measurements." - }; - - constexpr openspace::properties::Property::PropertyInfo SceneGraphEnabledInfo = { - "ShowSceneGraph", - "Show Scene Graph Measurements", - "If this value is enabled, the window showing the measurements for the scene " - "graph values is visible." - }; - - constexpr openspace::properties::Property::PropertyInfo FunctionsEnabledInfo = { - "ShowFunctions", - "Show Function Measurements", - "If this value is enabled, the window showing the measurements for the " - "individual functions is visible." - }; - - constexpr openspace::properties::Property::PropertyInfo OutputLogsInfo = { - "OutputLogs", - "Output Logs", - "" // @TODO Missing documentation - }; - -} // namespace - -namespace openspace::gui { - -GuiPerformanceComponent::GuiPerformanceComponent() - : GuiComponent("PerformanceComponent", "Performance Component") - , _sortingSelection(SortingSelectionInfo, -1, -1, 6) - , _sceneGraphIsEnabled(SceneGraphEnabledInfo, false) - , _functionsIsEnabled(FunctionsEnabledInfo, false) - , _outputLogs(OutputLogsInfo, false) -{ - addProperty(_sortingSelection); - - addProperty(_sceneGraphIsEnabled); - addProperty(_functionsIsEnabled); - addProperty(_outputLogs); -} - -GuiPerformanceComponent::~GuiPerformanceComponent() {} // NOLINT - -void GuiPerformanceComponent::render() { - if (!global::performanceManager.isEnabled()) { - return; - } - - using ghoul::SharedMemory; - using namespace performance; - - ImGui::SetNextWindowCollapsed(_isCollapsed); - bool v = _isEnabled; - ImGui::Begin("Performance", &v); - _isEnabled = v; - _isCollapsed = ImGui::IsWindowCollapsed(); - - PerformanceLayout* layout = global::performanceManager.performanceData(); - - v = _sceneGraphIsEnabled; - ImGui::Checkbox("SceneGraph", &v); - _sceneGraphIsEnabled = v; - v = _functionsIsEnabled; - ImGui::Checkbox("Functions", &v); - _functionsIsEnabled = v; - v = _outputLogs; - ImGui::Checkbox("Output Logs", &v); - global::performanceManager.setLogging(v); - // Need to catch if it's unsuccessful - v = global::performanceManager.loggingEnabled(); - _outputLogs = v; - - ImGui::Spacing(); - - if (ImGui::Button("Reset measurements")) { - global::performanceManager.resetPerformanceMeasurements(); - } - - if (_sceneGraphIsEnabled) { - bool sge = _sceneGraphIsEnabled; - ImGui::Begin("SceneGraph", &sge); - _sceneGraphIsEnabled = sge; - - // The indices correspond to the index into the average array further below - ImGui::Text("Sorting"); - int sorting = _sortingSelection; - ImGui::RadioButton("No Sorting", &sorting, Sorting::NoSorting); - ImGui::RadioButton("UpdateTranslation", &sorting, Sorting::UpdateTranslation); - ImGui::RadioButton("UpdateRotation", &sorting, Sorting::UpdateRotation); - ImGui::RadioButton("UpdateScaling", &sorting, Sorting::UpdateScaling); - ImGui::RadioButton("UpdateRender", &sorting, Sorting::UpdateRender); - ImGui::RadioButton("RenderTime", &sorting, Sorting::Render); - ImGui::RadioButton("TotalTime", &sorting, Sorting::Total); - _sortingSelection = sorting; - - // Later, we will sort this indices list instead of the real values for - // performance reasons - std::vector indices(layout->nScaleGraphEntries); - std::iota(indices.begin(), indices.end(), 0); - - // Ordering: - // updateTranslation - // updateRotation - // updateScaling - // UpdateRender - // RenderTime - std::vector> averages( - layout->nScaleGraphEntries, - { 0.f, 0.f, 0.f, 0.f, 0.f } - ); - - std::vector, 5>> minMax( - layout->nScaleGraphEntries - ); - - for (int i = 0; i < layout->nScaleGraphEntries; ++i) { - const PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[i]; - - int nValues[5] = { 0, 0, 0, 0, 0 }; - - // Compute the averages and count the number of values so we don't divide - // by 0 later - for (int j = 0; j < PerformanceLayout::NumberValues; ++j) { - averages[i][0] += entry.updateTranslation[j]; - if (entry.updateTranslation[j] != 0.f) { - ++(nValues[0]); - } - averages[i][1] += entry.updateRotation[j]; - if (entry.updateRotation[j] != 0.f) { - ++(nValues[1]); - } - averages[i][2] += entry.updateScaling[j]; - if (entry.updateScaling[j] != 0.f) { - ++(nValues[2]); - } - averages[i][3] += entry.updateRenderable[j]; - if (entry.updateRenderable[j] != 0.f) { - ++(nValues[3]); - } - averages[i][4] += entry.renderTime[j]; - if (entry.renderTime[j] != 0.f) { - ++(nValues[4]); - } - } - - if (nValues[0] != 0) { - averages[i][0] /= static_cast(nValues[0]); - } - if (nValues[1] != 0) { - averages[i][1] /= static_cast(nValues[1]); - } - if (nValues[2] != 0) { - averages[i][2] /= static_cast(nValues[2]); - } - if (nValues[3] != 0) { - averages[i][3] /= static_cast(nValues[3]); - } - if (nValues[4] != 0) { - averages[i][4] /= static_cast(nValues[4]); - } - - // Get the minimum/maximum values for each of the components so that we - // can scale the plot by these numbers - auto minmaxTranslation = std::minmax_element( - std::begin(entry.updateTranslation), - std::end(entry.updateTranslation) - ); - minMax[i][0] = std::make_pair( - *(minmaxTranslation.first), - *(minmaxTranslation.second) - ); - - auto minmaxRotation = std::minmax_element( - std::begin(entry.updateRotation), - std::end(entry.updateRotation) - ); - minMax[i][1] = std::make_pair( - *(minmaxRotation.first), - *(minmaxRotation.second) - ); - - auto minmaxScaling = std::minmax_element( - std::begin(entry.updateScaling), - std::end(entry.updateScaling) - ); - minMax[i][2] = std::make_pair( - *(minmaxScaling.first), - *(minmaxScaling.second) - ); - - auto minmaxUpdateRenderable = std::minmax_element( - std::begin(entry.updateRenderable), - std::end(entry.updateRenderable) - ); - minMax[i][3] = std::make_pair( - *(minmaxUpdateRenderable.first), - *(minmaxUpdateRenderable.second) - ); - - auto minmaxRendering = std::minmax_element( - std::begin(entry.renderTime), - std::end(entry.renderTime) - ); - minMax[i][4] = std::make_pair( - *(minmaxRendering.first), - *(minmaxRendering.second) - ); - } - - // If we don't want to sort, we will leave the indices list alone, thus - // leaving them in the regular ordering - Sorting selection = Sorting(sorting); - if (selection != Sorting::NoSorting) { - std::function sortFunc; - - if (selection == Sorting::Total) { - // If we do want to sort totally, we need to sum all the averages and - // use that as the criterion - sortFunc = [&averages](size_t a, size_t b) { - const float sumA = std::accumulate( - std::begin(averages[a]), - std::end(averages[a]), - 0.f - ); - - const float sumB = std::accumulate( - std::begin(averages[b]), - std::end(averages[b]), - 0.f - ); - - return sumA > sumB; - }; - } - else { - // otherwise we use the sorting index - sortFunc = [sel = _sortingSelection, &averages](size_t a, size_t b) { - return averages[a][sel] > averages[b][sel]; - }; - } - - std::sort(indices.begin(), indices.end(), sortFunc); - } - else { - // NoSorting -> So we sort by names instead - std::sort( - indices.begin(), - indices.end(), - [layout](size_t a, size_t b) { - return std::string(layout->sceneGraphEntries[a].name) < - std::string(layout->sceneGraphEntries[b].name); - } - ); - } - - for (int i = 0; i < layout->nScaleGraphEntries; ++i) { - // We are using the indices list as an additional level of indirection - // into the respective values so that the list will be sorted by whatever - // criterion we selected previously - - const PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[indices[i]]; - - if (ImGui::CollapsingHeader(entry.name)) { - const std::string& updateTranslationTime = std::to_string( - entry.updateTranslation[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateTranslation\nAverage: {}us", - averages[indices[i]][0] - ).c_str(), - &entry.updateTranslation[0], - PerformanceLayout::NumberValues, - 0, - updateTranslationTime.c_str(), - minMax[indices[i]][0].first, - minMax[indices[i]][0].second, - ImVec2(0, 40) - ); - - const std::string& updateRotationTime = std::to_string( - entry.updateRotation[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateRotation\nAverage: {}us", - averages[indices[i]][1] - ).c_str(), - &entry.updateRotation[0], - PerformanceLayout::NumberValues, - 0, - updateRotationTime.c_str(), - minMax[indices[i]][1].first, - minMax[indices[i]][1].second, - ImVec2(0, 40) - ); - - const std::string& updateScalingTime = std::to_string( - entry.updateScaling[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateScaling\nAverage: {}us", - averages[indices[i]][2] - ).c_str(), - &entry.updateScaling[0], - PerformanceLayout::NumberValues, - 0, - updateScalingTime.c_str(), - minMax[indices[i]][2].first, - minMax[indices[i]][2].second, - ImVec2(0, 40) - ); - - const std::string& updateRenderableTime = std::to_string( - entry.updateRenderable[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "UpdateRender\nAverage: {}us", - averages[indices[i]][3] - ).c_str(), - &entry.updateRenderable[0], - PerformanceLayout::NumberValues, - 0, - updateRenderableTime.c_str(), - minMax[indices[i]][3].first, - minMax[indices[i]][3].second, - ImVec2(0, 40) - ); - - const std::string& renderTime = std::to_string( - entry.renderTime[PerformanceLayout::NumberValues - 1] - ) + "us"; - - ImGui::PlotLines( - fmt::format( - "RenderTime\nAverage: {}us", - averages[indices[i]][4] - ).c_str(), - &entry.renderTime[0], - PerformanceLayout::NumberValues, - 0, - renderTime.c_str(), - minMax[indices[i]][4].first, - minMax[indices[i]][4].second, - ImVec2(0, 40) - ); - } - } - ImGui::End(); - } - - if (_functionsIsEnabled) { - bool fe = _functionsIsEnabled; - ImGui::Begin("Functions", &fe); - _functionsIsEnabled = fe; - - for (int i = 0; i < layout->nFunctionEntries; ++i) { - using namespace performance; - - const PerformanceLayout::FunctionPerformanceLayout& entry = - layout->functionEntries[i]; - - float avg = 0.f; - int count = 0; - for (int j = 0; j < PerformanceLayout::NumberValues; ++j) { - avg += layout->functionEntries[i].time[j]; - if (layout->functionEntries[i].time[j] != 0.f) { - ++count; - } - } - if (count > 0) { - avg /= count; - } - - auto minmax = std::minmax_element( - std::begin(layout->functionEntries[i].time), - std::end(layout->functionEntries[i].time) - ); - - const std::string& renderTime = std::to_string( - entry.time[PerformanceLayout::NumberValues - 1] - ) + "us"; - ImGui::PlotLines( - fmt::format("{}\nAverage: {}us", entry.name, avg).c_str(), - &entry.time[0], - PerformanceLayout::NumberValues, - 0, - renderTime.c_str(), - *(minmax.first), - *(minmax.second), - ImVec2(0, 40) - ); - } - ImGui::End(); - } - - ImGui::End(); -} - -} // namespace openspace::gui diff --git a/modules/space/rendering/renderableorbitalkepler.cpp b/modules/space/rendering/renderableorbitalkepler.cpp index 2ec587e4cb..5e902942d2 100644 --- a/modules/space/rendering/renderableorbitalkepler.cpp +++ b/modules/space/rendering/renderableorbitalkepler.cpp @@ -546,8 +546,7 @@ void RenderableOrbitalKepler::updateBuffers() { glm::dvec3 position = _keplerTranslator.position({ {}, Time(timeOffset + orbit.epoch), - Time(0.0), - false + Time(0.0) }); _vertexBufferData[vertexBufIdx].x = static_cast(position.x); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ea989bb7b..fb1b06b0c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -70,9 +70,6 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/network/parallelpeer.cpp ${OPENSPACE_BASE_DIR}/src/network/parallelpeer_lua.inl ${OPENSPACE_BASE_DIR}/src/network/parallelserver.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancemeasurement.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancelayout.cpp - ${OPENSPACE_BASE_DIR}/src/performance/performancemanager.cpp ${OPENSPACE_BASE_DIR}/src/properties/optionproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/property.cpp ${OPENSPACE_BASE_DIR}/src/properties/propertyowner.cpp @@ -253,9 +250,6 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/network/parallelpeer.h ${OPENSPACE_BASE_DIR}/include/openspace/network/parallelserver.h ${OPENSPACE_BASE_DIR}/include/openspace/network/messagestructures.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancemeasurement.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancelayout.h - ${OPENSPACE_BASE_DIR}/include/openspace/performance/performancemanager.h ${OPENSPACE_BASE_DIR}/include/openspace/properties/numericalproperty.h ${OPENSPACE_BASE_DIR}/include/openspace/properties/numericalproperty.inl ${OPENSPACE_BASE_DIR}/include/openspace/properties/optionproperty.h diff --git a/src/engine/globals.cpp b/src/engine/globals.cpp index 34effc2cc5..43924ce9e2 100644 --- a/src/engine/globals.cpp +++ b/src/engine/globals.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -188,11 +187,6 @@ interaction::ShortcutManager& gShortcutManager() { return g; } -performance::PerformanceManager& gPerformanceManager() { - static performance::PerformanceManager g; - return g; -} - properties::PropertyOwner& gRootPropertyOwner() { static properties::PropertyOwner g({ "" }); return g; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index ecb0e65150..cf84e4ecff 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -41,8 +41,6 @@ #include #include #include -#include -#include #include #include #include @@ -1057,18 +1055,8 @@ void OpenSpaceEngine::writeSceneDocumentation() { void OpenSpaceEngine::preSynchronization() { ZoneScoped - LTRACE("OpenSpaceEngine::preSynchronization(begin)"); - //std::this_thread::sleep_for(std::chrono::milliseconds(10)); - - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::preSynchronization" - ); - } - FileSys.triggerFilesystemEvents(); if (_hasScheduledAssetLoading) { @@ -1132,16 +1120,8 @@ void OpenSpaceEngine::preSynchronization() { void OpenSpaceEngine::postSynchronizationPreDraw() { ZoneScoped - LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::postSynchronizationPreDraw" - ); - } - bool master = global::windowDelegate.isMaster(); global::syncEngine.postSynchronization(SyncEngine::IsMaster(master)); @@ -1209,16 +1189,8 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view const glm::mat4& projectionMatrix) { ZoneScoped - LTRACE("OpenSpaceEngine::render(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::render" - ); - } - const bool isGuiWindow = global::windowDelegate.hasGuiWindow() ? global::windowDelegate.isGuiWindow() : @@ -1241,16 +1213,8 @@ void OpenSpaceEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& view void OpenSpaceEngine::drawOverlays() { ZoneScoped - LTRACE("OpenSpaceEngine::drawOverlays(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::drawOverlays" - ); - } - const bool isGuiWindow = global::windowDelegate.hasGuiWindow() ? global::windowDelegate.isGuiWindow() : @@ -1260,7 +1224,6 @@ void OpenSpaceEngine::drawOverlays() { global::renderEngine.renderOverlays(_shutdown); global::luaConsole.render(); global::sessionRecording.render(); - } for (const std::function& func : global::callback::draw2D) { @@ -1274,16 +1237,8 @@ void OpenSpaceEngine::drawOverlays() { void OpenSpaceEngine::postDraw() { ZoneScoped - LTRACE("OpenSpaceEngine::postDraw(begin)"); - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "OpenSpaceEngine::postDraw" - ); - } - global::renderEngine.postDraw(); for (const std::function& func : global::callback::postDraw) { diff --git a/src/performance/performancelayout.cpp b/src/performance/performancelayout.cpp deleted file mode 100644 index 0fbbb12788..0000000000 --- a/src/performance/performancelayout.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include - -#include - -namespace openspace::performance { - -PerformanceLayout::PerformanceLayout() { - std::memset( - sceneGraphEntries, - 0, - MaxValues * sizeof(SceneGraphPerformanceLayout) - ); - - std::memset( - functionEntries, - 0, - MaxValues * sizeof(FunctionPerformanceLayout) - ); -} - -} // namespace openspace::performance diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp deleted file mode 100644 index bd4b60096c..0000000000 --- a/src/performance/performancemanager.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace { - constexpr const char* _loggerCat = "PerformanceManager"; - - constexpr const char* GlobalSharedMemoryName = "OpenSpacePerformanceMeasurementData"; - // Probably 255 performance blocks per node are enough, so we can get away with - // 4 bytes (one uint8_t for the number, one uint8_t for the reference count to keep - // the global memory alive, and 2 bytes to enforce alignment) - constexpr const size_t GlobalSharedMemorySize = 4; - - struct GlobalMemory { - uint8_t number; - uint8_t referenceCount; - - std::array alignment; - }; - - constexpr const char* LocalSharedMemoryNameBase = "PerformanceMeasurement_"; -} // namespace - -namespace openspace::performance { - -// The Performance Manager will use a level of indirection in order to support multiple -// PerformanceManagers running in parallel: -// The ghoul::SharedData block addressed by OpenSpacePerformanceMeasurementSharedData -// will only get allocated once and contains the total number of allocated shared memory -// blocks alongside a list of names of these blocks - -void PerformanceManager::CreateGlobalSharedMemory() { - static_assert( - sizeof(GlobalMemory) == GlobalSharedMemorySize, - "The global memory struct does not fit the allocated global memory space" - ); - - if (ghoul::SharedMemory::exists(GlobalSharedMemoryName)) { - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - ++(m->referenceCount); - LINFO(fmt::format( - "Using global shared memory block for performance measurements. " - "Reference count: {}", - int(m->referenceCount) - )); - sharedMemory.releaseLock(); - } - else { - LINFO("Creating global shared memory block for performance measurements"); - ghoul::SharedMemory::create(GlobalSharedMemoryName, GlobalSharedMemorySize); - - // Initialize the data - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - new (sharedMemory.memory()) GlobalMemory; - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - m->number = 0; - m->referenceCount = 1; - sharedMemory.releaseLock(); - } -} - -void PerformanceManager::DestroyGlobalSharedMemory() { - if (!ghoul::SharedMemory::exists(GlobalSharedMemoryName)) { - LWARNING("Global shared memory for Performance measurements did not exist"); - return; - } - - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - --(m->referenceCount); - LINFO(fmt::format( - "Global shared performance memory reference count: {}", - static_cast(m->referenceCount) - )); - if (m->referenceCount == 0) { - LINFO("Removing global shared performance memory"); - - // When the global memory is deleted, we have to get rid of all local memory as - // well. In principle, none should be left, but OpenSpace crashing might leave - // some of the memory orphaned - for (int i = 0; i < std::numeric_limits::max(); ++i) { - std::string localName = LocalSharedMemoryNameBase + std::to_string(i); - if (ghoul::SharedMemory::exists(localName)) { - LINFO(fmt::format("Removing shared memory: {}", localName)); - ghoul::SharedMemory::remove(localName); - } - } - - ghoul::SharedMemory::remove(GlobalSharedMemoryName); - } - sharedMemory.releaseLock(); -} - -void PerformanceManager::setEnabled(bool enabled) { - _logDir = absPath("${BASE}"); - _prefix = "PM-"; - - _performanceMeasurementEnabled = enabled; - - if (enabled) { - PerformanceManager::CreateGlobalSharedMemory(); - - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - defer { - sharedMemory.releaseLock(); - }; - - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - - // The the first free block (which also coincides with the number of blocks - uint8_t blockIndex = m->number; - ++(m->number); - - const std::string& localName = LocalSharedMemoryNameBase + - std::to_string(blockIndex); - - // Compute the total size - const int totalSize = sizeof(PerformanceLayout); - LINFO(fmt::format("Create shared memory '{}' of {} bytes", localName, totalSize)); - - if (ghoul::SharedMemory::exists(localName)) { - throw ghoul::RuntimeError( - "Shared Memory '" + localName + "' block already existed" - ); - } - - ghoul::SharedMemory::create(localName, totalSize); - - _performanceMemory = std::make_unique(localName); - // Using the placement-new to create a PerformanceLayout in the shared memory - new (_performanceMemory->memory()) PerformanceLayout; - } - else { - if (loggingEnabled()) { - outputLogs(); - } - - if (_performanceMemory) { - ghoul::SharedMemory sharedMemory(GlobalSharedMemoryName); - sharedMemory.acquireLock(); - GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); - --(m->number); - sharedMemory.releaseLock(); - - LINFO(fmt::format("Remove shared memory '{}'", _performanceMemory->name())); - ghoul::SharedMemory::remove(_performanceMemory->name()); - - _performanceMemory = nullptr; - } - - PerformanceManager::DestroyGlobalSharedMemory(); - } -} - -bool PerformanceManager::isEnabled() const { - return _performanceMeasurementEnabled; -} - -void PerformanceManager::resetPerformanceMeasurements() { - // Using the placement-new to create a PerformanceLayout in the shared memory - _performanceMemory->acquireLock(); - new (_performanceMemory->memory()) PerformanceLayout; - _performanceMemory->releaseLock(); - - individualPerformanceLocations.clear(); -} - -void PerformanceManager::outputLogs() { - // Log Layout values - PerformanceLayout* layout = performanceData(); - const size_t writeStart = (PerformanceLayout::NumberValues - 1) - _currentTick; - - // Log function performance - for (int16_t n = 0; n < layout->nFunctionEntries; n++) { - const PerformanceLayout::FunctionPerformanceLayout& function = - layout->functionEntries[n]; - std::string filename = formatLogName(function.name); - std::ofstream out = std::ofstream( - absPath(std::move(filename)), - std::ofstream::out | std::ofstream::app - ); - - // Comma separate data - for (size_t i = writeStart; i < PerformanceLayout::NumberValues; i++) { - const std::vector& data = { function.time[i] }; - writeData(out, data); - } - out.close(); - } - - // Log scene object performance - for (int16_t n = 0; n < layout->nScaleGraphEntries; n++) { - const PerformanceLayout::SceneGraphPerformanceLayout node = - layout->sceneGraphEntries[n]; - - // Open file - std::string filename = formatLogName(node.name); - std::ofstream out = std::ofstream( - absPath(std::move(filename)), - std::ofstream::out | std::ofstream::app - ); - - // Comma separate data - for (size_t i = writeStart; i < PerformanceLayout::NumberValues; i++) { - const std::vector data = { - node.renderTime[i], - node.updateRenderable[i], - node.updateRotation[i], - node.updateScaling[i], - node.updateTranslation[i] - }; - writeData(out, data); - } - out.close(); - } -} - -void PerformanceManager::writeData(std::ofstream& out, const std::vector& data) { - for (size_t i = 0; i < data.size() - 1; i++) { - out << data[i] << ","; - } - out << data[data.size() - 1] << "\n"; -} - - std::string PerformanceManager::formatLogName(std::string nodeName) { - // Replace any colons with dashes - std::replace(nodeName.begin(), nodeName.end(), ':', '-'); - // Replace spaces with underscore - std::replace(nodeName.begin(), nodeName.end(), ' ', '_'); - return _logDir + "/" + _prefix + nodeName + "." + _ext; -} - -void PerformanceManager::logDir(std::string dir) { - _logDir = absPath(std::move(dir)); -} - -const std::string& PerformanceManager::logDir() const { - return _logDir; -} - -void PerformanceManager::prefix(std::string prefix) { - _prefix = std::move(prefix); -} - -const std::string& PerformanceManager::prefix() const { - return _prefix; -} - -void PerformanceManager::enableLogging() { - setLogging(true); -} - -void PerformanceManager::disableLogging() { - setLogging(false); -} - -void PerformanceManager::toggleLogging() { - setLogging(!_loggingEnabled); -} - -void PerformanceManager::setLogging(bool enabled) { - // Create the log directory if it doesn't exist. Do it here, so that it - // only tests once each time output is enabled - if (enabled) { - // If it can't create the directory, it's not logging so set false - enabled = createLogDir(); - } - - _loggingEnabled = enabled; -} - -bool PerformanceManager::createLogDir() { - // Done if it exists - ghoul::filesystem::Directory dir(_logDir); - if (FileSys.directoryExists(dir)) { - return true; - } - - // Error and set false if can't create - try { - FileSys.createDirectory(dir, ghoul::filesystem::FileSystem::Recursive::Yes); - } - catch (const ghoul::filesystem::FileSystem::FileSystemException& e) { - LERROR(fmt::format("Could not create log directory: {}", e.message)); - return false; - } - return true; -} - -bool PerformanceManager::loggingEnabled() const { - return _loggingEnabled; -} - -PerformanceLayout* PerformanceManager::performanceData() { - void* ptr = _performanceMemory->memory(); - return reinterpret_cast(ptr); -} - -void PerformanceManager::tick() { - _currentTick = (_currentTick + 1) % PerformanceLayout::NumberValues; -} - -void PerformanceManager::storeIndividualPerformanceMeasurement( - const std::string& identifier, - long long microseconds) -{ - if (!_performanceMemory) { - // If someone called the PerfMeasure macro without checking whether we are - // currently set-up for recording, we don't want to crash, so we just discard - return; - } - - PerformanceLayout* layout = performanceData(); - _performanceMemory->acquireLock(); - - auto it = individualPerformanceLocations.find(identifier); - PerformanceLayout::FunctionPerformanceLayout* p = nullptr; - if (it == individualPerformanceLocations.end()) { - p = &(layout->functionEntries[layout->nFunctionEntries]); - individualPerformanceLocations[identifier] = layout->nFunctionEntries; - ++(layout->nFunctionEntries); - } - else { - p = &(layout->functionEntries[it->second]); - } -#ifdef _MSC_VER - strcpy_s(p->name, identifier.length() + 1, identifier.c_str()); -#else - strcpy(p->name, identifier.c_str()); -#endif - - std::rotate( - std::begin(p->time), - std::next(std::begin(p->time)), - std::end(p->time) - ); - p->time[PerformanceLayout::NumberValues - 1] = static_cast(microseconds); - - _performanceMemory->releaseLock(); -} - -void PerformanceManager::storeScenePerformanceMeasurements( - const std::vector& sceneNodes) -{ - PerformanceLayout* layout = performanceData(); - _performanceMemory->acquireLock(); - - const int nNodes = static_cast(sceneNodes.size()); - layout->nScaleGraphEntries = static_cast(nNodes); - for (int i = 0; i < nNodes; ++i) { - const SceneGraphNode& node = *sceneNodes[i]; - - memset(layout->sceneGraphEntries[i].name, 0, PerformanceLayout::LengthName); -#ifdef _MSC_VER - strcpy_s( - layout->sceneGraphEntries[i].name, - node.identifier().length() + 1, - node.identifier().c_str() - ); -#else - strcpy(layout->sceneGraphEntries[i].name, node.identifier().c_str()); -#endif - - const SceneGraphNode::PerformanceRecord& r = node.performanceRecord(); - PerformanceLayout::SceneGraphPerformanceLayout& entry = - layout->sceneGraphEntries[i]; - - // Covert nano to microseconds - constexpr const float Micro = 1000.f; - - std::rotate( - std::begin(entry.renderTime), - std::next(std::begin(entry.renderTime)), - std::end(entry.renderTime) - ); - entry.renderTime[PerformanceLayout::NumberValues - 1] = r.renderTime / Micro; - - std::rotate( - std::begin(entry.updateTranslation), - std::next(std::begin(entry.updateTranslation)), - std::end(entry.updateTranslation) - ); - entry.updateTranslation[PerformanceLayout::NumberValues - 1] = - r.updateTimeTranslation / Micro; - - std::rotate( - std::begin(entry.updateRotation), - std::next(std::begin(entry.updateRotation)), - std::end(entry.updateRotation) - ); - entry.updateRotation[PerformanceLayout::NumberValues - 1] = - r.updateTimeRotation / Micro; - - std::rotate( - std::begin(entry.updateScaling), - std::next(std::begin(entry.updateScaling)), - std::end(entry.updateScaling) - ); - entry.updateScaling[PerformanceLayout::NumberValues - 1] = - r.updateTimeScaling / Micro; - - std::rotate( - std::begin(entry.updateRenderable), - std::next(std::begin(entry.updateRenderable)), - std::end(entry.updateRenderable) - ); - entry.updateRenderable[PerformanceLayout::NumberValues - 1] = - r.updateTimeRenderable / Micro; - } - _performanceMemory->releaseLock(); - - if (_loggingEnabled && _currentTick == PerformanceLayout::NumberValues - 1) { - outputLogs(); - } - - tick(); -} - -} // namespace openspace::performance diff --git a/src/performance/performancemeasurement.cpp b/src/performance/performancemeasurement.cpp deleted file mode 100644 index a529f70ea9..0000000000 --- a/src/performance/performancemeasurement.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2020 * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this * - * software and associated documentation files (the "Software"), to deal in the Software * - * without restriction, including without limitation the rights to use, copy, modify, * - * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * - * permit persons to whom the Software is furnished to do so, subject to the following * - * conditions: * - * * - * The above copyright notice and this permission notice shall be included in all copies * - * or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * - * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * - * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - ****************************************************************************************/ - -#include - -#include -#include -#include - -namespace openspace::performance { - -PerformanceMeasurement::PerformanceMeasurement(std::string identifier) - : _identifier(std::move(identifier)) -{ - glFinish(); - _startTime = std::chrono::high_resolution_clock::now(); -} - -PerformanceMeasurement::~PerformanceMeasurement() { - glFinish(); - auto endTime = std::chrono::high_resolution_clock::now(); - auto duration = std::chrono::duration_cast( - endTime - _startTime - ).count(); - - global::performanceManager.storeIndividualPerformanceMeasurement( - std::move(_identifier), - duration - ); -} - -} // namespace openspace::performance diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 2319b58ea5..ab9512c6c0 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include #include @@ -523,14 +521,6 @@ void FramebufferRenderer::deferredcastersChanged(Deferredcaster&, } void FramebufferRenderer::applyTMO(float blackoutFactor) { - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - std::unique_ptr perfInternal; - - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::TMO" - ); - } _hdrFilteringProgram->activate(); ghoul::opengl::TextureUnit hdrFeedingTextureUnit; @@ -563,15 +553,6 @@ void FramebufferRenderer::applyTMO(float blackoutFactor) { } void FramebufferRenderer::applyFXAA() { - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - std::unique_ptr perfInternal; - - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::FXAA" - ); - } - _fxaaProgram->activate(); ghoul::opengl::TextureUnit renderedTextureUnit; @@ -645,15 +626,6 @@ void FramebufferRenderer::updateDownscaleTextures() { } void FramebufferRenderer::writeDownscaledVolume() { - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - std::unique_ptr perfInternal; - - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::writeDownscaledVolume" - ); - } - // Saving current OpenGL state GLboolean blendEnabled = glIsEnabledi(GL_BLEND, 0); @@ -1177,16 +1149,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac } _pingPongIndex = 0; - // Measurements cache variable - const bool doPerformanceMeasurements = global::performanceManager.isEnabled(); - - std::unique_ptr perf; - if (doPerformanceMeasurements) { - perf = std::make_unique( - "FramebufferRenderer::render" - ); - } - if (!scene || !camera) { return; } @@ -1207,7 +1169,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac RenderData data = { *camera, std::move(time), - doPerformanceMeasurements, 0, {} }; @@ -1234,13 +1195,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac // Run Volume Tasks { GLDebugGroup group("Raycaster Tasks"); - - std::unique_ptr perfInternal; - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::raycasterTasks" - ); - } performRaycasterTasks(tasks.raycasterTasks); if (HasGLDebugInfo) { @@ -1257,12 +1211,6 @@ void FramebufferRenderer::render(Scene* scene, Camera* camera, float blackoutFac glBindFramebuffer(GL_FRAMEBUFFER, _pingPongBuffers.framebuffer); glDrawBuffers(1, &ColorAttachment01Array[_pingPongIndex]); - std::unique_ptr perfInternal; - if (doPerformanceMeasurements) { - perfInternal = std::make_unique( - "FramebufferRenderer::render::deferredTasks" - ); - } performDeferredTasks(tasks.deferredcasterTasks); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index d429cd8d46..7e052ac796 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -32,8 +32,6 @@ #include #include #include -#include -#include #include #include #include @@ -257,7 +255,6 @@ namespace openspace { RenderEngine::RenderEngine() : properties::PropertyOwner({ "RenderEngine" }) - , _doPerformanceMeasurements(PerformanceInfo) , _showOverlayOnSlaves(ShowOverlaySlavesInfo, false) , _showLog(ShowLogInfo, true) , _verticalLogOffset(VerticalLogOffsetInfo, 0.f, 0.f, 1.f) @@ -297,11 +294,6 @@ RenderEngine::RenderEngine() glm::vec3(glm::pi()) ) { - _doPerformanceMeasurements.onChange([this](){ - global::performanceManager.setEnabled(_doPerformanceMeasurements); - }); - addProperty(_doPerformanceMeasurements); - addProperty(_showOverlayOnSlaves); addProperty(_showLog); addProperty(_verticalLogOffset); @@ -528,8 +520,7 @@ void RenderEngine::updateScene() { _scene->update({ TransformData{ glm::dvec3(0.0), glm::dmat3(1.0), glm::dvec3(1.0) }, currentTime, - integrateFromTime, - _doPerformanceMeasurements + integrateFromTime }); LTRACE("RenderEngine::updateSceneGraph(end)"); @@ -852,13 +843,6 @@ void RenderEngine::renderShutdownInformation(float timer, float fullTime) { void RenderEngine::renderDashboard() { ZoneScoped - std::unique_ptr perf; - if (global::performanceManager.isEnabled()) { - perf = std::make_unique( - "Main Dashboard::render" - ); - } - glm::vec2 dashboardStart = global::dashboard.getStartPositionOffset(); glm::vec2 penPosition = glm::vec2( dashboardStart.x, @@ -888,12 +872,6 @@ void RenderEngine::postDraw() { ++_frameNumber; - if (global::performanceManager.isEnabled()) { - global::performanceManager.storeScenePerformanceMeasurements( - scene()->allSceneGraphNodes() - ); - } - #ifdef OPENSPACE_WITH_INSTRUMENTATION if (_saveFrameInformation) { _frameInfo.frames.push_back({ diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 14db241e45..e2975be134 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -432,51 +432,15 @@ void SceneGraphNode::update(const UpdateData& data) { } if (_transform.translation) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.translation->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeTranslation = (end - start).count(); - } - else { - _transform.translation->update(data); - } + _transform.translation->update(data); } if (_transform.rotation) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.rotation->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeRotation = (end - start).count(); - } - else { - _transform.rotation->update(data); - } + _transform.rotation->update(data); } if (_transform.scale) { - if (data.doPerformanceMeasurement) { - glFinish(); - const auto start = std::chrono::high_resolution_clock::now(); - - _transform.scale->update(data); - - glFinish(); - const auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeScaling = (end - start).count(); - } - else { - _transform.scale->update(data); - } + _transform.scale->update(data); } UpdateData newUpdateData = data; @@ -500,19 +464,7 @@ void SceneGraphNode::update(const UpdateData& data) { _inverseModelTransformCached = glm::inverse(_modelTransformCached); if (_renderable && _renderable->isReady()) { - if (data.doPerformanceMeasurement) { - glFinish(); - auto start = std::chrono::high_resolution_clock::now(); - - _renderable->update(newUpdateData); - - glFinish(); - auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.updateTimeRenderable = (end - start).count(); - } - else { - _renderable->update(newUpdateData); - } + _renderable->update(newUpdateData); } } @@ -527,7 +479,6 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { RenderData newData = { data.camera, data.time, - data.doPerformanceMeasurement, data.renderBinMask, { _worldPositionCached, _worldRotationCached, _worldScaleCached } }; @@ -546,20 +497,7 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) { return; } - if (data.doPerformanceMeasurement) { - glFinish(); - auto start = std::chrono::high_resolution_clock::now(); - - _renderable->render(newData, tasks); - if (_computeScreenSpaceValues) { - computeScreenSpaceData(newData); - } - - glFinish(); - auto end = std::chrono::high_resolution_clock::now(); - _performanceRecord.renderTime = (end - start).count(); - } - else { + { TracyGpuZone("Render") _renderable->render(newData, tasks); @@ -959,8 +897,4 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& id) { return nullptr; } -const SceneGraphNode::PerformanceRecord& SceneGraphNode::performanceRecord() const { - return _performanceRecord; -} - } // namespace openspace