mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	ENABLE_RENDER_STATISTICS -> FPS averaged to last second
This commit is contained in:
		
							parent
							
								
									1185ec9d2a
								
							
						
					
					
						commit
						bf3786be59
					
				
					 2 changed files with 23 additions and 16 deletions
				
			
		|  | @ -1679,22 +1679,20 @@ void GLCanvas3D::render() | |||
|     if (wxGetApp().plater()->is_render_statistic_dialog_visible()) { | ||||
|         ImGuiWrapper& imgui = *wxGetApp().imgui(); | ||||
|         imgui.begin(std::string("Render statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse); | ||||
|         imgui.text("Last frame: "); | ||||
|         imgui.text("Last frame:"); | ||||
|         ImGui::SameLine(); | ||||
|         imgui.text(std::to_string(m_render_stats.last_frame)); | ||||
|         long long average = m_render_stats.get_average(); | ||||
|         imgui.text(std::to_string(average)); | ||||
|         ImGui::SameLine(); | ||||
|         imgui.text("  ms"); | ||||
|         imgui.text("FPS: "); | ||||
|         imgui.text("ms"); | ||||
|         imgui.text("FPS:"); | ||||
|         ImGui::SameLine(); | ||||
|         imgui.text(std::to_string(static_cast<int>(1000.0f / static_cast<float>(m_render_stats.last_frame)))); | ||||
| //    imgui.text("Imgui FPS: ");
 | ||||
| //    ImGui::SameLine();
 | ||||
| //    imgui.text(std::to_string(static_cast<int>(ImGui::GetIO().Framerate)));
 | ||||
|         imgui.text(std::to_string((average == 0) ? 0 : static_cast<int>(1000.0f / static_cast<float>(average)))); | ||||
|         ImGui::Separator(); | ||||
|         imgui.text("Compressed textures: "); | ||||
|         imgui.text("Compressed textures:"); | ||||
|         ImGui::SameLine(); | ||||
|         imgui.text(OpenGLManager::are_compressed_textures_supported() ? "supported" : "not supported"); | ||||
|         imgui.text("Max texture size: "); | ||||
|         imgui.text("Max texture size:"); | ||||
|         ImGui::SameLine(); | ||||
|         imgui.text(std::to_string(OpenGLManager::get_gl_info().get_max_tex_size())); | ||||
|         imgui.end(); | ||||
|  | @ -1707,8 +1705,6 @@ void GLCanvas3D::render() | |||
| 
 | ||||
|     std::string tooltip; | ||||
| 
 | ||||
| 	 | ||||
| 
 | ||||
| 	// Negative coordinate means out of the window, likely because the window was deactivated.
 | ||||
| 	// In that case the tooltip should be hidden.
 | ||||
|     if (m_mouse.position.x() >= 0. && m_mouse.position.y() >= 0.) { | ||||
|  | @ -1745,7 +1741,7 @@ void GLCanvas3D::render() | |||
| 
 | ||||
| #if ENABLE_RENDER_STATISTICS | ||||
|     auto end_time = std::chrono::high_resolution_clock::now(); | ||||
|     m_render_stats.last_frame = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count(); | ||||
|     m_render_stats.add_frame(std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time).count()); | ||||
| #endif // ENABLE_RENDER_STATISTICS
 | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -320,11 +320,22 @@ class GLCanvas3D | |||
|     }; | ||||
| 
 | ||||
| #if ENABLE_RENDER_STATISTICS | ||||
|     struct RenderStats | ||||
|     class RenderStats | ||||
|     { | ||||
|         long long last_frame; | ||||
|         std::queue<std::pair<long long, long long>> m_frames; | ||||
|         long long m_curr_total{ 0 }; | ||||
| 
 | ||||
|         RenderStats() : last_frame(0) {} | ||||
|     public: | ||||
|         void add_frame(long long frame) { | ||||
|             long long now = wxGetLocalTimeMillis().GetValue(); | ||||
|             if (!m_frames.empty() && now - m_frames.front().first > 1000) { | ||||
|                 m_curr_total -= m_frames.front().second; | ||||
|                 m_frames.pop(); | ||||
|             } | ||||
|             m_curr_total += frame; | ||||
|             m_frames.push({ now, frame }); | ||||
|         } | ||||
|         long long get_average() const { return m_frames.empty() ? 0 : m_curr_total / m_frames.size(); } | ||||
|     }; | ||||
| #endif // ENABLE_RENDER_STATISTICS
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966