First Commit
This commit is contained in:
21
pcsx2-gsrunner/CMakeLists.txt
Normal file
21
pcsx2-gsrunner/CMakeLists.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
add_executable(pcsx2-gsrunner)
|
||||
|
||||
if (PACKAGE_MODE)
|
||||
install(TARGETS pcsx2-gsrunner DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
else()
|
||||
install(TARGETS pcsx2-gsrunner DESTINATION ${CMAKE_SOURCE_DIR}/bin)
|
||||
endif()
|
||||
|
||||
target_sources(pcsx2-gsrunner PRIVATE
|
||||
Main.cpp
|
||||
)
|
||||
|
||||
target_include_directories(pcsx2-gsrunner PRIVATE
|
||||
"${CMAKE_BINARY_DIR}/common/include"
|
||||
"${CMAKE_SOURCE_DIR}/pcsx2"
|
||||
)
|
||||
|
||||
target_link_libraries(pcsx2-gsrunner PRIVATE
|
||||
PCSX2_FLAGS
|
||||
PCSX2
|
||||
)
|
||||
1087
pcsx2-gsrunner/Main.cpp
Normal file
1087
pcsx2-gsrunner/Main.cpp
Normal file
File diff suppressed because it is too large
Load Diff
97
pcsx2-gsrunner/comparer.css
Normal file
97
pcsx2-gsrunner/comparer.css
Normal file
@@ -0,0 +1,97 @@
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1;
|
||||
padding-top: 100px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
position: relative;
|
||||
margin: auto;
|
||||
padding: 0;
|
||||
width: 90%;
|
||||
max-width: 1200px;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: white;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 25px;
|
||||
font-size: 35px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.close:hover,
|
||||
.close:focus {
|
||||
color: #999;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prev,
|
||||
.next {
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: auto;
|
||||
padding: 16px;
|
||||
margin-top: -50px;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
font-size: 20px;
|
||||
transition: 0.6s ease;
|
||||
border-radius: 0 3px 3px 0;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
}
|
||||
|
||||
.next {
|
||||
right: 0;
|
||||
border-radius: 3px 0 0 3px;
|
||||
}
|
||||
|
||||
.prev:hover,
|
||||
.next:hover {
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.item img {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#compareTitle {
|
||||
color: white;
|
||||
font-size: 20px;
|
||||
font-family: sans-serif;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#compareCaption {
|
||||
color: white;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
#compareState {
|
||||
display: block;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
color: red;
|
||||
font-family: sans-serif;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#compareImage {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
111
pcsx2-gsrunner/comparer.js
Normal file
111
pcsx2-gsrunner/comparer.js
Normal file
@@ -0,0 +1,111 @@
|
||||
/* Worst script known to man */
|
||||
/* Sources:
|
||||
https://www.w3schools.com/howto/howto_js_lightbox.asp
|
||||
https://css-tricks.com/prevent-page-scrolling-when-a-modal-is-open/
|
||||
*/
|
||||
|
||||
function openModal() {
|
||||
document.body.style.position = 'fixed';
|
||||
document.body.style.top = `-${window.scrollY}px`;
|
||||
document.getElementById("myModal").style.display = "block";
|
||||
document.getElementById("myModal").focus();
|
||||
setImageIndex(0);
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
document.getElementById("myModal").style.display = "none";
|
||||
const scrollY = document.body.style.top;
|
||||
document.body.style.position = '';
|
||||
document.body.style.top = '';
|
||||
window.scrollTo(0, parseInt(scrollY || '0') * -1);
|
||||
}
|
||||
|
||||
function isModalOpen() {
|
||||
return (document.getElementById("myModal").style.display == "block");
|
||||
}
|
||||
|
||||
function formatLines(str) {
|
||||
let lines = str.split("\n")
|
||||
lines = lines.filter(line => !line.startsWith("Difference in frames"))
|
||||
return lines.join("<br>")
|
||||
}
|
||||
|
||||
function extractItem(elem) {
|
||||
return {
|
||||
name: elem.querySelector("h1").innerText,
|
||||
beforeImg: elem.querySelector(".before").getAttribute("src"),
|
||||
afterImg: elem.querySelector(".after").getAttribute("src"),
|
||||
details: formatLines(elem.querySelector("pre").innerText)
|
||||
};
|
||||
}
|
||||
|
||||
const items = [...document.querySelectorAll(".item")].map(extractItem)
|
||||
let currentImage = 0;
|
||||
let currentState = 0;
|
||||
|
||||
function getImageIndexForUri(uri) {
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (items[i].beforeImg == uri || items[i].afterImg == uri)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function setImageState(state) {
|
||||
const item = items[currentImage]
|
||||
const uri = (state === 0) ? item.beforeImg : item.afterImg;
|
||||
const stateText = (state === 0) ? "BEFORE" : "AFTER";
|
||||
const posText = "(" + (currentImage + 1).toString() + "/" + (items.length).toString() + ") ";
|
||||
document.getElementById("compareImage").setAttribute("src", uri);
|
||||
document.getElementById("compareState").innerText = stateText;
|
||||
document.getElementById("compareTitle").innerText = posText + item.name;
|
||||
document.getElementById("compareCaption").innerHTML = item.details;
|
||||
currentState = state;
|
||||
}
|
||||
|
||||
function setImageIndex(index) {
|
||||
if (index < 0 || index > items.length)
|
||||
return;
|
||||
|
||||
currentImage = index;
|
||||
setImageState(0);
|
||||
}
|
||||
|
||||
function handleKey(key) {
|
||||
if (key == " ") {
|
||||
setImageState((currentState === 0) ? 1 : 0);
|
||||
return true;
|
||||
} else if (key == "ArrowLeft") {
|
||||
setImageIndex(currentImage - 1);
|
||||
return true;
|
||||
} else if (key == "ArrowRight") {
|
||||
setImageIndex(currentImage + 1);
|
||||
return true;
|
||||
} else if (key == "Escape") {
|
||||
closeModal();
|
||||
return true;
|
||||
} else {
|
||||
console.log(key);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("myModal").addEventListener("keydown", function(ev) {
|
||||
if (ev.defaultPrevented)
|
||||
return;
|
||||
|
||||
if (handleKey(ev.key))
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
document.querySelector("#myModal .prev").addEventListener("click", function() {
|
||||
setImageIndex(currentImage - 1);
|
||||
});
|
||||
document.querySelector("#myModal .next").addEventListener("click", function() {
|
||||
setImageIndex(currentImage + 1);
|
||||
});
|
||||
document.querySelectorAll(".item img").forEach(elem => elem.addEventListener("click", function() {
|
||||
if (!isModalOpen())
|
||||
openModal();
|
||||
setImageIndex(getImageIndexForUri(this.getAttribute("src")));
|
||||
}));
|
||||
67
pcsx2-gsrunner/pcsx2-gsrunner.vcxproj
Normal file
67
pcsx2-gsrunner/pcsx2-gsrunner.vcxproj
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(SolutionDir)common\vsprops\BaseProjectConfig.props" />
|
||||
<Import Project="$(SolutionDir)common\vsprops\WinSDK.props" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{BB98BF81-A132-444A-BB81-96D510F433A8}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset Condition="!$(Configuration.Contains(Clang))">$(DefaultPlatformToolset)</PlatformToolset>
|
||||
<PlatformToolset Condition="$(Configuration.Contains(Clang))">ClangCL</PlatformToolset>
|
||||
<WholeProgramOptimization Condition="$(Configuration.Contains(Release))">true</WholeProgramOptimization>
|
||||
<UseDebugLibraries Condition="$(Configuration.Contains(Debug))">true</UseDebugLibraries>
|
||||
<UseDebugLibraries Condition="!$(Configuration.Contains(Debug))">false</UseDebugLibraries>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings" />
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(SolutionDir)common\vsprops\common.props" />
|
||||
<Import Project="$(SolutionDir)common\vsprops\BaseProperties.props" />
|
||||
<Import Project="$(SolutionDir)common\vsprops\GenerateSCMVersion.props" />
|
||||
<Import Project="$(SolutionDir)common\vsprops\LinkPCSX2Deps.props" />
|
||||
<Import Condition="'$(Platform)'=='ARM64'" Project="$(SolutionDir)common\vsprops\CopyResources.props" />
|
||||
<Import Condition="$(Configuration.Contains(Debug))" Project="$(SolutionDir)common\vsprops\CodeGen_Debug.props" />
|
||||
<Import Condition="$(Configuration.Contains(Devel))" Project="$(SolutionDir)common\vsprops\CodeGen_Devel.props" />
|
||||
<Import Condition="$(Configuration.Contains(Release))" Project="$(SolutionDir)common\vsprops\CodeGen_Release.props" />
|
||||
<Import Condition="!$(Configuration.Contains(Release))" Project="$(SolutionDir)common\vsprops\IncrementalLinking.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<TargetName>$(EXEString)</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)3rdparty\fmt\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)3rdparty\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)3rdparty\imgui\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)3rdparty\fast_float\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)3rdparty\simpleini\include</AdditionalIncludeDirectories>
|
||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)pcsx2</AdditionalIncludeDirectories>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;LZMA_API_STATIC;ENABLE_RAINTEGRATION;ENABLE_ACHIEVEMENTS;ENABLE_DISCORD_PRESENCE;ENABLE_OPENGL;ENABLE_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(SolutionDir)3rdparty\imgui\imgui.vcxproj">
|
||||
<Project>{88fb34ec-845e-4f21-a552-f1573b9ed167}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(SolutionDir)common\common.vcxproj">
|
||||
<Project>{4639972e-424e-4e13-8b07-ca403c481346}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(SolutionDir)pcsx2\pcsx2.vcxproj">
|
||||
<Project>{6c7986c4-3e4d-4dcc-b3c6-6bb12b238995}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
6
pcsx2-gsrunner/pcsx2-gsrunner.vcxproj.filters
Normal file
6
pcsx2-gsrunner/pcsx2-gsrunner.vcxproj.filters
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
197
pcsx2-gsrunner/test_check_dumps.py
Normal file
197
pcsx2-gsrunner/test_check_dumps.py
Normal file
@@ -0,0 +1,197 @@
|
||||
import argparse
|
||||
import glob
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import hashlib
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
MAX_DIFF_FRAMES = 9999
|
||||
|
||||
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__))
|
||||
CSS_PATH = Path(os.path.join(SCRIPTDIR, "comparer.css")).as_uri()
|
||||
JS_PATH = Path(os.path.join(SCRIPTDIR, "comparer.js")).as_uri()
|
||||
|
||||
FILE_HEADER = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Comparison</title>
|
||||
""" + f"<link rel=\"stylesheet\" href=\"{CSS_PATH}\" />" + """
|
||||
</head>
|
||||
<body>
|
||||
"""
|
||||
|
||||
FILE_FOOTER = """
|
||||
<div id="myModal" class="modal" tabindex="0">
|
||||
<span class="close cursor" onclick="closeModal()">×</span>
|
||||
<div class="modal-content">
|
||||
<div id="compareTitle"></div>
|
||||
<img id="compareImage" />
|
||||
<div id="compareState"></div>
|
||||
<a class="prev">❮</a>
|
||||
<a class="next">❯</a>
|
||||
<div id="compareCaption"></div>
|
||||
</div>
|
||||
</div>
|
||||
""" + f"<script src=\"{JS_PATH}\"></script>\n" + """
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
outfile = None
|
||||
def write(line):
|
||||
outfile.write(line + "\n")
|
||||
|
||||
|
||||
def compare_frames(path1, path2):
|
||||
try:
|
||||
with open(path1, "rb") as f:
|
||||
hash1 = hashlib.md5(f.read()).digest()
|
||||
with open(path2, "rb") as f:
|
||||
hash2 = hashlib.md5(f.read()).digest()
|
||||
|
||||
return hash1 == hash2
|
||||
except (FileNotFoundError, IOError):
|
||||
return False
|
||||
|
||||
|
||||
def extract_stats(file):
|
||||
stats = {}
|
||||
try:
|
||||
with open(file, "r", errors="ignore") as f:
|
||||
for line in f.readlines():
|
||||
m = re.match(".*@HWSTAT@ ([^:]+): (.*) \(avg ([^)]+)\)$", line)
|
||||
if m is None:
|
||||
continue
|
||||
stats[m[1]] = int(m[3])
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except IOError:
|
||||
pass
|
||||
return stats
|
||||
|
||||
|
||||
def compare_stats(baselinedir, testdir):
|
||||
stats1 = extract_stats(os.path.join(baselinedir, "emulog.txt"))
|
||||
stats2 = extract_stats(os.path.join(testdir, "emulog.txt"))
|
||||
res = []
|
||||
for statname in stats1.keys():
|
||||
if statname not in stats2 or stats1[statname] == stats2[statname]:
|
||||
continue
|
||||
v2 = stats2[statname]
|
||||
v1 = stats1[statname]
|
||||
delta = v2 - v1
|
||||
res.append("%s: %s%d [%d=>%d]" % (statname, "+" if delta > 0 else "", delta, v1, v2))
|
||||
return res
|
||||
|
||||
|
||||
def check_regression_test(baselinedir, testdir, name):
|
||||
#print("Checking '%s'..." % name)
|
||||
|
||||
dir1 = os.path.join(baselinedir, name)
|
||||
dir2 = os.path.join(testdir, name)
|
||||
if not os.path.isdir(dir2):
|
||||
#print("*** %s is missing in test set" % name)
|
||||
return False
|
||||
|
||||
images = glob.glob(os.path.join(glob.escape(dir1), "*_frame*.png"))
|
||||
diff_frames = []
|
||||
first_fail = True
|
||||
stats = compare_stats(dir1, dir2)
|
||||
|
||||
for imagepath in images:
|
||||
imagename = Path(imagepath).name
|
||||
matches = re.match(".*_frame([0-9]+).png", imagename)
|
||||
if matches is None:
|
||||
continue
|
||||
|
||||
framenum = int(matches[1])
|
||||
|
||||
path1 = os.path.join(dir1, imagename)
|
||||
path2 = os.path.join(dir2, imagename)
|
||||
if not os.path.isfile(path2):
|
||||
print("--- Frame %u for %s is missing in test set" % (framenum, name))
|
||||
if first_fail:
|
||||
write("<h1>{}</h1>".format(name))
|
||||
|
||||
if first_fail == False:
|
||||
write("</table>")
|
||||
write("<pre>--- Frame %u for %s is missing in test set</pre>" % (framenum, name))
|
||||
write("</div>")
|
||||
else:
|
||||
write("<pre>--- Frame %u for %s is missing in test set</pre>" % (framenum, name))
|
||||
return False
|
||||
|
||||
if not compare_frames(path1, path2):
|
||||
diff_frames.append(framenum)
|
||||
|
||||
if first_fail:
|
||||
write("<div class=\"item\">")
|
||||
write("<h1>{}</h1>".format(name))
|
||||
write("<table width=\"100%\">")
|
||||
first_fail = False
|
||||
|
||||
imguri1 = Path(path1).as_uri()
|
||||
imguri2 = Path(path2).as_uri()
|
||||
write("<tr><td colspan=\"2\">Frame %d</td></tr>" % (framenum))
|
||||
write("<tr><td><img class=\"before\" src=\"%s\" /></td><td><img class=\"after\" src=\"%s\" /></td></tr>" % (imguri1, imguri2))
|
||||
|
||||
if len(diff_frames) == MAX_DIFF_FRAMES:
|
||||
break
|
||||
|
||||
if len(diff_frames) > 0:
|
||||
write("</table>")
|
||||
write("<pre>Difference in frames [%s] for %s%s%s</pre>" % (",".join(map(str, diff_frames)), name, "\n" if len(stats) > 0 else "", "\n".join(stats)))
|
||||
write("</div>")
|
||||
print("*** Difference in frames [%s] for %s" % (",".join(map(str, diff_frames)), name))
|
||||
if len(stats) > 0:
|
||||
print(stats)
|
||||
elif len(stats) > 0:
|
||||
write("<h1>{}</h1>".format(name))
|
||||
write("<pre>%s</pre>" % "\n".join(stats))
|
||||
print(name, stats)
|
||||
|
||||
return len(diff_frames) == 0
|
||||
|
||||
|
||||
def check_regression_tests(baselinedir, testdir):
|
||||
gamedirs = glob.glob(baselinedir + "/*", recursive=False)
|
||||
|
||||
success = 0
|
||||
failure = 0
|
||||
|
||||
for gamedir in gamedirs:
|
||||
name = Path(gamedir).name
|
||||
if check_regression_test(baselinedir, testdir, name):
|
||||
success += 1
|
||||
else:
|
||||
failure += 1
|
||||
|
||||
print("%d dumps unchanged" % success)
|
||||
print("%d dumps changed" % failure)
|
||||
return (failure == 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Check frame dump images for regression tests")
|
||||
parser.add_argument("-baselinedir", action="store", required=True, help="Directory containing baseline frames to check against")
|
||||
parser.add_argument("-testdir", action="store", required=True, help="Directory containing frames to check")
|
||||
parser.add_argument("-maxframes", type=int, action="store", required=False, default=9999, help="Max frames to compare")
|
||||
parser.add_argument("outfile", action="store", help="The file to write the output to")
|
||||
|
||||
args = parser.parse_args()
|
||||
MAX_DIFF_FRAMES = args.maxframes
|
||||
|
||||
outfile = open(args.outfile, "w")
|
||||
write(FILE_HEADER)
|
||||
|
||||
if not check_regression_tests(os.path.realpath(args.baselinedir), os.path.realpath(args.testdir)):
|
||||
write(FILE_FOOTER)
|
||||
outfile.close()
|
||||
sys.exit(1)
|
||||
else:
|
||||
outfile.close()
|
||||
os.remove(args.outfile)
|
||||
sys.exit(0)
|
||||
106
pcsx2-gsrunner/test_run_dumps.py
Normal file
106
pcsx2-gsrunner/test_run_dumps.py
Normal file
@@ -0,0 +1,106 @@
|
||||
import argparse
|
||||
import glob
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import multiprocessing
|
||||
from pathlib import Path
|
||||
from functools import partial
|
||||
|
||||
def get_gs_name(path):
|
||||
lpath = path.lower()
|
||||
|
||||
for extension in [".gs", ".gs.xz", ".gs.zst"]:
|
||||
if lpath.endswith(extension):
|
||||
return os.path.basename(path)[:-len(extension)]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def run_regression_test(runner, dumpdir, renderer, upscale, renderhacks, parallel, gspath):
|
||||
args = [runner]
|
||||
gsname = get_gs_name(gspath)
|
||||
|
||||
real_dumpdir = os.path.join(dumpdir, gsname).strip()
|
||||
if not os.path.exists(real_dumpdir):
|
||||
os.mkdir(real_dumpdir)
|
||||
else:
|
||||
return
|
||||
|
||||
if renderer is not None:
|
||||
args.extend(["-renderer", renderer])
|
||||
|
||||
if upscale != 1.0:
|
||||
args.extend(["-upscale", str(upscale)])
|
||||
|
||||
if renderhacks is not None:
|
||||
args.extend(["-renderhacks", renderhacks])
|
||||
|
||||
args.extend(["-dumpdir", real_dumpdir])
|
||||
args.extend(["-logfile", os.path.join(real_dumpdir, "emulog.txt")])
|
||||
|
||||
# loop a couple of times for those stubborn merge/interlace dumps that don't render anything
|
||||
# the first time around
|
||||
args.extend(["-loop", "2"])
|
||||
|
||||
# disable shader cache for parallel runs, otherwise it'll have sharing violations
|
||||
if parallel > 1:
|
||||
args.append("-noshadercache")
|
||||
|
||||
# run surfaceless, we don't want tons of windows popping up
|
||||
args.append("-surfaceless");
|
||||
|
||||
# disable output console entirely
|
||||
environ = os.environ.copy()
|
||||
environ["PCSX2_NOCONSOLE"] = "1"
|
||||
|
||||
args.append("--")
|
||||
args.append(gspath)
|
||||
|
||||
#print("Running '%s'" % (" ".join(args)))
|
||||
subprocess.run(args, env=environ, stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
|
||||
|
||||
|
||||
def run_regression_tests(runner, gsdir, dumpdir, renderer, upscale, renderhacks, parallel=1):
|
||||
paths = glob.glob(gsdir + "/*.*", recursive=True)
|
||||
gamepaths = list(filter(lambda x: get_gs_name(x) is not None, paths))
|
||||
|
||||
if not os.path.isdir(dumpdir):
|
||||
os.mkdir(dumpdir)
|
||||
|
||||
print("Found %u GS dumps" % len(gamepaths))
|
||||
|
||||
if parallel <= 1:
|
||||
for game in gamepaths:
|
||||
run_regression_test(runner, dumpdir, renderer, upscale, renderhacks, parallel, game)
|
||||
else:
|
||||
print("Processing %u games on %u processors" % (len(gamepaths), parallel))
|
||||
func = partial(run_regression_test, runner, dumpdir, renderer, upscale, renderhacks, parallel)
|
||||
pool = multiprocessing.Pool(parallel)
|
||||
completed = 0
|
||||
for _ in pool.imap_unordered(func, gamepaths, chunksize=1):
|
||||
completed += 1
|
||||
print("Processed %u of %u GS dumps (%u%%)" % (completed, len(gamepaths), (completed * 100) // len(gamepaths)))
|
||||
pool.close()
|
||||
|
||||
|
||||
return True
|
||||
|
||||
|
||||
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 PCSX2 GS runner")
|
||||
parser.add_argument("-gsdir", action="store", required=True, help="Directory containing GS dumps")
|
||||
parser.add_argument("-dumpdir", action="store", required=True, help="Base directory to dump frames to")
|
||||
parser.add_argument("-renderer", action="store", required=False, help="Renderer to use")
|
||||
parser.add_argument("-upscale", action="store", type=float, default=1, help="Upscaling multiplier to use")
|
||||
parser.add_argument("-renderhacks", action="store", required=False, help="Enable HW Rendering hacks")
|
||||
parser.add_argument("-parallel", action="store", type=int, default=1, help="Number of proceeses to run")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not run_regression_tests(args.runner, os.path.realpath(args.gsdir), os.path.realpath(args.dumpdir), args.renderer, args.upscale, args.renderhacks, args.parallel):
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
||||
Reference in New Issue
Block a user