rsx: zip and unzip rsx captures

This commit is contained in:
Megamouse 2023-11-09 22:31:55 +01:00
parent 66d01b688c
commit 840455b872
3 changed files with 25 additions and 4 deletions

View File

@ -24,6 +24,7 @@
#include "Program/GLSLCommon.h"
#include "Utilities/date_time.h"
#include "Utilities/StrUtil.h"
#include "Crypto/unzip.h"
#include "util/serialization.hpp"
#include "util/asm.hpp"
@ -3588,14 +3589,23 @@ namespace rsx
{
capture_current_frame = false;
const std::string file_path = fs::get_config_dir() + "captures/" + Emu.GetTitleID() + "_" + date_time::current_time_narrow() + "_capture.rrc";
std::string file_path = fs::get_config_dir() + "captures/" + Emu.GetTitleID() + "_" + date_time::current_time_narrow() + "_capture.rrc";
// todo: may want to compress this data?
utils::serial save_manager;
save_manager.reserve(0x800'0000); // 128MB
save_manager(frame_capture);
if (std::vector<u8> zipped = zip(save_manager.data); !zipped.empty())
{
file_path += ".gz";
save_manager.data = std::move(zipped);
}
else
{
rsx_log.error("Failed to compress capture");
}
fs::pending_file temp(file_path);
if (temp.file && (temp.file.write(save_manager.data), temp.commit(false)))

View File

@ -38,6 +38,7 @@
#include "Utilities/StrUtil.h"
#include "../Crypto/unself.h"
#include "../Crypto/unzip.h"
#include "util/logs.hpp"
#include "util/serialization.hpp"
#include "savestate_utils.hpp"
@ -717,6 +718,16 @@ bool Emulator::BootRsxCapture(const std::string& path)
load.m_file_handler = make_uncompressed_serialization_file_handler(std::move(in_file));
load.set_reading_state();
if (fmt::to_lower(path).ends_with(".gz"))
{
load.data = unzip(load.data);
if (load.data.empty())
{
sys_log.error("Failed to unzip rsx capture file!");
return false;
}
}
load(*frame);
in_file.close();

View File

@ -654,7 +654,7 @@ void main_window::BootRsxCapture(std::string path)
is_stopped = true;
}
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select RSX Capture"), qstr(fs::get_config_dir() + "captures/"), tr("RRC files (*.rrc *.RRC);;All files (*.*)"));
const QString file_path = QFileDialog::getOpenFileName(this, tr("Select RSX Capture"), qstr(fs::get_config_dir() + "captures/"), tr("RRC files (*.rrc *.RRC *.rrc.gz *.RRC.GZ);;All files (*.*)"));
if (file_path.isEmpty())
{
@ -3553,7 +3553,7 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
}
else if (m_drop_file_url_list.size() == 1)
{
if (suffix_lo == "rrc")
if (suffix_lo == "rrc" || path.toLower().endsWith(".rrc.gz"))
{
type = drop_type::drop_rrc;
}