jak-project/game/graphics/opengl_renderer/debug_gui.h
Tyler Wilding 73ff53f01d
debugging: Improve event profiler utility (#3561)
- Can make the event buffer larger or smaller
- UI shows the current event index / size, so you know how fast it's
filling up
- Can save compressed, 10x reduction in filesize and Windows 11 explorer
actually supports ZSTD natively now so this isn't inconvenient at all

![Screenshot 2024-06-22
000343](https://github.com/open-goal/jak-project/assets/13153231/2f7dfa41-d931-4170-a848-840cbed9be9f)
> An example of almost 1 million events.  Results in a 4mb file.
2024-06-22 22:01:33 -04:00

85 lines
2.1 KiB
C++

#pragma once
/*!
* @file debug_gui.h
* The debug menu-bar and frame timing window
*/
#include "common/dma/dma.h"
#include "common/util/Timer.h"
#include "common/versions/versions.h"
class FrameTimeRecorder {
public:
static constexpr int SIZE = 60 * 5;
void finish_frame();
void start_frame();
void draw_window(const DmaStats& dma_stats);
bool should_advance_frame() {
if (m_single_frame) {
m_single_frame = false;
return true;
}
return m_play;
}
bool do_gl_finish = false;
private:
float m_frame_times[SIZE] = {0};
float m_last_frame_time = 0;
int m_idx = 0;
Timer m_compute_timer;
Timer m_fps_timer;
bool m_open = true;
bool m_play = true;
bool m_single_frame = false;
};
class OpenGlDebugGui {
public:
OpenGlDebugGui() {}
void start_frame();
void finish_frame();
void draw(const DmaStats& dma_stats);
bool should_draw_render_debug() const { return master_enable && m_draw_debug; }
bool should_draw_profiler() const { return master_enable && m_draw_profiler; }
bool should_draw_subtitle_editor() const { return master_enable && m_subtitle_editor; }
bool should_draw_filters_menu() const { return master_enable && m_filters_menu; }
bool should_draw_loader_menu() const { return master_enable && m_draw_loader; }
bool should_advance_frame() { return m_frame_timer.should_advance_frame(); }
bool should_gl_finish() const { return m_frame_timer.do_gl_finish; }
bool get_screenshot_flag() {
if (m_want_screenshot) {
m_want_screenshot = false;
return true;
}
return false;
}
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;
bool master_enable = false;
private:
FrameTimeRecorder m_frame_timer;
bool m_draw_frame_time = false;
bool m_draw_profiler = false;
bool m_draw_debug = false;
bool m_draw_loader = false;
bool m_subtitle_editor = false;
bool m_filters_menu = false;
bool m_want_screenshot = false;
float target_fps_input = 60.f;
};