mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 00:57:44 -04:00
game: Allow changing the GlobalProfiler
's buffer size at runtime
This commit is contained in:
parent
90c11bde8f
commit
fb24d2a5f4
|
@ -140,7 +140,7 @@ void printstd(const char* format, va_list arg_list) {
|
||||||
internal::log_vprintf(format, arg_list);
|
internal::log_vprintf(format, arg_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
// how many extra log files for a single program should be kept?
|
// how many extra log files for a single program should be kept
|
||||||
constexpr int LOG_ROTATE_MAX = 10;
|
constexpr int LOG_ROTATE_MAX = 10;
|
||||||
|
|
||||||
void set_file(const std::string& filename,
|
void set_file(const std::string& filename,
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
#include "ObjectFileDB.h"
|
#include "ObjectFileDB.h"
|
||||||
|
|
||||||
|
#include "common/formatter/formatter.h"
|
||||||
#include "common/goos/PrettyPrinter.h"
|
#include "common/goos/PrettyPrinter.h"
|
||||||
#include "common/link_types.h"
|
#include "common/link_types.h"
|
||||||
#include "common/log/log.h"
|
#include "common/log/log.h"
|
||||||
#include "common/util/FileUtil.h"
|
#include "common/util/FileUtil.h"
|
||||||
#include "common/util/Timer.h"
|
#include "common/util/Timer.h"
|
||||||
#include "common/util/string_util.h"
|
#include "common/util/string_util.h"
|
||||||
#include <common/formatter/formatter.h>
|
|
||||||
|
|
||||||
#include "decompiler/IR2/Form.h"
|
#include "decompiler/IR2/Form.h"
|
||||||
#include "decompiler/analysis/analyze_inspect_method.h"
|
#include "decompiler/analysis/analyze_inspect_method.h"
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
|
|
||||||
#include "debug_gui.h"
|
#include "debug_gui.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "common/global_profiler/GlobalProfiler.h"
|
#include "common/global_profiler/GlobalProfiler.h"
|
||||||
|
#include "common/util/string_util.h"
|
||||||
|
|
||||||
#include "game/graphics/display.h"
|
#include "game/graphics/display.h"
|
||||||
#include "game/graphics/gfx.h"
|
#include "game/graphics/gfx.h"
|
||||||
|
@ -164,10 +162,22 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::BeginMenu("Event Profiler")) {
|
if (ImGui::BeginMenu("Event Profiler")) {
|
||||||
if (ImGui::Checkbox("Record", &record_events)) {
|
if (ImGui::Checkbox("Record Events", &record_events)) {
|
||||||
prof().set_enable(record_events);
|
prof().set_enable(record_events);
|
||||||
}
|
}
|
||||||
ImGui::MenuItem("Dump to file", nullptr, &dump_events);
|
ImGui::InputInt("Event Buffer Size", &prof().m_max_events);
|
||||||
|
if (ImGui::Button("Resize")) {
|
||||||
|
prof().update_event_buffer_size();
|
||||||
|
}
|
||||||
|
ImGui::Separator();
|
||||||
|
ImGui::Checkbox("Enable Compression", &prof().m_enable_compression);
|
||||||
|
if (ImGui::Button("Dump to File")) {
|
||||||
|
record_events = false;
|
||||||
|
prof().dump_to_json();
|
||||||
|
}
|
||||||
|
// if (ImGui::Button("Open dump folder")) {
|
||||||
|
// // TODO - https://github.com/mlabbe/nativefiledialog
|
||||||
|
// }
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ class OpenGlDebugGui {
|
||||||
|
|
||||||
bool small_profiler = false;
|
bool small_profiler = false;
|
||||||
bool record_events = false;
|
bool record_events = false;
|
||||||
bool dump_events = false;
|
|
||||||
bool want_reboot_in_debug = false;
|
bool want_reboot_in_debug = false;
|
||||||
|
|
||||||
bool screenshot_hotkey_enabled = true;
|
bool screenshot_hotkey_enabled = true;
|
||||||
|
|
|
@ -448,23 +448,6 @@ void render_game_frame(int game_width,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_global_profiler() {
|
|
||||||
if (g_gfx_data->debug_gui.dump_events) {
|
|
||||||
prof().set_enable(false);
|
|
||||||
g_gfx_data->debug_gui.dump_events = false;
|
|
||||||
|
|
||||||
// TODO - the file rotation code had an infinite loop here if it couldn't find anything
|
|
||||||
// matching the format
|
|
||||||
//
|
|
||||||
// Does the existing log rotation code have that problem?
|
|
||||||
|
|
||||||
auto file_path = file_util::get_jak_project_dir() / "profile_data" /
|
|
||||||
fmt::format("prof-{}.json", str_util::current_local_timestamp_no_colons());
|
|
||||||
file_util::create_dir_if_needed_for_file(file_path);
|
|
||||||
prof().dump_to_json(file_path.string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GLDisplay::process_sdl_events() {
|
void GLDisplay::process_sdl_events() {
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
while (SDL_PollEvent(&evt) != 0) {
|
while (SDL_PollEvent(&evt) != 0) {
|
||||||
|
@ -603,7 +586,6 @@ void GLDisplay::render() {
|
||||||
// Start timing for the next frame.
|
// Start timing for the next frame.
|
||||||
g_gfx_data->debug_gui.start_frame();
|
g_gfx_data->debug_gui.start_frame();
|
||||||
prof().instant_event("ROOT");
|
prof().instant_event("ROOT");
|
||||||
update_global_profiler();
|
|
||||||
|
|
||||||
// toggle even odd and wake up engine waiting on vsync.
|
// toggle even odd and wake up engine waiting on vsync.
|
||||||
// TODO: we could play with moving this earlier, right after the final bucket renderer.
|
// TODO: we could play with moving this earlier, right after the final bucket renderer.
|
||||||
|
|
Loading…
Reference in a new issue