mirror of https://github.com/PCSX2/pcsx2.git
gsdx linux replayer: allow to repack gs dump
linux_replay = -N will save N first frames to a new gs dump Save disk space & debug time
This commit is contained in:
parent
99c43881df
commit
01f0f436ac
|
@ -1543,8 +1543,6 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
GSRendererType m_renderer;
|
||||
// Allow to easyly switch between SW/HW renderer -> this effectively removes the ability to select the renderer by function args
|
||||
m_renderer = static_cast<GSRendererType>(theApp.GetConfigI("Renderer"));
|
||||
// alternatively:
|
||||
// m_renderer = static_cast<GSRendererType>(renderer);
|
||||
|
||||
if (m_renderer != GSRendererType::OGL_HW && m_renderer != GSRendererType::OGL_SW)
|
||||
{
|
||||
|
@ -1561,9 +1559,17 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
GSsetBaseMem(regs);
|
||||
|
||||
s_vsync = theApp.GetConfigB("vsync");
|
||||
int finished = theApp.GetConfigI("linux_replay");
|
||||
bool repack_dump = (finished < 0);
|
||||
|
||||
if (theApp.GetConfigI("dump")) {
|
||||
fprintf(stderr, "Dump is enabled. Replay will be disabled\n");
|
||||
finished = 1;
|
||||
}
|
||||
|
||||
long frame_number = 0;
|
||||
|
||||
void* hWnd = NULL;
|
||||
|
||||
int err = _GSopen((void**)&hWnd, "", m_renderer);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "Error failed to GSopen\n");
|
||||
|
@ -1573,12 +1579,18 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
|
||||
{ // Read .gs content
|
||||
std::string f(lpszCmdLine);
|
||||
bool is_xz = (f.size() >= 4) && (f.compare(f.size()-3, 3, ".xz") == 0);
|
||||
if (is_xz)
|
||||
f.replace(f.end()-6, f.end(), "_repack.gs");
|
||||
else
|
||||
f.replace(f.end()-3, f.end(), "_repack.gs");
|
||||
|
||||
#ifdef LZMA_SUPPORTED
|
||||
GSDumpFile* file = (f.size() >= 4) && (f.compare(f.size()-3, 3, ".xz") == 0)
|
||||
? (GSDumpFile*) new GSDumpLzma(lpszCmdLine)
|
||||
: (GSDumpFile*) new GSDumpRaw(lpszCmdLine);
|
||||
GSDumpFile* file = is_xz
|
||||
? (GSDumpFile*) new GSDumpLzma(lpszCmdLine, repack_dump ? f.c_str() : nullptr)
|
||||
: (GSDumpFile*) new GSDumpRaw(lpszCmdLine, repack_dump ? f.c_str() : nullptr);
|
||||
#else
|
||||
GSDumpFile* file = new GSDumpRaw(lpszCmdLine);
|
||||
GSDumpFile* file = new GSDumpRaw(lpszCmdLine, repack_dump ? f.c_str() : nullptr);
|
||||
#endif
|
||||
|
||||
uint32 crc;
|
||||
|
@ -1629,6 +1641,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
|
||||
case 1:
|
||||
file->Read(&p->param, 1);
|
||||
frame_number++;
|
||||
|
||||
break;
|
||||
|
||||
|
@ -1646,6 +1659,9 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
}
|
||||
|
||||
packets.push_back(p);
|
||||
|
||||
if (repack_dump && frame_number > -finished)
|
||||
break;
|
||||
}
|
||||
|
||||
delete file;
|
||||
|
@ -1653,14 +1669,8 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
|
||||
sleep(2);
|
||||
|
||||
//while(IsWindowVisible(hWnd))
|
||||
//FIXME map?
|
||||
int finished = theApp.GetConfigI("linux_replay");
|
||||
if (theApp.GetConfigI("dump")) {
|
||||
fprintf(stderr, "Dump is enabled. Replay will be disabled\n");
|
||||
finished = 1;
|
||||
}
|
||||
unsigned long frame_number = 0;
|
||||
|
||||
frame_number = 0;
|
||||
|
||||
// Init vsync stuff
|
||||
GSvsync(1);
|
||||
|
@ -1720,7 +1730,7 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer)
|
|||
static_cast<GSDeviceOGL*>(s_gs->m_dev)->GenerateProfilerData();
|
||||
|
||||
#ifdef ENABLE_OGL_DEBUG_MEM_BW
|
||||
unsigned long total_frame_nb = std::max(1ul, frame_number) << 10;
|
||||
unsigned long total_frame_nb = std::max(1l, frame_number) << 10;
|
||||
fprintf(stderr, "memory bandwith. T: %f KB/f. V: %f KB/f. U: %f KB/f\n",
|
||||
(float)g_real_texture_upload_byte/(float)total_frame_nb,
|
||||
(float)g_vertex_upload_byte/(float)total_frame_nb,
|
||||
|
|
|
@ -23,23 +23,42 @@
|
|||
|
||||
#if defined(__unix__)
|
||||
|
||||
GSDumpFile::GSDumpFile(char* filename) {
|
||||
GSDumpFile::GSDumpFile(char* filename, const char* repack_filename) {
|
||||
m_fp = fopen(filename, "rb");
|
||||
if (m_fp == NULL) {
|
||||
if (m_fp == nullptr) {
|
||||
fprintf(stderr, "failed to open %s\n", filename);
|
||||
throw "BAD"; // Just exit the program
|
||||
}
|
||||
|
||||
m_repack_fp = nullptr;
|
||||
if (repack_filename) {
|
||||
m_repack_fp = fopen(repack_filename, "wb");
|
||||
if (m_repack_fp == nullptr)
|
||||
fprintf(stderr, "failed to open %s for repack\n", repack_filename);
|
||||
}
|
||||
}
|
||||
|
||||
void GSDumpFile::Repack(void* ptr, size_t size) {
|
||||
if (m_repack_fp == nullptr)
|
||||
return;
|
||||
|
||||
size_t ret = fwrite(ptr, 1, size, m_repack_fp);
|
||||
if (ret != size)
|
||||
fprintf(stderr, "Failed to repack\n");
|
||||
|
||||
}
|
||||
|
||||
GSDumpFile::~GSDumpFile() {
|
||||
if (m_fp)
|
||||
fclose(m_fp);
|
||||
if (m_repack_fp)
|
||||
fclose(m_repack_fp);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
#ifdef LZMA_SUPPORTED
|
||||
|
||||
GSDumpLzma::GSDumpLzma(char* filename) : GSDumpFile(filename) {
|
||||
GSDumpLzma::GSDumpLzma(char* filename, const char* repack_filename) : GSDumpFile(filename, repack_filename) {
|
||||
|
||||
memset(&m_strm, 0, sizeof(lzma_stream));
|
||||
|
||||
|
@ -102,6 +121,7 @@ bool GSDumpLzma::IsEof() {
|
|||
void GSDumpLzma::Read(void* ptr, size_t size) {
|
||||
size_t off = 0;
|
||||
uint8_t* dst = (uint8_t*)ptr;
|
||||
size_t full_size = size;
|
||||
while (size) {
|
||||
if (m_avail == 0) {
|
||||
Decompress();
|
||||
|
@ -114,6 +134,7 @@ void GSDumpLzma::Read(void* ptr, size_t size) {
|
|||
m_start += l;
|
||||
off += l;
|
||||
}
|
||||
Repack(ptr, full_size);
|
||||
}
|
||||
|
||||
GSDumpLzma::~GSDumpLzma() {
|
||||
|
@ -129,7 +150,7 @@ GSDumpLzma::~GSDumpLzma() {
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
GSDumpRaw::GSDumpRaw(char* filename) : GSDumpFile(filename) {
|
||||
GSDumpRaw::GSDumpRaw(char* filename, const char* repack_filename) : GSDumpFile(filename, repack_filename) {
|
||||
m_buff_size = 0;
|
||||
m_area = NULL;
|
||||
m_inbuf = NULL;
|
||||
|
@ -156,6 +177,7 @@ void GSDumpRaw::Read(void* ptr, size_t size) {
|
|||
throw "BAD"; // Just exit the program
|
||||
}
|
||||
}
|
||||
Repack(ptr, size);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,15 +25,18 @@
|
|||
#endif
|
||||
|
||||
class GSDumpFile {
|
||||
FILE* m_repack_fp;
|
||||
|
||||
protected:
|
||||
FILE* m_fp;
|
||||
|
||||
void Repack(void* ptr, size_t size);
|
||||
|
||||
public:
|
||||
virtual bool IsEof() = 0;
|
||||
virtual void Read(void* ptr, size_t size) = 0;
|
||||
|
||||
GSDumpFile(char* filename);
|
||||
GSDumpFile(char* filename, const char* repack_filename);
|
||||
virtual ~GSDumpFile();
|
||||
};
|
||||
|
||||
|
@ -53,7 +56,7 @@ class GSDumpLzma : public GSDumpFile {
|
|||
|
||||
public:
|
||||
|
||||
GSDumpLzma(char* filename);
|
||||
GSDumpLzma(char* filename, const char* repack_filename);
|
||||
virtual ~GSDumpLzma();
|
||||
|
||||
bool IsEof();
|
||||
|
@ -74,7 +77,7 @@ class GSDumpRaw : public GSDumpFile {
|
|||
|
||||
public:
|
||||
|
||||
GSDumpRaw(char* filename);
|
||||
GSDumpRaw(char* filename, const char* repack_filename);
|
||||
virtual ~GSDumpRaw();
|
||||
|
||||
bool IsEof();
|
||||
|
|
Loading…
Reference in New Issue