diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 79db055207..7a49f76a7e 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -315,7 +315,7 @@ void RenderablePlanetProjection::render(const RenderData& data) { _programObject->setUniform("_heightExaggeration", _heightExaggeration); _programObject->setUniform("_projectionFading", _projectionFading); - _programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value())); + //_programObject->setUniform("debug_projectionTextureRotation", glm::radians(_debugProjectionTextureRotation.value())); setPscUniforms(*_programObject.get(), data.camera, data.position); diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.cpp b/modules/newhorizons/rendering/renderableshadowcylinder.cpp index 21c85c2523..79ed65e57d 100644 --- a/modules/newhorizons/rendering/renderableshadowcylinder.cpp +++ b/modules/newhorizons/rendering/renderableshadowcylinder.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2016 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 @@ -80,8 +80,7 @@ namespace openspace { ghoul_assert(success, ""); } -RenderableShadowCylinder::~RenderableShadowCylinder() { -} +RenderableShadowCylinder::~RenderableShadowCylinder() {} bool RenderableShadowCylinder::isReady() const { bool ready = true; @@ -103,6 +102,8 @@ bool RenderableShadowCylinder::initialize() { if (!_shader) return false; + + return completeSuccess; } diff --git a/modules/onscreengui/include/guiperformancecomponent.h b/modules/onscreengui/include/guiperformancecomponent.h index e2f31f9f45..f7fde598ac 100644 --- a/modules/onscreengui/include/guiperformancecomponent.h +++ b/modules/onscreengui/include/guiperformancecomponent.h @@ -44,6 +44,7 @@ public: protected: ghoul::SharedMemory* _performanceMemory = nullptr; float _minMaxValues[2]; + int _sortingSelection; }; } // namespace gui diff --git a/modules/onscreengui/src/guiperformancecomponent.cpp b/modules/onscreengui/src/guiperformancecomponent.cpp index e12c639288..8ad8df84fc 100644 --- a/modules/onscreengui/src/guiperformancecomponent.cpp +++ b/modules/onscreengui/src/guiperformancecomponent.cpp @@ -27,8 +27,12 @@ #include #include #include + #include +#include + #include +#include namespace { const std::string _loggerCat = "GuiPerformanceComponent"; @@ -40,6 +44,7 @@ namespace gui { void GuiPerformanceComponent::initialize() { _minMaxValues[0] = 100.f; _minMaxValues[1] = 250.f; + _sortingSelection = -1; } void GuiPerformanceComponent::deinitialize() { @@ -82,26 +87,108 @@ void GuiPerformanceComponent::render() { ImGui::SliderFloat2("Min values, max Value", _minMaxValues, 0.f, 10000.f); _minMaxValues[1] = fmaxf(_minMaxValues[0], _minMaxValues[1]); + // The indices correspond to the index into the average array further below + ImGui::Text("Sorting"); + ImGui::RadioButton("No Sorting", &_sortingSelection, -1); + ImGui::RadioButton("UpdateEphemeris", &_sortingSelection, 0); + ImGui::RadioButton("UpdateRender", &_sortingSelection, 1); + ImGui::RadioButton("RenderTime", &_sortingSelection, 2); if (!_performanceMemory) _performanceMemory = new ghoul::SharedMemory(RenderEngine::PerformanceMeasurementSharedData); void* ptr = _performanceMemory->memory(); - PerformanceLayout* layout = reinterpret_cast(ptr); - for (int i = 0; i < layout->nEntries; ++i) { - const PerformanceLayout::PerformanceLayoutEntry& entry = layout->entries[i]; + PerformanceLayout layout = *reinterpret_cast(ptr); + + std::vector indices(layout.nEntries); + std::iota(indices.begin(), indices.end(), 0); + + // Ordering: + // updateEphemeris + // UpdateRender + // RenderTime + std::vector> averages(layout.nEntries, { 0.f, 0.f, 0.f }); + + for (int i = 0; i < layout.nEntries; ++i) { + const PerformanceLayout::PerformanceLayoutEntry& entry = layout.entries[i]; + + int v[3] = { 0, 0, 0 }; + + for (int j = 0; j < nValues; ++j) { + averages[i][0] += entry.updateEphemeris[j]; + if (entry.updateEphemeris[j] != 0.f) + ++v[0]; + averages[i][1] += entry.updateRenderable[j]; + if (entry.updateRenderable[j] != 0.f) + ++v[1]; + averages[i][2] += entry.renderTime[j]; + if (entry.renderTime[j] != 0.f) + ++v[2]; + } + + if (v[0] != 0) + averages[i][0] /= static_cast(v[0]); + if (v[1] != 0) + averages[i][1] /= static_cast(v[1]); + if (v[2] != 0) + averages[i][2] /= static_cast(v[2]); + } + + if (_sortingSelection != -1) { + int sortIndex = _sortingSelection; + + std::sort( + indices.begin(), + indices.end(), + [sortIndex, &averages](int a, int b) { + return averages[a][sortIndex] > averages[b][sortIndex]; + } + ); + + } + + for (int i = 0; i < layout.nEntries; ++i) { + const PerformanceLayout::PerformanceLayoutEntry& entry = layout.entries[indices[i]]; if (ImGui::CollapsingHeader(entry.name)) { std::string updateEphemerisTime = std::to_string(entry.updateEphemeris[entry.currentUpdateEphemeris - 1]) + "us"; - ImGui::PlotLines("UpdateEphemeris", &entry.updateEphemeris[0], layout->nValuesPerEntry, 0, updateEphemerisTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40)); + ; + ImGui::PlotLines( + fmt::format("UpdateEphemeris\nAverage: {}us", averages[i][0]).c_str(), + &entry.updateEphemeris[0], + layout.nValuesPerEntry, + 0, + updateEphemerisTime.c_str(), + _minMaxValues[0], + _minMaxValues[1], + ImVec2(0, 40) + ); std::string updateRenderableTime = std::to_string(entry.updateRenderable[entry.currentUpdateRenderable - 1]) + "us"; - ImGui::PlotLines("UpdateRender", &entry.updateRenderable[0], layout->nValuesPerEntry, 0, updateRenderableTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40)); + ImGui::PlotLines( + fmt::format("UpdateRender\nAverage: {}us", averages[i][1]).c_str(), + &entry.updateRenderable[0], + layout.nValuesPerEntry, + 0, + updateRenderableTime.c_str(), + _minMaxValues[0], + _minMaxValues[1], + ImVec2(0, 40) + ); std::string renderTime = std::to_string(entry.renderTime[entry.currentRenderTime - 1]) + "us"; - ImGui::PlotLines("RenderTime", &entry.renderTime[0], layout->nValuesPerEntry, 0, renderTime.c_str(), _minMaxValues[0], _minMaxValues[1], ImVec2(0, 40)); + ImGui::PlotLines( + fmt::format("RenderTime\nAverage: {}us", averages[i][2]).c_str(), + &entry.renderTime[0], + layout.nValuesPerEntry, + 0, + renderTime.c_str(), + _minMaxValues[0], + _minMaxValues[1], + ImVec2(0, 40) + ); } } }