From 3fc8d0aa05f6802c3821445a9a06aa552febff87 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Mon, 1 Jun 2026 00:43:58 +0200 Subject: [PATCH] a --- include/frontend.hpp | 3 +++ source/WindowScreen.cpp | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/frontend.hpp b/include/frontend.hpp index cfa750b..0d98d3a 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -232,6 +232,7 @@ private: FPSArray in_fps; FPSArray draw_fps; std::chrono::time_point last_draw_time; + std::chrono::time_point start_draw_time; FPSArray poll_fps; std::chrono::time_point last_poll_time; std::chrono::time_point last_menu_change_time; @@ -282,6 +283,8 @@ private: void prepare_menu_draws(int view_size_x, int view_size_y); void execute_menu_draws(); + void print_time_since_start_draw(std::string text); + static void reset_operations(ScreenOperations &operations); void free_ownership_of_window(bool is_main_thread); diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index bd2dd9b..ff170df 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -285,7 +285,7 @@ void WindowScreen::after_thread_join() { } void WindowScreen::draw(double frame_time, VideoOutputData* out_buf, InputVideoDataType video_data_type, bool update_rendered_buffer) { - auto start_draw_time = std::chrono::high_resolution_clock::now(); + this->start_draw_time = std::chrono::high_resolution_clock::now(); FPSArrayInsertElement(&this->in_fps, frame_time); if(!this->done_display) { return; @@ -319,6 +319,7 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf, InputVideoD this->last_poll_time = std::chrono::high_resolution_clock::now(); } if(this->m_win.isOpen() || this->loaded_operations.call_create) { + print_time_since_start_draw("TO REAL START DRAW TIME"); this->curr_frame_texture_pos = (this->curr_frame_texture_pos + 1) % this->num_frames_to_blend; WindowScreen::reset_operations(future_operations); if(update_rendered_buffer) { @@ -354,10 +355,12 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf, InputVideoD this->display_lock.unlock(); if((!this->main_thread_owns_window) && ((this->scheduled_work_on_window) || (!this->loaded_info.async))) while(!this->is_thread_done); + print_time_since_start_draw("PRE WINDOW DRAW TIME"); this->window_factory(true); // This must be done in the main thread for it to work on Windows... :/ this->m_win.setMouseCursorVisible(this->loaded_info.show_mouse); this->is_window_factory_done = true; + print_time_since_start_draw("POST WINDOW DRAW TIME"); if(!this->loaded_info.async) this->display_call(true); auto curr_time = std::chrono::high_resolution_clock::now(); @@ -365,13 +368,18 @@ void WindowScreen::draw(double frame_time, VideoOutputData* out_buf, InputVideoD FPSArrayInsertElement(&this->draw_fps, diff.count()); this->last_draw_time = curr_time; printf("OUT: %f\n", diff.count()); - diff = curr_time - start_draw_time; - printf("DRAW TIME: %f\n", diff.count()); + print_time_since_start_draw("TOTAL DRAW TIME"); } else this->was_last_frame_null = true; } +void WindowScreen::print_time_since_start_draw(std::string text) { + auto curr_time = std::chrono::high_resolution_clock::now(); + std::chrono::duration diff = curr_time - this->start_draw_time; + printf("%s: %f\n", text.c_str(), diff.count()); +} + void WindowScreen::update_connection() { if((this->last_connected_status == this->capture_status->connected) && (this->last_title_check_id == this->capture_status->title_check_id)) return;