Bläddra i källkod

Merge pull request #60159 from Calinou/print-fps-hide-unstable-prints

Rémi Verschelde 3 år sedan
förälder
incheckning
129767da70
2 ändrade filer med 12 tillägg och 5 borttagningar
  1. 11 5
      main/main.cpp
  2. 1 0
      main/main.h

+ 11 - 5
main/main.cpp

@@ -2634,6 +2634,7 @@ bool Main::start() {
 
 uint64_t Main::last_ticks = 0;
 uint32_t Main::frames = 0;
+uint32_t Main::hide_print_fps_attempts = 3;
 uint32_t Main::frame = 0;
 bool Main::force_redraw_requested = false;
 int Main::iterating = 0;
@@ -2774,12 +2775,17 @@ bool Main::iteration() {
 	Engine::get_singleton()->_process_frames++;
 
 	if (frame > 1000000) {
-		if (editor || project_manager) {
-			if (print_fps) {
-				print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2)));
+		// Wait a few seconds before printing FPS, as FPS reporting just after the engine has started is inaccurate.
+		if (hide_print_fps_attempts == 0) {
+			if (editor || project_manager) {
+				if (print_fps) {
+					print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2)));
+				}
+			} else if (print_fps || GLOBAL_GET("debug/settings/stdout/print_fps")) {
+				print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2)));
 			}
-		} else if (GLOBAL_GET("debug/settings/stdout/print_fps") || print_fps) {
-			print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2)));
+		} else {
+			hide_print_fps_attempts--;
 		}
 
 		Engine::get_singleton()->_fps = frames;

+ 1 - 0
main/main.h

@@ -38,6 +38,7 @@
 class Main {
 	static void print_help(const char *p_binary);
 	static uint64_t last_ticks;
+	static uint32_t hide_print_fps_attempts;
 	static uint32_t frames;
 	static uint32_t frame;
 	static bool force_redraw_requested;