Files
Triforce-Source/tests/test_present_geometry_trace.py
ruckus7382sfgsgdf 6f338c8f56 Triforce v0.5.0
In-game mods (GameBanana browser, search and installs, with the Mask Salesman), code-patch and cheat mods, the devs' test18 to test45 work (full performance overlay, frame pacing on, steady frame rate, save export and import, bug capture, new options rows, Setup's Mods page and Add to Steam), occlusion queries and new defaults, Auto resolution that scales, replay helper threads and robust buffers off by default, the options in sections.
2026-11-17 22:40:50 -06:00

48 lines
2.1 KiB
Python

"""Run production present route/geometry diagnostics and bounded per-kind state tracking without a GPU."""
import argparse
from pathlib import Path
import os
import subprocess
import tempfile
RUN_ALL_ARGS = ["--cxx", "{cxx}"]
ROOT = Path(__file__).resolve().parents[1]
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("--cxx", default="g++")
p.add_argument("--source", type=Path, default=ROOT)
a = p.parse_args()
source = (a.source / "gpu/vk/vk_replay.cpp").read_text(encoding="utf-8")
begin = source.index("void present_image(")
marker = " const PresentAspect aspect{" if " const PresentAspect aspect{" in source[begin:] else " const bool preserve_stretch ="
start = source.index(marker, begin)
end = source.index(" if (src && framelog_on())", start)
draw = source[start:end]
trace = ""
if " // Geometry trace:" in source[end:]:
start = source.index(" // Geometry trace:", end)
stop = source.index(" menu_record(", start)
# (Triforce: the device lost's marker before the menu, wp8-lost, is not the trace's)
marked = source.find(" checkpoint_mark(f.cmd, index, 'M');", start)
trace = source[start:marked if 0 <= marked < stop else stop]
fixture = (ROOT / "tests/present_geometry_trace_test.cpp").read_text(encoding="utf-8")
fixture = fixture.replace("/* ACTUAL_DRAW */", draw).replace("/* ACTUAL_TRACE */", trace)
with tempfile.TemporaryDirectory(prefix="present-geometry-trace-") as temp:
cpp, exe = Path(temp) / "fixture.cpp", Path(temp) / "fixture.exe"
cpp.write_text(fixture, encoding="utf-8")
subprocess.run([a.cxx, "-std=c++20", "-Wall", "-Wextra", "-Werror", "-I" + str(a.source / "gpu/vk"),
str(cpp), "-o", str(exe)], check=True)
for value in (None, "0", "1"):
env = os.environ.copy()
env.pop("RX_VK_PRESENT_LOG", None)
if value is not None:
env["RX_VK_PRESENT_LOG"] = value
subprocess.run([str(exe), "1" if value == "1" else "0"], env=env, check=True, timeout=30)
if __name__ == "__main__":
main()