diff --git a/src/core/gpu_dump.cpp b/src/core/gpu_dump.cpp index 02c5b1427..f0f0d4b90 100644 --- a/src/core/gpu_dump.cpp +++ b/src/core/gpu_dump.cpp @@ -111,6 +111,16 @@ bool GPUDump::Recorder::Compress(const std::string& source_path, GPUDumpCompress return false; } } + if (mode >= GPUDumpCompressionMode::XZLow && mode <= GPUDumpCompressionMode::XZHigh) + { + const int clevel = + ((mode == GPUDumpCompressionMode::XZLow) ? 3 : ((mode == GPUDumpCompressionMode::ZstHigh) ? 9 : 5)); + if (!CompressHelpers::CompressToFile(fmt::format("{}.xz", source_path).c_str(), std::move(data.value()), clevel, + true, error)) + { + return false; + } + } else { Error::SetStringView(error, "Unknown compression mode."); @@ -313,7 +323,7 @@ std::unique_ptr GPUDump::Player::Open(std::string path, Error* Common::Timer timer; std::optional> data; - if (StringUtil::EndsWithNoCase(path, ".psxgpu.zst")) + if (StringUtil::EndsWithNoCase(path, ".psxgpu.zst") || StringUtil::EndsWithNoCase(path, ".psxgpu.xz")) data = CompressHelpers::DecompressFile(path.c_str(), std::nullopt, error); else data = FileSystem::ReadBinaryFile(path.c_str(), error); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 3fb53b010..2a7fff5da 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1522,12 +1522,16 @@ const char* Settings::GetGPUWireframeModeDisplayName(GPUWireframeMode mode) "GPUWireframeMode"); } -static constexpr const std::array s_gpu_dump_compression_mode_names = {"Disabled", "ZstLow", "ZstDefault", "ZstHigh"}; +static constexpr const std::array s_gpu_dump_compression_mode_names = {"Disabled", "ZstLow", "ZstDefault", "ZstHigh", + "XZLow", "XZDefault", "XZHigh"}; static constexpr const std::array s_gpu_dump_compression_mode_display_names = { TRANSLATE_DISAMBIG_NOOP("Settings", "Disabled", "GPUDumpCompressionMode"), TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (Low)", "GPUDumpCompressionMode"), TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (Default)", "GPUDumpCompressionMode"), TRANSLATE_DISAMBIG_NOOP("Settings", "Zstandard (High)", "GPUDumpCompressionMode"), + TRANSLATE_DISAMBIG_NOOP("Settings", "XZ (Low)", "GPUDumpCompressionMode"), + TRANSLATE_DISAMBIG_NOOP("Settings", "XZ (Default)", "GPUDumpCompressionMode"), + TRANSLATE_DISAMBIG_NOOP("Settings", "XZ (High)", "GPUDumpCompressionMode"), }; static_assert(s_gpu_dump_compression_mode_names.size() == static_cast(GPUDumpCompressionMode::MaxCount)); static_assert(s_gpu_dump_compression_mode_display_names.size() == diff --git a/src/core/system.cpp b/src/core/system.cpp index 6d7cffe2c..c15adc053 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -869,17 +869,18 @@ bool System::IsPsfPath(std::string_view path) bool System::IsGPUDumpPath(std::string_view path) { - return (StringUtil::EndsWithNoCase(path, ".psxgpu") || StringUtil::EndsWithNoCase(path, ".psxgpu.zst")); + return (StringUtil::EndsWithNoCase(path, ".psxgpu") || StringUtil::EndsWithNoCase(path, ".psxgpu.zst") || + StringUtil::EndsWithNoCase(path, ".psxgpu.xz")); } bool System::IsLoadablePath(std::string_view path) { static constexpr const std::array extensions = { - ".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs - ".exe", ".psexe", ".ps-exe", ".psx", // exes - ".psf", ".minipsf", // psf - ".psxgpu", ".psxgpu.zst", // gpu dump - ".m3u", // playlists + ".bin", ".cue", ".img", ".iso", ".chd", ".ecm", ".mds", // discs + ".exe", ".psexe", ".ps-exe", ".psx", // exes + ".psf", ".minipsf", // psf + ".psxgpu", ".psxgpu.zst", ".psxgpu.xz", // gpu dump + ".m3u", // playlists ".pbp", }; diff --git a/src/core/types.h b/src/core/types.h index 918670f8d..49e517ce2 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -132,7 +132,9 @@ enum class GPUDumpCompressionMode : u8 ZstLow, ZstDefault, ZstHigh, - // TODO: XZ + XZLow, + XZDefault, + XZHigh, MaxCount };