RegTest: Support replaying GPU dumps

pull/3349/head
Stenzek 2 months ago
parent b7832e609f
commit 1ed9e609a5
No known key found for this signature in database

@ -6,13 +6,12 @@ import subprocess
import multiprocessing
from functools import partial
def is_game_path(path):
idx = path.rfind('.')
if idx < 0:
return False
extension = path[idx + 1:].strip().lower()
return extension in ["cue", "chd"]
def is_game_path(path:str):
lpath = path.lower()
for extension in ["cue", "chd", "psxgpu", "psxgpu.zst", "psxgpu.xz"]:
if path.endswith(extension):
return True
return False
def run_regression_test(runner, destdir, dump_interval, frames, renderer, cargs, gamepath):
@ -31,8 +30,10 @@ def run_regression_test(runner, destdir, dump_interval, frames, renderer, cargs,
return os.path.basename(gamepath)
def run_regression_tests(runner, gamedir, destdir, dump_interval, frames, parallel, renderer, cargs):
paths = glob.glob(gamedir + "/*.*", recursive=True)
def run_regression_tests(runner, gamedirs, destdir, dump_interval, frames, parallel, renderer, cargs):
paths = []
for gamedir in gamedirs:
paths += glob.glob(os.path.realpath(gamedir) + "/*.*", recursive=True)
gamepaths = list(filter(is_game_path, paths))
try:
@ -64,7 +65,7 @@ def run_regression_tests(runner, gamedir, destdir, dump_interval, frames, parall
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate frame dump images for regression tests")
parser.add_argument("-runner", action="store", required=True, help="Path to DuckStation regression test runner")
parser.add_argument("-gamedir", action="store", required=True, help="Directory containing game images")
parser.add_argument("-gamedir", action="append", required=True, help="Directory containing game images")
parser.add_argument("-destdir", action="store", required=True, help="Base directory to dump frames to")
parser.add_argument("-dumpinterval", action="store", type=int, default=600, help="Interval to dump frames at")
parser.add_argument("-frames", action="store", type=int, default=36000, help="Number of frames to run")
@ -86,7 +87,7 @@ if __name__ == "__main__":
if (args.cpu is not None):
cargs += ["-cpu", args.cpu]
if not run_regression_tests(args.runner, os.path.realpath(args.gamedir), os.path.realpath(args.destdir), args.dumpinterval, args.frames, args.parallel, args.renderer, cargs):
if not run_regression_tests(args.runner, args.gamedir, os.path.realpath(args.destdir), args.dumpinterval, args.frames, args.parallel, args.renderer, cargs):
sys.exit(1)
else:
sys.exit(0)

@ -106,6 +106,7 @@ public:
ALWAYS_INLINE const std::string& GetPath() const { return m_path; }
ALWAYS_INLINE const std::string& GetSerial() const { return m_serial; }
ALWAYS_INLINE ConsoleRegion GetRegion() const { return m_region; }
ALWAYS_INLINE size_t GetFrameCount() const { return m_frame_offsets.size(); }
static std::unique_ptr<Player> Open(std::string path, Error* error);

@ -622,6 +622,11 @@ bool System::IsReplayingGPUDump()
return static_cast<bool>(s_state.gpu_dump_player);
}
size_t System::GetGPUDumpFrameCount()
{
return s_state.gpu_dump_player ? s_state.gpu_dump_player->GetFrameCount() : 0;
}
bool System::IsStartupCancelled()
{
return s_state.startup_cancelled.load(std::memory_order_acquire);

@ -172,6 +172,7 @@ bool IsValid();
bool IsValidOrInitializing();
bool IsExecuting();
bool IsReplayingGPUDump();
size_t GetGPUDumpFrameCount();
bool IsStartupCancelled();
void CancelPendingStartup();

@ -726,14 +726,6 @@ bool RegTestHost::ParseCommandLineParameters(int argc, char* argv[], std::option
bool RegTestHost::SetNewDataRoot(const std::string& filename)
{
Error error;
std::unique_ptr<CDImage> image = CDImage::Open(filename.c_str(), false, &error);
if (!image)
{
ERROR_LOG("Failed to open CD image '{}' to set data root: {}", Path::GetFileName(filename), error.GetDescription());
return false;
}
if (!s_dump_base_directory.empty())
{
std::string game_subdir = Path::SanitizeFileName(Path::GetFileTitle(filename));
@ -808,6 +800,13 @@ int main(int argc, char* argv[])
goto cleanup;
}
if (System::IsReplayingGPUDump() && !s_dump_base_directory.empty())
{
INFO_LOG("Replaying GPU dump, dumping all frames.");
s_frame_dump_interval = 1;
s_frames_to_run = static_cast<u32>(System::GetGPUDumpFrameCount());
}
if (s_frame_dump_interval > 0)
{
if (s_dump_base_directory.empty())

Loading…
Cancel
Save