From 9b2f3e206d64ad6a1efcbf4759816c55b89539f1 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 22 Jun 2024 00:04:44 -0400 Subject: [PATCH] game: some UX cleanup --- common/global_profiler/GlobalProfiler.cpp | 7 ++++++- common/global_profiler/GlobalProfiler.h | 6 ++++-- game/graphics/opengl_renderer/debug_gui.cpp | 9 +++++++-- game/graphics/opengl_renderer/debug_gui.h | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/common/global_profiler/GlobalProfiler.cpp b/common/global_profiler/GlobalProfiler.cpp index 5c6f645123..cdbed8af67 100644 --- a/common/global_profiler/GlobalProfiler.cpp +++ b/common/global_profiler/GlobalProfiler.cpp @@ -39,7 +39,8 @@ GlobalProfiler::GlobalProfiler() { m_nodes.resize(m_max_events); } -void GlobalProfiler::update_event_buffer_size() { +void GlobalProfiler::update_event_buffer_size(size_t new_size) { + m_max_events = new_size; m_nodes.resize(m_max_events); } @@ -73,6 +74,10 @@ void GlobalProfiler::root_event() { instant_event("ROOT"); } +size_t GlobalProfiler::get_next_idx() { + return (m_next_idx % m_nodes.size()); +} + void GlobalProfiler::begin_event(const char* name) { event(name, ProfNode::BEGIN); } diff --git a/common/global_profiler/GlobalProfiler.h b/common/global_profiler/GlobalProfiler.h index eb55f421f2..fdf903f8fb 100644 --- a/common/global_profiler/GlobalProfiler.h +++ b/common/global_profiler/GlobalProfiler.h @@ -17,7 +17,8 @@ struct ProfNode { class GlobalProfiler { public: GlobalProfiler(); - void update_event_buffer_size(); + size_t get_max_events() { return m_max_events; } + void update_event_buffer_size(size_t new_size); void set_waiting_for_event(const std::string& event_name); void instant_event(const char* name); void begin_event(const char* name); @@ -28,12 +29,13 @@ class GlobalProfiler { void dump_to_json(); void root_event(); bool is_enabled() { return m_enabled; } + size_t get_next_idx(); - int m_max_events = 65536; bool m_enable_compression = false; private: std::atomic_bool m_enabled = false; + size_t m_max_events = 65536; u64 m_t0 = 0; std::atomic_size_t m_next_idx = 0; std::vector m_nodes; diff --git a/game/graphics/opengl_renderer/debug_gui.cpp b/game/graphics/opengl_renderer/debug_gui.cpp index b0c9dcece4..ba865e7272 100644 --- a/game/graphics/opengl_renderer/debug_gui.cpp +++ b/game/graphics/opengl_renderer/debug_gui.cpp @@ -165,9 +165,14 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) { if (ImGui::Checkbox("Record Events", &record_events)) { prof().set_enable(record_events); } - ImGui::InputInt("Event Buffer Size", &prof().m_max_events); + ImGui::SameLine(); + ImGui::Text(fmt::format("({}/{})", prof().get_next_idx(), prof().get_max_events()).c_str()); + ImGui::InputInt("Event Buffer Size", &max_event_buffer_size); if (ImGui::Button("Resize")) { - prof().update_event_buffer_size(); + prof().update_event_buffer_size(max_event_buffer_size); + } + if (ImGui::Button("Reset Events")) { + prof().clear(); } ImGui::Separator(); ImGui::Checkbox("Enable Compression", &prof().m_enable_compression); diff --git a/game/graphics/opengl_renderer/debug_gui.h b/game/graphics/opengl_renderer/debug_gui.h index 239d8a01df..7ed401b213 100644 --- a/game/graphics/opengl_renderer/debug_gui.h +++ b/game/graphics/opengl_renderer/debug_gui.h @@ -64,6 +64,7 @@ class OpenGlDebugGui { bool small_profiler = false; bool record_events = false; + int max_event_buffer_size = 65536; bool want_reboot_in_debug = false; bool screenshot_hotkey_enabled = true;