Files
Triforce-Source/tests/test_present_aspect_vulkan.py
ruckus7382sfgsgdf 4fa4f9188b Triforce v0.8.0
Evil HD (SMAA Ultra, 16x filtering, full textures, ambient occlusion with bounce light, sunlight shafts, foliage drawn 4x as far, the remastered texture pack's loader and the launcher's download of it), FSR 3.1 frame generation for every GPU, Intel XeSS, FSR 4 model choice, ReShade presets, Auto (this PC), HUD placement, the options menu in 13 languages, a second input for every control, hold to toggle, DualSense speaker and haptics, NFC from the player's own dumps, the above-60 fps game fixes, the Debug tab's flight and Inventory fixes, the launcher's full settings, and over 250 fixes.
2026-11-25 10:21:32 -06:00

63 lines
2.6 KiB
Python

"""Optional real-Vulkan offscreen presentation regression, without game data.
Needs a Vulkan 1.3 device, loader and headers. The normal CI runner skips GPU
checks; selecting this check explicitly runs it. No window/swapchain is created.
"""
import argparse
import os
import shutil
import subprocess
import sys
import tempfile
from pathlib import Path
RUN_ALL_ARGS = ["--cxx", "{cxx}", "--headers", "{vulkan_headers}"]
# (a GPU)
RUN_ALL_SKIP = {
"linux": "needs a Vulkan 1.3 device for offscreen transfer/readback",
"windows": "needs a Vulkan 1.3 device for offscreen transfer/readback",
}
ROOT = Path(__file__).resolve().parents[1]
def function(source, marker):
start = source.index(marker)
end = source.index("{", start) + 1
depth = 1
while depth:
depth += (source[end] == "{") - (source[end] == "}")
end += 1
return source[start:end]
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--cxx", default="g++")
parser.add_argument("--headers", required=True, type=Path)
args = parser.parse_args()
source = (ROOT / "gpu/vk/vk_replay.cpp").read_text(encoding="utf-8")
begin = source.index(" const PresentAspect aspect{", source.index("void present_image("))
end = source.index(" // ((Triforce) RX_VK_FRAMELOG_WINDOW=1, with the frame log:", begin)
fixture = (ROOT / "tests/present_aspect_vulkan.cpp").read_text(encoding="utf-8")
fixture = fixture.replace("// @PRODUCTION_HELPERS@", function(source, "void image_barrier(") + "\n" +
function(source, "void blit_crop_to_rect("))
fixture = fixture.replace("// @PRODUCTION_PRESENT@", source[begin:end])
loader = [str(Path(os.environ.get("WINDIR", "C:/Windows")) / "System32/vulkan-1.dll")] if sys.platform == "win32" else ["-lvulkan"]
with tempfile.TemporaryDirectory(prefix="present-aspect-vulkan-") as tmp:
unit, exe = Path(tmp) / "fixture.cpp", Path(tmp) / "fixture.exe"
unit.write_text(fixture, encoding="utf-8")
command = [args.cxx, "-std=c++17", "-O2", "-Wall", "-Wextra", "-Werror",
"-Wno-missing-field-initializers", "-Wno-missing-braces",
"-I" + str(ROOT / "gpu/vk"), "-I" + str(args.headers), str(unit), *loader, "-o", str(exe)]
subprocess.run(command, check=True, timeout=60)
env = dict(os.environ)
compiler = shutil.which(args.cxx)
if compiler:
env["PATH"] = str(Path(compiler).parent) + os.pathsep + env.get("PATH", "")
subprocess.run([str(exe)], env=env, check=True, timeout=60)
if __name__ == "__main__":
main()