diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index 975adb648e..99da54b3f4 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -88,7 +88,7 @@ constexpr bool SIMULATE_SLOW_IO = false; #else constexpr bool SIMULATE_SLOW_IO = false; #endif -constexpr bool LOG_IO = false; +constexpr bool LOG_IO = true; #ifndef S_ISDIR #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) diff --git a/Core/FileSystems/BlobFileSystem.cpp b/Core/FileSystems/BlobFileSystem.cpp index 76ca05a206..5e18ad2911 100644 --- a/Core/FileSystems/BlobFileSystem.cpp +++ b/Core/FileSystems/BlobFileSystem.cpp @@ -19,6 +19,7 @@ BlobFileSystem::BlobFileSystem(IHandleAllocator *hAlloc, FileLoader *fileLoader, std::string alias) : alloc_(hAlloc), fileLoader_(fileLoader), alias_(alias) { + NOTICE_LOG(Log::FileSystem, "%s", fileLoader->GetPath().c_str()); } BlobFileSystem::~BlobFileSystem() { diff --git a/Core/System.cpp b/Core/System.cpp index 56ce4ef203..dceaf3323d 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -63,6 +63,7 @@ #include "Core/SaveState.h" #include "Common/ExceptionHandlerSetup.h" #include "GPU/GPUCommon.h" +#include "GPU/Debugger/Playback.h" #include "GPU/Debugger/RecordFormat.h" #include "Core/RetroAchievements.h" @@ -326,6 +327,8 @@ void CPU_Shutdown() { PSP_LoadingLock lock; PSPLoaders_Shutdown(); + GPURecord::Replay_Unload(); + if (g_Config.bAutoSaveSymbolMap) { SaveSymbolMapIfSupported(); } diff --git a/Core/Util/GameDB.h b/Core/Util/GameDB.h index babf63e244..853b808363 100644 --- a/Core/Util/GameDB.h +++ b/Core/Util/GameDB.h @@ -19,6 +19,8 @@ struct GameDBInfo { class GameDB { public: // Warning: Linear search. Don't call it every frame if possible. + // If this returns true, there is at least 1 entry in infos, so it's safe to go + // look up element 0 for a quick guess. bool GetGameInfos(std::string_view id, std::vector *infos); private: diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index cd5ea163ce..7bfb9e6f19 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -43,6 +43,7 @@ #include "Core/MIPS/MIPS.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/System.h" +#include "Core/Util/GameDB.h" #include "GPU/GPUCommon.h" #include "GPU/GPUState.h" #include "GPU/ge_constants.h" @@ -73,6 +74,8 @@ static uint32_t lastExecVersion; static std::vector lastExecCommands; static std::vector lastExecPushbuf; +// This thread is restarted every frame (dump execution) for simplicity. TODO: Make persistent? +// Alternatively, get rid of it, but the code is written in a way that makes it difficult (you'll see if you try). static std::thread replayThread; static std::mutex opStartLock; @@ -80,6 +83,7 @@ static std::condition_variable opStartWait; static std::mutex opFinishLock; static std::condition_variable opFinishWait; + static Operation g_opToExec; static u32 g_retVal; static bool g_opDone = true; @@ -825,6 +829,9 @@ static bool ReadCompressed(u32 fp, void *dest, size_t sz, uint32_t version) { static u32 LoadReplay(const std::string &filename) { PROFILE_THIS_SCOPE("ReplayLoad"); + + NOTICE_LOG(Log::GeDebugger, "LoadReplay %s", filename.c_str()); + u32 fp = pspFileSystem.OpenFile(filename, FILEACCESS_READ); Header header; pspFileSystem.ReadFile(fp, (u8 *)&header, sizeof(header)); @@ -843,9 +850,17 @@ static u32 LoadReplay(const std::string &filename) { size_t gameIDLength = strnlen(header.gameID, sizeof(header.gameID)); if (gameIDLength != 0) { g_paramSFO.SetValue("DISC_ID", std::string(header.gameID, gameIDLength), (int)sizeof(header.gameID)); - System_SetWindowTitle(g_paramSFO.GetValueString("DISC_ID")); + std::vector info; + std::string gameTitle = "(unknown title)"; +#if !defined(__LIBRETRO__) + if (g_gameDB.GetGameInfos(header.gameID, &info)) { + gameTitle = info[0].title; + g_paramSFO.SetValue("TITLE", gameTitle, (int)gameTitle.size()); + } +#endif + System_SetWindowTitle(g_paramSFO.GetValueString("DISC_ID") + " : " + gameTitle + " (GE frame dump)"); } else { - System_SetWindowTitle("(old dump: missing DISC_ID)"); + System_SetWindowTitle("(GE frame dump: old format, missing DISC_ID)"); } u32 sz = 0; @@ -872,6 +887,18 @@ static u32 LoadReplay(const std::string &filename) { return version; } +void Replay_Unload() { + _dbg_assert_(!replayThread.joinable()); + + lastExecFilename.clear(); + lastExecVersion = 0; + lastExecCommands.clear(); + lastExecPushbuf.clear(); + + g_opDone = true; + g_retVal = 0; +} + void WriteRunDumpCode(u32 codeStart) { // NOTE: Not static, since parts are run-time computed (MIPS_MAKE_SYSCALL etc) const u32 runDumpCode[] = { diff --git a/GPU/Debugger/Playback.h b/GPU/Debugger/Playback.h index fefd2f9217..fa71d7675f 100644 --- a/GPU/Debugger/Playback.h +++ b/GPU/Debugger/Playback.h @@ -30,6 +30,6 @@ enum class ReplayResult { void WriteRunDumpCode(u32 addr); ReplayResult RunMountedReplay(const std::string &filename); -void ReplayShutdown(); +void Replay_Unload(); } // namespace GPURecord