Skip to content

Commit

Permalink
game: some UX cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser committed Jun 22, 2024
1 parent feafb27 commit 9b2f3e2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
7 changes: 6 additions & 1 deletion common/global_profiler/GlobalProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions common/global_profiler/GlobalProfiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<ProfNode> m_nodes;
Expand Down
9 changes: 7 additions & 2 deletions game/graphics/opengl_renderer/debug_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions game/graphics/opengl_renderer/debug_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9b2f3e2

Please sign in to comment.