From f04083d997550611b2e2bc02f593a04e10b7aaa1 Mon Sep 17 00:00:00 2001 From: ZedB0T <89345505+Zedb0T@users.noreply.github.com> Date: Wed, 29 Mar 2023 18:24:28 -0400 Subject: [PATCH] Dont overwrite profile data (#2440) This way a user can take multiple data samples from one/multiple play sessions quickly. Creates a directory called profile_data that is added to gitignore to place the data in, and checks to see if a file is there and if so it creates prof1.json prof2.json prof3.json and so on... --- .gitignore | 1 + game/graphics/pipelines/opengl.cpp | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2c4f1b0ab4..a77e0d760f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ cmake-build-debug--o0/* build/* /decompiler_out* logs/* +profile_data/* # for vscode/clangd .cache/* diff --git a/game/graphics/pipelines/opengl.cpp b/game/graphics/pipelines/opengl.cpp index ca1277e517..0f90c7a6b6 100644 --- a/game/graphics/pipelines/opengl.cpp +++ b/game/graphics/pipelines/opengl.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "common/dma/dma_copy.h" #include "common/global_profiler/GlobalProfiler.h" @@ -739,11 +740,35 @@ void update_global_profiler() { if (g_gfx_data->debug_gui.dump_events) { prof().set_enable(false); g_gfx_data->debug_gui.dump_events = false; - prof().dump_to_json((file_util::get_jak_project_dir() / "prof.json").string()); + + std::string dir_path = (file_util::get_jak_project_dir() / "profile_data").string(); + fs::create_directories(dir_path); + + std::string file_path = (file_util::get_jak_project_dir() / "profile_data/prof.json").string(); + std::ifstream file(file_path); + if (file.good()) { + file.close(); + + int file_index = 1; + while (true) { + std::stringstream ss; + ss << "profile_data/prof" << file_index << ".json"; + std::string new_file_path = (file_util::get_jak_project_dir() / ss.str()).string(); + std::ifstream new_file(new_file_path); + if (!new_file.good()) { + file_path = new_file_path; + break; + } + new_file.close(); + file_index++; + } + } else { + file.close(); + } + prof().dump_to_json(file_path); } prof().set_enable(g_gfx_data->debug_gui.record_events); } - void GLDisplay::VMode::set(const GLFWvidmode* vmode) { width = vmode->width; height = vmode->height;