| 146 | } |
| 147 | |
| 148 | void ImGuiDebugOverlay::UpdateFrameTimings() |
| 149 | { |
| 150 | if (lastUpdateTime_.secondsSince() > updateTime_) { |
| 151 | const AppConfiguration& appCfg = theApplication().GetAppConfiguration(); |
| 152 | |
| 153 | plotValues_[ValuesType::FrameTime][index_] = theApplication().GetFrameTimer().GetLastFrameDuration() * 1000.0f; |
| 154 | |
| 155 | #if defined(NCINE_PROFILING) |
| 156 | auto timings = theApplication().GetTimings(); |
| 157 | plotValues_[ValuesType::BeginFrame][index_] = timings[(std::int32_t)Application::Timings::BeginFrame] * 1000.0f; |
| 158 | if (appCfg.withScenegraph) { |
| 159 | plotValues_[ValuesType::PostUpdate][index_] = timings[(std::int32_t)Application::Timings::PostUpdate] * 1000.0f; |
| 160 | } |
| 161 | plotValues_[ValuesType::ImGui][index_] = timings[(std::int32_t)Application::Timings::ImGui] * 1000.0f; |
| 162 | plotValues_[ValuesType::EndFrame][index_] = timings[(std::int32_t)Application::Timings::EndFrame] * 1000.0f; |
| 163 | |
| 164 | if (appCfg.withScenegraph) { |
| 165 | plotValues_[ValuesType::UpdateVisitDraw][index_] = timings[(std::int32_t)Application::Timings::Update] * 1000.0f + |
| 166 | timings[(std::int32_t)Application::Timings::Visit] * 1000.0f + timings[(std::int32_t)Application::Timings::Draw] * 1000.0f; |
| 167 | plotValues_[ValuesType::Update][index_] = timings[(std::int32_t)Application::Timings::Update] * 1000.0f; |
| 168 | plotValues_[ValuesType::Visit][index_] = timings[(std::int32_t)Application::Timings::Visit] * 1000.0f; |
| 169 | plotValues_[ValuesType::Draw][index_] = timings[(std::int32_t)Application::Timings::Draw] * 1000.0f; |
| 170 | } |
| 171 | #endif |
| 172 | |
| 173 | float maxFrameTime = 0.0f, avgFrameTime = 0.0f; |
| 174 | #if defined(NCINE_PROFILING) |
| 175 | float maxUpdateVisitDraw = 0.0f, avgUpdateVisitDraw = 0.0f; |
| 176 | #endif |
| 177 | for (std::uint32_t i = 0; i < numValues_; i++) { |
| 178 | if (maxFrameTime < plotValues_[ValuesType::FrameTime][i]) { |
| 179 | maxFrameTime = plotValues_[ValuesType::FrameTime][i]; |
| 180 | } |
| 181 | avgFrameTime += plotValues_[ValuesType::FrameTime][i]; |
| 182 | |
| 183 | #if defined(NCINE_PROFILING) |
| 184 | if (appCfg.withScenegraph) { |
| 185 | if (maxUpdateVisitDraw < plotValues_[ValuesType::UpdateVisitDraw][i]) { |
| 186 | maxUpdateVisitDraw = plotValues_[ValuesType::UpdateVisitDraw][i]; |
| 187 | } |
| 188 | avgUpdateVisitDraw += plotValues_[ValuesType::UpdateVisitDraw][i]; |
| 189 | } |
| 190 | #endif |
| 191 | } |
| 192 | |
| 193 | avgFrameTime = avgFrameTime * 2.0f / numValues_; |
| 194 | if (maxFrameTime < avgFrameTime) { |
| 195 | maxFrameTime = avgFrameTime; |
| 196 | } |
| 197 | if (maxFrameTime_ < maxFrameTime) { |
| 198 | maxFrameTime_ = maxFrameTime; |
| 199 | } else { |
| 200 | maxFrameTime_ = lerp(maxFrameTime_, maxFrameTime, 0.2f); |
| 201 | } |
| 202 | |
| 203 | #if defined(NCINE_PROFILING) |
| 204 | avgUpdateVisitDraw = avgUpdateVisitDraw * 2.0f / numValues_; |
| 205 | if (maxUpdateVisitDraw < avgUpdateVisitDraw) { |
no test coverage detected