mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-07 04:00:37 -06:00
Merge branch 'master' into feature/memory-allocations
# Conflicts: # include/openspace/scene/scenegraphnode.h # modules/imgui/include/gui.h
This commit is contained in:
@@ -30,7 +30,7 @@ local Deimos = {
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Radii = { 15, 12.2, 11 },
|
||||
Radii = { 15000, 12200, 11000 },
|
||||
SegmentsPerPatch = 90,
|
||||
Layers = {
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ local Phobos = {
|
||||
},
|
||||
Renderable = {
|
||||
Type = "RenderableGlobe",
|
||||
Radii = { 27, 22, 18 },
|
||||
Radii = { 27000, 22000, 18000 },
|
||||
SegmentsPerPatch = 90,
|
||||
Layers = {
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace interaction {
|
||||
class SessionRecording;
|
||||
class ShortcutManager;
|
||||
} // namespace interaction
|
||||
namespace performance { class PerformanceManager; }
|
||||
namespace properties { class PropertyOwner; }
|
||||
namespace scripting {
|
||||
class ScriptEngine;
|
||||
@@ -98,7 +97,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();
|
||||
@@ -137,8 +135,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();
|
||||
|
||||
@@ -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 <cstdint>
|
||||
|
||||
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__
|
||||
@@ -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 <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
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<SceneGraphNode*>& sceneNodes);
|
||||
|
||||
void outputLogs();
|
||||
|
||||
void writeData(std::ofstream& out, const std::vector<float>& 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<std::string, size_t> individualPerformanceLocations;
|
||||
|
||||
std::unique_ptr<ghoul::SharedMemory> _performanceMemory;
|
||||
|
||||
size_t _currentTick = 0;
|
||||
|
||||
void tick();
|
||||
bool createLogDir();
|
||||
};
|
||||
|
||||
} // namespace openspace::performance
|
||||
|
||||
#endif // __OPENSPACE_CORE___PERFORMANCEMANAGER___H__
|
||||
@@ -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 <chrono>
|
||||
#include <string>
|
||||
|
||||
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__
|
||||
@@ -179,8 +179,6 @@ private:
|
||||
Camera* _camera = nullptr;
|
||||
Scene* _scene = nullptr;
|
||||
|
||||
properties::BoolProperty _doPerformanceMeasurements;
|
||||
|
||||
std::unique_ptr<Renderer> _renderer;
|
||||
RendererImplementation _rendererImplementation = RendererImplementation::Invalid;
|
||||
ghoul::Dictionary _rendererData;
|
||||
|
||||
@@ -72,14 +72,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";
|
||||
@@ -139,8 +131,6 @@ public:
|
||||
|
||||
SceneGraphNode* childNode(const std::string& identifier);
|
||||
|
||||
const PerformanceRecord& performanceRecord() const;
|
||||
|
||||
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 };
|
||||
|
||||
ghoul::mm_unique_ptr<Renderable> _renderable;
|
||||
|
||||
properties::StringProperty _guiPath;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/documentation/verifier.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
|
||||
@@ -350,7 +350,6 @@ RenderData ShadowComponent::begin(const RenderData& data) {
|
||||
RenderData lightRenderData{
|
||||
*_lightCamera,
|
||||
data.time,
|
||||
data.doPerformanceMeasurement,
|
||||
data.renderBinMask,
|
||||
data.modelTransform
|
||||
};
|
||||
|
||||
@@ -36,7 +36,6 @@ set(HEADER_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guijoystickcomponent.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/guimemorycomponent.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
|
||||
@@ -57,7 +56,6 @@ set(SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guijoystickcomponent.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/guimemorycomponent.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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <modules/imgui/include/guimemorycomponent.h>
|
||||
#include <modules/imgui/include/guimissioncomponent.h>
|
||||
#include <modules/imgui/include/guiparallelcomponent.h>
|
||||
#include <modules/imgui/include/guiperformancecomponent.h>
|
||||
#include <modules/imgui/include/guipropertycomponent.h>
|
||||
#include <modules/imgui/include/guishortcutscomponent.h>
|
||||
#include <modules/imgui/include/guispacetimecomponent.h>
|
||||
@@ -64,7 +63,7 @@ namespace openspace::gui {
|
||||
|
||||
namespace detail {
|
||||
constexpr int nComponents() {
|
||||
const int nRegularComponents = 17;
|
||||
const int nRegularComponents = 16;
|
||||
int totalComponents = nRegularComponents;
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
@@ -107,7 +106,6 @@ public:
|
||||
GuiFilePathComponent _filePath;
|
||||
GuiAssetComponent _asset;
|
||||
GuiGlobeBrowsingComponent _globeBrowsing;
|
||||
GuiPerformanceComponent _performance;
|
||||
|
||||
GuiPropertyComponent _globalProperty;
|
||||
GuiPropertyComponent _sceneProperty;
|
||||
@@ -156,8 +154,6 @@ private:
|
||||
&_joystick,
|
||||
&_filePath,
|
||||
|
||||
&_performance,
|
||||
|
||||
&_help
|
||||
};
|
||||
|
||||
|
||||
@@ -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 <modules/imgui/include/guicomponent.h>
|
||||
|
||||
#include <openspace/properties/scalar/boolproperty.h>
|
||||
#include <openspace/properties/scalar/intproperty.h>
|
||||
#include <memory>
|
||||
|
||||
namespace ghoul { class SharedMemory; }
|
||||
|
||||
namespace openspace::gui {
|
||||
|
||||
class GuiPerformanceComponent : public GuiComponent {
|
||||
public:
|
||||
GuiPerformanceComponent();
|
||||
~GuiPerformanceComponent();
|
||||
|
||||
void render() override;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<ghoul::SharedMemory> _performanceMemory;
|
||||
|
||||
properties::IntProperty _sortingSelection;
|
||||
|
||||
properties::BoolProperty _sceneGraphIsEnabled;
|
||||
properties::BoolProperty _functionsIsEnabled;
|
||||
properties::BoolProperty _outputLogs;
|
||||
};
|
||||
|
||||
} // namespace openspace::gui
|
||||
|
||||
#endif // __OPENSPACE_MODULE_IMGUI___GUIPERFORMANCECOMPONENT___H__
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <ghoul/fmt.h>
|
||||
#include <ghoul/filesystem/cachemanager.h>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 <modules/imgui/include/guiperformancecomponent.h>
|
||||
|
||||
#include <modules/imgui/include/imgui_include.h>
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/performance/performancelayout.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <ghoul/misc/sharedmemory.h>
|
||||
#include <array>
|
||||
#include <numeric>
|
||||
|
||||
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<size_t> indices(layout->nScaleGraphEntries);
|
||||
std::iota(indices.begin(), indices.end(), 0);
|
||||
|
||||
// Ordering:
|
||||
// updateTranslation
|
||||
// updateRotation
|
||||
// updateScaling
|
||||
// UpdateRender
|
||||
// RenderTime
|
||||
std::vector<std::array<float, 5>> averages(
|
||||
layout->nScaleGraphEntries,
|
||||
{ 0.f, 0.f, 0.f, 0.f, 0.f }
|
||||
);
|
||||
|
||||
std::vector<std::array<std::pair<float, float>, 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<float>(nValues[0]);
|
||||
}
|
||||
if (nValues[1] != 0) {
|
||||
averages[i][1] /= static_cast<float>(nValues[1]);
|
||||
}
|
||||
if (nValues[2] != 0) {
|
||||
averages[i][2] /= static_cast<float>(nValues[2]);
|
||||
}
|
||||
if (nValues[3] != 0) {
|
||||
averages[i][3] /= static_cast<float>(nValues[3]);
|
||||
}
|
||||
if (nValues[4] != 0) {
|
||||
averages[i][4] /= static_cast<float>(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<bool(size_t, size_t)> 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
|
||||
@@ -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<float>(position.x);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include <openspace/interaction/shortcutmanager.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/dashboard.h>
|
||||
#include <openspace/rendering/deferredcastermanager.h>
|
||||
@@ -194,11 +193,6 @@ interaction::ShortcutManager& gShortcutManager() {
|
||||
return g;
|
||||
}
|
||||
|
||||
performance::PerformanceManager& gPerformanceManager() {
|
||||
static performance::PerformanceManager g;
|
||||
return g;
|
||||
}
|
||||
|
||||
properties::PropertyOwner& gRootPropertyOwner() {
|
||||
static properties::PropertyOwner g({ "" });
|
||||
return g;
|
||||
|
||||
@@ -41,8 +41,6 @@
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/network/parallelpeer.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/rendering/dashboard.h>
|
||||
#include <openspace/rendering/dashboarditem.h>
|
||||
#include <openspace/rendering/helper.h>
|
||||
@@ -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<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"OpenSpaceEngine::preSynchronization"
|
||||
);
|
||||
}
|
||||
|
||||
FileSys.triggerFilesystemEvents();
|
||||
|
||||
if (_hasScheduledAssetLoading) {
|
||||
@@ -1132,16 +1120,8 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
ZoneScoped
|
||||
|
||||
LTRACE("OpenSpaceEngine::postSynchronizationPreDraw(begin)");
|
||||
|
||||
std::unique_ptr<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<void()>& func : global::callback::draw2D) {
|
||||
@@ -1274,16 +1237,8 @@ void OpenSpaceEngine::drawOverlays() {
|
||||
|
||||
void OpenSpaceEngine::postDraw() {
|
||||
ZoneScoped
|
||||
|
||||
LTRACE("OpenSpaceEngine::postDraw(begin)");
|
||||
|
||||
std::unique_ptr<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"OpenSpaceEngine::postDraw"
|
||||
);
|
||||
}
|
||||
|
||||
global::renderEngine.postDraw();
|
||||
|
||||
for (const std::function<void()>& func : global::callback::postDraw) {
|
||||
|
||||
@@ -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 <openspace/performance/performancelayout.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace openspace::performance {
|
||||
|
||||
PerformanceLayout::PerformanceLayout() {
|
||||
std::memset(
|
||||
sceneGraphEntries,
|
||||
0,
|
||||
MaxValues * sizeof(SceneGraphPerformanceLayout)
|
||||
);
|
||||
|
||||
std::memset(
|
||||
functionEntries,
|
||||
0,
|
||||
MaxValues * sizeof(FunctionPerformanceLayout)
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace openspace::performance
|
||||
@@ -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 <openspace/performance/performancemanager.h>
|
||||
|
||||
#include <openspace/performance/performancelayout.h>
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <ghoul/fmt.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/defer.h>
|
||||
#include <ghoul/misc/sharedmemory.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
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<uint8_t, 2> 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<GlobalMemory*>(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<GlobalMemory*>(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<GlobalMemory*>(sharedMemory.memory());
|
||||
--(m->referenceCount);
|
||||
LINFO(fmt::format(
|
||||
"Global shared performance memory reference count: {}",
|
||||
static_cast<int>(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<uint8_t>::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<GlobalMemory*>(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<ghoul::SharedMemory>(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<GlobalMemory*>(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<float>& 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<float> 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<float>& 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<PerformanceLayout*>(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<float>(microseconds);
|
||||
|
||||
_performanceMemory->releaseLock();
|
||||
}
|
||||
|
||||
void PerformanceManager::storeScenePerformanceMeasurements(
|
||||
const std::vector<SceneGraphNode*>& sceneNodes)
|
||||
{
|
||||
PerformanceLayout* layout = performanceData();
|
||||
_performanceMemory->acquireLock();
|
||||
|
||||
const int nNodes = static_cast<int>(sceneNodes.size());
|
||||
layout->nScaleGraphEntries = static_cast<int16_t>(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
|
||||
@@ -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 <openspace/performance/performancemeasurement.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
|
||||
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<std::chrono::microseconds>(
|
||||
endTime - _startTime
|
||||
).count();
|
||||
|
||||
global::performanceManager.storeIndividualPerformanceMeasurement(
|
||||
std::move(_identifier),
|
||||
duration
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace openspace::performance
|
||||
@@ -26,8 +26,6 @@
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
#include <openspace/rendering/deferredcaster.h>
|
||||
#include <openspace/rendering/deferredcastermanager.h>
|
||||
#include <openspace/rendering/raycastermanager.h>
|
||||
@@ -523,14 +521,6 @@ void FramebufferRenderer::deferredcastersChanged(Deferredcaster&,
|
||||
}
|
||||
|
||||
void FramebufferRenderer::applyTMO(float blackoutFactor) {
|
||||
const bool doPerformanceMeasurements = global::performanceManager.isEnabled();
|
||||
std::unique_ptr<performance::PerformanceMeasurement> perfInternal;
|
||||
|
||||
if (doPerformanceMeasurements) {
|
||||
perfInternal = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perfInternal;
|
||||
|
||||
if (doPerformanceMeasurements) {
|
||||
perfInternal = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perfInternal;
|
||||
|
||||
if (doPerformanceMeasurements) {
|
||||
perfInternal = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perf;
|
||||
if (doPerformanceMeasurements) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perfInternal;
|
||||
if (doPerformanceMeasurements) {
|
||||
perfInternal = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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<performance::PerformanceMeasurement> perfInternal;
|
||||
if (doPerformanceMeasurements) {
|
||||
perfInternal = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"FramebufferRenderer::render::deferredTasks"
|
||||
);
|
||||
}
|
||||
performDeferredTasks(tasks.deferredcasterTasks);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
#include <openspace/mission/missionmanager.h>
|
||||
#include <openspace/performance/performancemanager.h>
|
||||
#include <openspace/performance/performancemeasurement.h>
|
||||
#include <openspace/rendering/abufferrenderer.h>
|
||||
#include <openspace/rendering/dashboard.h>
|
||||
#include <openspace/rendering/deferredcastermanager.h>
|
||||
@@ -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<float>())
|
||||
)
|
||||
{
|
||||
_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<performance::PerformanceMeasurement> perf;
|
||||
if (global::performanceManager.isEnabled()) {
|
||||
perf = std::make_unique<performance::PerformanceMeasurement>(
|
||||
"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({
|
||||
|
||||
@@ -441,51 +441,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;
|
||||
|
||||
@@ -509,19 +473,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,7 +488,6 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
|
||||
RenderData newData = {
|
||||
data.camera,
|
||||
data.time,
|
||||
data.doPerformanceMeasurement,
|
||||
data.renderBinMask,
|
||||
{ _worldPositionCached, _worldRotationCached, _worldScaleCached }
|
||||
};
|
||||
@@ -553,20 +504,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);
|
||||
@@ -961,8 +899,4 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& id) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const SceneGraphNode::PerformanceRecord& SceneGraphNode::performanceRecord() const {
|
||||
return _performanceRecord;
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user