diff --git a/scripts/run_regression_tests.py b/scripts/run_regression_tests.py index 657c73f40..9805173c0 100644 --- a/scripts/run_regression_tests.py +++ b/scripts/run_regression_tests.py @@ -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) diff --git a/src/core/gpu_dump.h b/src/core/gpu_dump.h index 3afa50aca..dfb26b5a1 100644 --- a/src/core/gpu_dump.h +++ b/src/core/gpu_dump.h @@ -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 Open(std::string path, Error* error); diff --git a/src/core/system.cpp b/src/core/system.cpp index ed2a30403..e1cc4a0cf 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -622,6 +622,11 @@ bool System::IsReplayingGPUDump() return static_cast(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); diff --git a/src/core/system.h b/src/core/system.h index 2a45403c0..50e9e31e0 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -172,6 +172,7 @@ bool IsValid(); bool IsValidOrInitializing(); bool IsExecuting(); bool IsReplayingGPUDump(); +size_t GetGPUDumpFrameCount(); bool IsStartupCancelled(); void CancelPendingStartup(); diff --git a/src/duckstation-regtest/regtest_host.cpp b/src/duckstation-regtest/regtest_host.cpp index cecc02e65..02c0feb6a 100644 --- a/src/duckstation-regtest/regtest_host.cpp +++ b/src/duckstation-regtest/regtest_host.cpp @@ -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 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(System::GetGPUDumpFrameCount()); + } + if (s_frame_dump_interval > 0) { if (s_dump_base_directory.empty())