diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 152f494e0c..233a166689 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -242,6 +242,8 @@ private: glm::ivec4 zoom = glm::ivec4(0); glm::ivec4 roll = glm::ivec4(0); } _cameraButtonLocations; + + std::string _versionString; }; } // namespace openspace diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 12a0003a69..991afa4520 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -37,6 +37,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -352,6 +353,7 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary) addProperty(_destination.nodeName); _font = global::fontManager.font(_fontName, _fontSize); + _buffer.resize(128); } std::pair DashboardItemAngle::positionAndLabel( @@ -391,6 +393,8 @@ std::pair DashboardItemAngle::positionAndLabel( } void DashboardItemAngle::render(glm::vec2& penPosition) { + ZoneScoped + std::pair sourceInfo = positionAndLabel(_source); std::pair referenceInfo = positionAndLabel(_reference); std::pair destinationInfo = positionAndLabel(_destination); @@ -398,16 +402,16 @@ void DashboardItemAngle::render(glm::vec2& penPosition) { const glm::dvec3 a = referenceInfo.first - sourceInfo.first; const glm::dvec3 b = destinationInfo.first - sourceInfo.first; + std::fill(_buffer.begin(), _buffer.end(), 0); if (glm::length(a) == 0.0 || glm::length(b) == 0) { penPosition.y -= _font->height(); - RenderFont( - *_font, - penPosition, - fmt::format( - "Could not compute angle at {} between {} and {}", - sourceInfo.second, destinationInfo.second, referenceInfo.second - ) + char* end = fmt::format_to( + _buffer.data(), + "Could not compute angle at {} between {} and {}", + sourceInfo.second, destinationInfo.second, referenceInfo.second ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } else { const double angle = glm::degrees( @@ -415,18 +419,19 @@ void DashboardItemAngle::render(glm::vec2& penPosition) { ); penPosition.y -= _font->height(); - RenderFont( - *_font, - penPosition, - fmt::format( - "Angle at {} between {} and {}: {} degrees", - sourceInfo.second, destinationInfo.second, referenceInfo.second, angle - ) + char* end = fmt::format_to( + _buffer.data(), + "Angle at {} between {} and {}: {} degrees", + sourceInfo.second, destinationInfo.second, referenceInfo.second, angle ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } } glm::vec2 DashboardItemAngle::size() const { + ZoneScoped + constexpr const double Angle = 120; return _font->boundingBox("Angle: " + std::to_string(Angle)); diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h index 21791cc63b..111f1a8a79 100644 --- a/modules/base/dashboard/dashboarditemangle.h +++ b/modules/base/dashboard/dashboarditemangle.h @@ -73,6 +73,7 @@ private: properties::StringProperty _fontName; properties::FloatProperty _fontSize; + std::vector _buffer; std::shared_ptr _font; }; diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index 4accac477f..b003e06882 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -110,6 +111,8 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary) } void DashboardItemDate::render(glm::vec2& penPosition) { + ZoneScoped + penPosition.y -= _font->height(); RenderFont( *_font, @@ -119,6 +122,8 @@ void DashboardItemDate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemDate::size() const { + ZoneScoped + return _font->boundingBox( fmt::format("Date: {} UTC", global::timeManager.time().UTC()) ); diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index 92e1b74365..655e7881a8 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -358,6 +359,8 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary addProperty(_requestedUnit); _font = global::fontManager.font(_fontName, _fontSize); + + _buffer.resize(256); } std::pair DashboardItemDistance::positionAndLabel( @@ -419,6 +422,8 @@ std::pair DashboardItemDistance::positionAndLabel( } void DashboardItemDistance::render(glm::vec2& penPosition) { + ZoneScoped + std::pair sourceInfo = positionAndLabel( _source, _destination @@ -440,18 +445,20 @@ void DashboardItemDistance::render(glm::vec2& penPosition) { } penPosition.y -= _font->height(); - - RenderFont( - *_font, - penPosition, - fmt::format( - "Distance from {} to {}: {:f} {}", - sourceInfo.second, destinationInfo.second, dist.first, dist.second - ) + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = fmt::format_to( + _buffer.data(), + "Distance from {} to {}: {:f} {}\0", + sourceInfo.second, destinationInfo.second, dist.first, dist.second ); + + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + RenderFont(*_font, penPosition, text); } glm::vec2 DashboardItemDistance::size() const { + ZoneScoped + const double d = glm::length(1e20); std::pair dist; if (_doSimplification) { diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h index aab5098bfb..f66cd745c4 100644 --- a/modules/base/dashboard/dashboarditemdistance.h +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -79,6 +79,8 @@ private: Component _source; Component _destination; + std::vector _buffer; + std::shared_ptr _font; }; diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 7588c7a215..b72a4441b8 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -70,17 +71,22 @@ namespace { constexpr const char* ValueFpsAvg = "Average frames per second"; constexpr const char* ValueNone = "None"; - std::string formatDt() { - return fmt::format( - "Avg. Frametime: {:.2f} ms", + [[ nodiscard ]] char* formatDt(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Avg. Frametime: {:.2f} ms\0", openspace::global::windowDelegate.averageDeltaTime() * 1000.0 ); } - std::string formatDtExtremes(double minFrametimeCache, double maxFrametimeCache) { - return fmt::format( + [[ nodiscard ]] char* formatDtExtremes(std::vector& buffer, + double minFrametimeCache, + double maxFrametimeCache) + { + return fmt::format_to( + buffer.data(), "Last frametimes between: {:.2f} and {:.2f} ms\n" - "Overall between: {:.2f} and {:.2f} ms", + "Overall between: {:.2f} and {:.2f} ms\0", openspace::global::windowDelegate.minDeltaTime() * 1000.0, openspace::global::windowDelegate.maxDeltaTime() * 1000.0, minFrametimeCache, @@ -88,54 +94,59 @@ namespace { ); } - std::string formatDtStandardDeviation() { - return fmt::format( - "Frametime standard deviation : {:.2f} ms", + [[ nodiscard ]] char* formatDtStandardDeviation(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Frametime standard deviation : {:.2f} ms\0", openspace::global::windowDelegate.deltaTimeStandardDeviation() * 1000.0 ); } - std::string formatDtCoefficientOfVariation() { - return fmt::format( - "Frametime coefficient of variation : {:.2f} %", + [[ nodiscard ]] char* formatDtCoefficientOfVariation(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Frametime coefficient of variation : {:.2f} %\0", openspace::global::windowDelegate.deltaTimeStandardDeviation() / openspace::global::windowDelegate.averageDeltaTime() * 100.0 ); } - std::string formatFps() { - return fmt::format( - "FPS: {:3.2f}", + [[ nodiscard ]] char* formatFps(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "FPS: {:3.2f}\0", 1.0 / openspace::global::windowDelegate.deltaTime() ); } - std::string formatAverageFps() { - return fmt::format( - "Avg. FPS: {:3.2f}", + [[ nodiscard ]] char* formatAverageFps(std::vector& buffer) { + return fmt::format_to( + buffer.data(), + "Avg. FPS: {:3.2f}\0", 1.0 / openspace::global::windowDelegate.averageDeltaTime() ); } - std::string format(openspace::DashboardItemFramerate::FrametimeType frametimeType, - double minFrametimeCache, double maxFrametimeCache) + [[ nodiscard ]] char* format(std::vector& buffer, + openspace::DashboardItemFramerate::FrametimeType frametimeType, + double minFrametimeCache, double maxFrametimeCache) { using namespace openspace; switch (frametimeType) { case DashboardItemFramerate::FrametimeType::DtTimeAvg: - return formatDt(); + return formatDt(buffer); case DashboardItemFramerate::FrametimeType::DtTimeExtremes: - return formatDtExtremes(minFrametimeCache, maxFrametimeCache); + return formatDtExtremes(buffer, minFrametimeCache, maxFrametimeCache); case DashboardItemFramerate::FrametimeType::DtStandardDeviation: - return formatDtStandardDeviation(); + return formatDtStandardDeviation(buffer); case DashboardItemFramerate::FrametimeType::DtCoefficientOfVariation: - return formatDtCoefficientOfVariation(); + return formatDtCoefficientOfVariation(buffer); case DashboardItemFramerate::FrametimeType::FPS: - return formatFps(); + return formatFps(buffer); case DashboardItemFramerate::FrametimeType::FPSAvg: - return formatAverageFps(); + return formatAverageFps(buffer); default: - return ""; + throw ghoul::MissingCaseException(); } } } // namespace @@ -262,9 +273,13 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona addProperty(_clearCache); _font = global::fontManager.font(_fontName, _fontSize); + + _buffer.resize(128); } void DashboardItemFramerate::render(glm::vec2& penPosition) { + ZoneScoped + if (_shouldClearCache) { _minDeltaTimeCache = 1.0; _maxDeltaTimeCache = -1.0; @@ -282,11 +297,14 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { FrametimeType frametimeType = FrametimeType(_frametimeType.value()); - const std::string output = format( + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = format( + _buffer, frametimeType, _minDeltaTimeCache, _maxDeltaTimeCache ); + std::string_view output = std::string_view(_buffer.data(), end - _buffer.data()); int nLines = output.empty() ? 0 : static_cast((std::count(output.begin(), output.end(), '\n') + 1)); @@ -301,8 +319,11 @@ void DashboardItemFramerate::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemFramerate::size() const { + ZoneScoped + const FrametimeType t = FrametimeType(_frametimeType.value()); - const std::string output = format(t, _minDeltaTimeCache, _maxDeltaTimeCache); + format(_buffer, t, _minDeltaTimeCache, _maxDeltaTimeCache); + std::string_view output = _buffer.data(); if (output.empty()) { return { 0.f, 0.f }; diff --git a/modules/base/dashboard/dashboarditemframerate.h b/modules/base/dashboard/dashboarditemframerate.h index 2b1b8c2de9..8fc952f537 100644 --- a/modules/base/dashboard/dashboarditemframerate.h +++ b/modules/base/dashboard/dashboarditemframerate.h @@ -68,6 +68,7 @@ private: double _minDeltaTimeCache = 1.0; double _maxDeltaTimeCache = -1.0; bool _shouldClearCache = true; + mutable std::vector _buffer; }; } // openspace diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp index 8fc99bb908..eb65bc8651 100644 --- a/modules/base/dashboard/dashboarditemmission.cpp +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include namespace { @@ -129,6 +130,8 @@ DashboardItemMission::DashboardItemMission(const ghoul::Dictionary& dictionary) } void DashboardItemMission::render(glm::vec2& penPosition) { + ZoneScoped + if (!global::missionManager.hasCurrentMission()) { return; } @@ -245,6 +248,8 @@ void DashboardItemMission::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemMission::size() const { + ZoneScoped + // @TODO fix this up ---abock return { 0.f, 0.f }; } diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index 30911be306..54a2642387 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -34,6 +34,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -114,6 +115,8 @@ DashboardItemParallelConnection::DashboardItemParallelConnection( } void DashboardItemParallelConnection::render(glm::vec2& penPosition) { + ZoneScoped + const ParallelConnection::Status status = global::parallelPeer.status(); const size_t nConnections = global::parallelPeer.nConnections(); const std::string& hostName = global::parallelPeer.hostName(); @@ -164,6 +167,8 @@ void DashboardItemParallelConnection::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemParallelConnection::size() const { + ZoneScoped + ParallelConnection::Status status = global::parallelPeer.status(); size_t nConnections = global::parallelPeer.nConnections(); const std::string& hostName = global::parallelPeer.hostName(); diff --git a/modules/base/dashboard/dashboarditempropertyvalue.cpp b/modules/base/dashboard/dashboarditempropertyvalue.cpp index c884458d7d..d388e379fb 100644 --- a/modules/base/dashboard/dashboarditempropertyvalue.cpp +++ b/modules/base/dashboard/dashboarditempropertyvalue.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -151,6 +152,8 @@ DashboardItemPropertyValue::DashboardItemPropertyValue( } void DashboardItemPropertyValue::render(glm::vec2& penPosition) { + ZoneScoped + if (_propertyIsDirty) { _property = openspace::property(_propertyUri); _propertyIsDirty = false; @@ -166,6 +169,8 @@ void DashboardItemPropertyValue::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemPropertyValue::size() const { + ZoneScoped + return _font->boundingBox(_displayString.value()); } diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 11c310943c..def2b6f9e1 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -176,6 +177,8 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( } void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { + ZoneScoped + const double targetDt = global::timeManager.targetDeltaTime(); const double currentDt = global::timeManager.deltaTime(); std::pair targetDeltaTime; @@ -227,6 +230,8 @@ void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemSimulationIncrement::size() const { + ZoneScoped + double t = global::timeManager.targetDeltaTime(); std::pair deltaTime; if (_doSimplification) { diff --git a/modules/base/dashboard/dashboarditemvelocity.cpp b/modules/base/dashboard/dashboarditemvelocity.cpp index 12952fb0bb..e89fedb6be 100644 --- a/modules/base/dashboard/dashboarditemvelocity.cpp +++ b/modules/base/dashboard/dashboarditemvelocity.cpp @@ -38,6 +38,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -187,6 +188,8 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary } void DashboardItemVelocity::render(glm::vec2& penPosition) { + ZoneScoped + const glm::dvec3 currentPos = global::renderEngine.scene()->camera()->positionVec3(); const glm::dvec3 dt = currentPos - _prevPosition; const double speedPerFrame = glm::length(dt); @@ -218,6 +221,8 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) { } glm::vec2 DashboardItemVelocity::size() const { + ZoneScoped + const double d = glm::length(1e20); std::pair dist; if (_doSimplification) { diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.cpp b/modules/globebrowsing/src/dashboarditemglobelocation.cpp index 4bac59a59f..d23f1cf868 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.cpp +++ b/modules/globebrowsing/src/dashboarditemglobelocation.cpp @@ -37,6 +37,7 @@ #include #include #include +#include namespace { constexpr const char* KeyFontMono = "Mono"; @@ -135,12 +136,25 @@ DashboardItemGlobeLocation::DashboardItemGlobeLocation( }); addProperty(_fontSize); + auto updateFormatString = [this]() { + using namespace fmt::literals; + + _formatString = + "Position: {{:03.{0}f}}{{}}, {{:03.{0}f}}{{}} Altitude: {{}} {{}}"_format( + _significantDigits.value() + ); + }; + _significantDigits.onChange(updateFormatString); addProperty(_significantDigits); + updateFormatString(); _font = global::fontManager.font(_fontName, _fontSize); + _buffer.resize(128); } void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { + ZoneScoped + using namespace globebrowsing; const SceneGraphNode* n = global::navigationHandler.orbitalNavigator().anchorNode(); @@ -186,19 +200,22 @@ void DashboardItemGlobeLocation::render(glm::vec2& penPosition) { std::pair dist = simplifyDistance(altitude); penPosition.y -= _font->height(); - std::string d = std::to_string(_significantDigits); - std::string f = "Position: {:03." + d + "f}{}, {:03." + d + "f}{} Altitude: {} {}"; - RenderFont( - *_font, - penPosition, - fmt::format(f, - lat, isNorth ? "N" : "S", - lon, isEast ? "E" : "W", - dist.first, dist.second - ) + + std::fill(_buffer.begin(), _buffer.end(), 0); + char* end = fmt::format_to( + _buffer.data(), + _formatString.c_str(), + lat, isNorth ? "N" : "S", + lon, isEast ? "E" : "W", + dist.first, dist.second ); + std::string_view text = std::string_view(_buffer.data(), end - _buffer.data()); + + RenderFont(*_font, penPosition, text); } glm::vec2 DashboardItemGlobeLocation::size() const { + ZoneScoped + return _font->boundingBox( fmt::format("Position: {}, {} Altitude: {}", 1.f, 1.f, 1.f) ); diff --git a/modules/globebrowsing/src/dashboarditemglobelocation.h b/modules/globebrowsing/src/dashboarditemglobelocation.h index 12c6f6fc84..47f8cafce3 100644 --- a/modules/globebrowsing/src/dashboarditemglobelocation.h +++ b/modules/globebrowsing/src/dashboarditemglobelocation.h @@ -55,6 +55,8 @@ private: properties::IntProperty _significantDigits; std::shared_ptr _font; + std::string _formatString; + std::vector _buffer; }; } // namespace openspace diff --git a/modules/globebrowsing/src/lrucache.inl b/modules/globebrowsing/src/lrucache.inl index 1ee02b4e1a..5144250b6d 100644 --- a/modules/globebrowsing/src/lrucache.inl +++ b/modules/globebrowsing/src/lrucache.inl @@ -59,8 +59,16 @@ bool LRUCache::exist(const KeyType& key) const { template bool LRUCache::touch(const KeyType& key) { + ZoneScoped + const auto it = _itemMap.find(key); - if (it != _itemMap.end()) { // Found in cache + if (it != _itemMap.end()) { + // @TODO (abock, 2020-08-14) Instead of removing the iterator from the previous + // position and then readding it at the front, it might make more sense to move + // them around? That would prevent the dynamic memoray allocation that is + // happening here + + // Found in cache ValueType value = it->second->second; // Remove from current position _itemList.erase(it->second); diff --git a/modules/globebrowsing/src/memoryawaretilecache.cpp b/modules/globebrowsing/src/memoryawaretilecache.cpp index b2d34f1ce4..c6106137b1 100644 --- a/modules/globebrowsing/src/memoryawaretilecache.cpp +++ b/modules/globebrowsing/src/memoryawaretilecache.cpp @@ -395,8 +395,7 @@ Tile MemoryAwareTileCache::get(const ProviderTileKey& key) { } } -ghoul::opengl::Texture* MemoryAwareTileCache::texture( - const TileTextureInitData& initData) +ghoul::opengl::Texture* MemoryAwareTileCache::texture(const TileTextureInitData& initData) { // if this texture type does not exist among the texture containers // it needs to be created diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index 8a9a74298f..4cf67df702 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -615,9 +615,9 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) addPropertySubOwner(_debugPropertyOwner); addPropertySubOwner(_layerManager); - _globalChunkBuffer.reserve(2048); - _localChunkBuffer.reserve(2048); - _traversalMemory.reserve(512); + _globalChunkBuffer.resize(2048); + _localChunkBuffer.resize(2048); + _traversalMemory.resize(512); //================================================================ //======== Reads Shadow (Eclipses) Entries in mod file =========== @@ -1214,8 +1214,24 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&, } }; - traversal(_leftRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); - traversal(_rightRoot, _globalChunkBuffer, globalCount, _localChunkBuffer, localCount, _debugProperties.modelSpaceRenderingCutoffLevel, _traversalMemory); + traversal( + _leftRoot, + _globalChunkBuffer, + globalCount, + _localChunkBuffer, + localCount, + _debugProperties.modelSpaceRenderingCutoffLevel, + _traversalMemory + ); + traversal( + _rightRoot, + _globalChunkBuffer, + globalCount, + _localChunkBuffer, + localCount, + _debugProperties.modelSpaceRenderingCutoffLevel, + _traversalMemory + ); // Render all chunks that want to be rendered globally _globalRenderer.program->activate(); diff --git a/modules/globebrowsing/src/tileprovider.cpp b/modules/globebrowsing/src/tileprovider.cpp index eaed99936f..1b7686a322 100644 --- a/modules/globebrowsing/src/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider.cpp @@ -924,7 +924,6 @@ Tile tile(TileProvider& tp, const TileIndex& tileIndex) { } const cache::ProviderTileKey key = { tileIndex, t.uniqueIdentifier }; Tile tile = t.tileCache->get(key); - if (!tile.texture) { //TracyMessage("Enqueuing tile", 32); t.asyncTextureDataProvider->enqueueTileIO(tileIndex); diff --git a/modules/globebrowsing/src/timequantizer.cpp b/modules/globebrowsing/src/timequantizer.cpp index 080af9b3b9..707c7f850e 100644 --- a/modules/globebrowsing/src/timequantizer.cpp +++ b/modules/globebrowsing/src/timequantizer.cpp @@ -158,12 +158,12 @@ void DateTime::setTime(std::string_view input) { constexpr const size_t IndexMinute = 14; constexpr const size_t IndexSecond = 17; - std::from_chars(input.data() + IndexYear, input.data() + 4, _year); - std::from_chars(input.data() + IndexMonth, input.data() + 2, _month); - std::from_chars(input.data() + IndexDay, input.data() + 2, _day); - std::from_chars(input.data() + IndexHour, input.data() + 2, _hour); - std::from_chars(input.data() + IndexMinute, input.data() + 2, _minute); - std::from_chars(input.data() + IndexSecond, input.data() + 2, _second); + std::from_chars(input.data() + IndexYear, input.data() + IndexYear + 4, _year); + std::from_chars(input.data() + IndexMonth, input.data() + IndexMonth + 2, _month); + std::from_chars(input.data() + IndexDay, input.data() + IndexDay + 2, _day); + std::from_chars(input.data() + IndexHour, input.data() + IndexHour + 2, _hour); + std::from_chars(input.data() + IndexMinute, input.data() + IndexMinute + 2, _minute); + std::from_chars(input.data() + IndexSecond, input.data() + IndexSecond + 2, _second); } std::string DateTime::ISO8601() const { diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index 84eda4956f..7e6e05b87d 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace { @@ -178,6 +179,8 @@ DashboardItemInstruments::DashboardItemInstruments(const ghoul::Dictionary& dict } void DashboardItemInstruments::render(glm::vec2& penPosition) { + ZoneScoped + double currentTime = global::timeManager.time().j2000Seconds(); if (!ImageSequencer::ref().isReady()) { diff --git a/src/rendering/dashboard.cpp b/src/rendering/dashboard.cpp index 77bc5162eb..c700326cbc 100644 --- a/src/rendering/dashboard.cpp +++ b/src/rendering/dashboard.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "dashboard_lua.inl" @@ -127,6 +128,8 @@ void Dashboard::clearDashboardItems() { } void Dashboard::render(glm::vec2& penPosition) { + ZoneScoped + if (!_isEnabled) { return; } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 08dd69ed3f..c952a43ebd 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -446,6 +447,22 @@ void RenderEngine::initialize() { ghoul::io::TextureReader::ref().addReader( std::make_unique() ); + + _versionString = OPENSPACE_VERSION_STRING_FULL; + if (global::versionChecker.hasLatestVersionInfo()) { + VersionChecker::SemanticVersion latest = global::versionChecker.latestVersion(); + + VersionChecker::SemanticVersion current{ + OPENSPACE_VERSION_MAJOR, + OPENSPACE_VERSION_MINOR, + OPENSPACE_VERSION_PATCH +}; + if (current < latest) { + _versionString += fmt::format( + " [Available: {}.{}.{}]", latest.major, latest.minor, latest.patch + ); + } + } } void RenderEngine::initializeGL() { @@ -1305,31 +1322,9 @@ void RenderEngine::renderVersionInformation() { return; } - std::string versionString = OPENSPACE_VERSION_STRING_FULL; - - if (global::versionChecker.hasLatestVersionInfo()) { - VersionChecker::SemanticVersion latestVersion = - global::versionChecker.latestVersion(); - - VersionChecker::SemanticVersion currentVersion { - OPENSPACE_VERSION_MAJOR, - OPENSPACE_VERSION_MINOR, - OPENSPACE_VERSION_PATCH - }; - if (currentVersion < latestVersion) { - versionString += fmt::format( - " [Available: {}.{}.{}]", - latestVersion.major, latestVersion.minor, latestVersion.patch - ); - } - } - using FR = ghoul::fontrendering::FontRenderer; - const glm::vec2 versionBox = _fontInfo->boundingBox(versionString); - - const glm::vec2 commitBox = _fontInfo->boundingBox( - fmt::format("{}@{}", OPENSPACE_GIT_BRANCH, OPENSPACE_GIT_COMMIT) - ); + const glm::vec2 versionBox = _fontInfo->boundingBox(_versionString); + const glm::vec2 commitBox = _fontInfo->boundingBox(OPENSPACE_GIT_FULL); FR::defaultRenderer().render( *_fontInfo, @@ -1337,13 +1332,13 @@ void RenderEngine::renderVersionInformation() { fontResolution().x - versionBox.x - 10.f, 5.f ), - versionString, + _versionString, glm::vec4(0.5, 0.5, 0.5, 1.f) ); // If a developer hasn't placed the Git command in the path, this variable will be // empty - if (!std::string(OPENSPACE_GIT_COMMIT).empty()) { + if (!std::string_view(OPENSPACE_GIT_COMMIT).empty()) { // We check OPENSPACE_GIT_COMMIT but puse OPENSPACE_GIT_FULL on purpose since // OPENSPACE_GIT_FULL will never be empty (always will contain at least @, but // checking for that is a bit brittle) @@ -1381,9 +1376,9 @@ void RenderEngine::renderScreenLog() { size_t nr = 1; const auto now = std::chrono::steady_clock::now(); for (auto& it = lastEntries.first; it != lastEntries.second; ++it) { - const ScreenLog::LogEntry* e = &(*it); + ZoneScopedN("Entry") - std::chrono::duration diff = now - e->timeStamp; + std::chrono::duration diff = now - it->timeStamp; float alpha = 1.f; std::chrono::duration ttf = ScreenLogTimeToLive - FadeTime; @@ -1398,32 +1393,37 @@ void RenderEngine::renderScreenLog() { if (alpha <= 0.f) { break; } - const std::string_view lvl = ghoul::to_string(e->level); - const std::string_view message = - std::string_view(e->message).substr(0, MessageLength); + std::string_view message = std::string_view(it->message).substr(0, MessageLength); nr += std::count(message.begin(), message.end(), '\n'); const glm::vec4 white(0.9f, 0.9f, 0.9f, alpha); - std::string str = fmt::format( - "{:<15} {}{}", - e->timeString, - e->category.substr(0, CategoryLength), - e->category.length() > CategoryLength ? "..." : "" - ); + std::array buf; + { + std::fill(buf.begin(), buf.end(), 0); + char* end = fmt::format_to( + buf.data(), + "{:<15} {}{}", + it->timeString, + std::string_view(it->category).substr(0, CategoryLength), + it->category.length() > CategoryLength ? "..." : "" + ); + std::string_view text = std::string_view(buf.data(), end - buf.data()); - RenderFont( - *_fontLog, - glm::vec2( - 10.f, - _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset - ), - str, - white - ); + RenderFont( + *_fontLog, + glm::vec2( + 10.f, + _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset + ), + text, + white + ); + } - const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) { - switch (level) { + { + const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) { + switch (level) { case ghoul::logging::LogLevel::Debug: return glm::vec4(0.f, 1.f, 0.f, alpha); case ghoul::logging::LogLevel::Warning: @@ -1434,18 +1434,23 @@ void RenderEngine::renderScreenLog() { return glm::vec4(0.3f, 0.3f, 0.85f, alpha); default: return white; - } - }(e->level); + } + }(it->level); - RenderFont( - *_fontLog, - glm::vec2( - 10 + 30 * _fontLog->pointSize(), - _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset - ), - fmt::format("({})", lvl), - color - ); + const std::string_view lvl = ghoul::to_string(it->level); + std::fill(buf.begin(), buf.end(), 0); + char* end = fmt::format_to(buf.data(), "({})", lvl); + std::string_view levelText = std::string_view(buf.data(), end - buf.data()); + RenderFont( + *_fontLog, + glm::vec2( + 10 + 30 * _fontLog->pointSize(), + _fontLog->pointSize() * nr * 2 + fontRes.y * _verticalLogOffset + ), + levelText, + color + ); + } RenderFont( *_fontLog,