GPUDump: Support XZ compression
Some checks are pending
Create rolling release / Windows x64 Build (push) Waiting to run
Create rolling release / Windows x64 SSE2 Build (push) Waiting to run
Create rolling release / Windows ARM64 Build (push) Waiting to run
Create rolling release / Linux x64 AppImage (push) Waiting to run
Create rolling release / Linux x64 SSE2 AppImage (push) Waiting to run
Create rolling release / MacOS Universal Build (push) Waiting to run
Create rolling release / Create Release (push) Blocked by required conditions

This commit is contained in:
Stenzek 2024-10-22 19:40:03 +10:00
parent 3a76485e4b
commit 485f81a02f
No known key found for this signature in database
4 changed files with 26 additions and 9 deletions

View File

@ -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> GPUDump::Player::Open(std::string path, Error*
Common::Timer timer;
std::optional<DynamicHeapArray<u8>> 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);

View File

@ -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<size_t>(GPUDumpCompressionMode::MaxCount));
static_assert(s_gpu_dump_compression_mode_display_names.size() ==

View File

@ -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",
};

View File

@ -132,7 +132,9 @@ enum class GPUDumpCompressionMode : u8
ZstLow,
ZstDefault,
ZstHigh,
// TODO: XZ
XZLow,
XZDefault,
XZHigh,
MaxCount
};