diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index 9009632b33..459fe52f23 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "Common/Profiler/Profiler.h" #include "Common/Common.h" #include "Common/Log.h" @@ -637,7 +638,7 @@ bool DumpExecute::Run() { return true; } -static bool ReadCompressed(u32 fp, void *dest, size_t sz) { +static bool ReadCompressed(u32 fp, void *dest, size_t sz, uint32_t version) { u32 compressed_size = 0; if (pspFileSystem.ReadFile(fp, (u8 *)&compressed_size, sizeof(compressed_size)) != sizeof(compressed_size)) { return false; @@ -650,7 +651,10 @@ static bool ReadCompressed(u32 fp, void *dest, size_t sz) { } size_t real_size = sz; - snappy_uncompress((const char *)compressed, compressed_size, (char *)dest, &real_size); + if (version < 5) + snappy_uncompress((const char *)compressed, compressed_size, (char *)dest, &real_size); + else + real_size = ZSTD_decompress(dest, real_size, compressed, compressed_size); delete[] compressed; return real_size == sz; @@ -699,8 +703,8 @@ bool RunMountedReplay(const std::string &filename) { lastExecPushbuf.resize(bufsz); bool truncated = false; - truncated = truncated || !ReadCompressed(fp, lastExecCommands.data(), sizeof(Command) * sz); - truncated = truncated || !ReadCompressed(fp, lastExecPushbuf.data(), bufsz); + truncated = truncated || !ReadCompressed(fp, lastExecCommands.data(), sizeof(Command) * sz, header.version); + truncated = truncated || !ReadCompressed(fp, lastExecPushbuf.data(), bufsz, header.version); pspFileSystem.CloseFile(fp); diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 4fdc32b29f..eca8ec9a68 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "Common/Common.h" #include "Common/File/FileUtil.h" @@ -98,9 +98,9 @@ static void BeginRecording() { } static void WriteCompressed(FILE *fp, const void *p, size_t sz) { - size_t compressed_size = snappy_max_compressed_length(sz); + size_t compressed_size = ZSTD_compressBound(sz); u8 *compressed = new u8[compressed_size]; - snappy_compress((const char *)p, sz, (char *)compressed, &compressed_size); + compressed_size = ZSTD_compress(compressed, compressed_size, p, sz, 6); u32 write_size = (u32)compressed_size; fwrite(&write_size, sizeof(write_size), 1, fp); diff --git a/GPU/Debugger/RecordFormat.h b/GPU/Debugger/RecordFormat.h index f59e71aa7e..22395e1594 100644 --- a/GPU/Debugger/RecordFormat.h +++ b/GPU/Debugger/RecordFormat.h @@ -33,7 +33,8 @@ static const char *HEADER_MAGIC = "PPSSPPGE"; // Version 2: Uses snappy // Version 3: Adds FRAMEBUF0-FRAMEBUF9 // Version 4: Expanded header with game ID -static const int VERSION = 4; +// Version 5: Uses zstd +static const int VERSION = 5; static const int MIN_VERSION = 2; enum class CommandType : u8 {