mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-25 18:48:51 -04:00
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.
79 lines
3.6 KiB
Python
79 lines
3.6 KiB
Python
"""Authored failure injection against actual fallback buffer initialization; no Vulkan/game required."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
|
|
RUN_ALL_ARGS = ["--cxx", "{cxx}"]
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
CASES = ("initial_allocation_failure", "payload_allocation_failure", "records_address_zero",
|
|
"records_only_address_zero", "payload_address_zero", "records_only_success", "task_success",
|
|
"pool_records", "warp_counters", "warp_counters_pool", "invalid_program", "program_isolation",
|
|
# ((11-21, the performance audit's MEM-154) a payload growth keeps the thread's records buffer)
|
|
"payload_growth_keeps_records", "shared_records_payload_failure")
|
|
|
|
|
|
def block(source, signature, semicolon=False):
|
|
start = source.index(signature)
|
|
first = source.index("{", start)
|
|
depth = 1
|
|
at = first + 1
|
|
while depth:
|
|
if source[at] == "{":
|
|
depth += 1
|
|
elif source[at] == "}":
|
|
depth -= 1
|
|
at += 1
|
|
if semicolon:
|
|
assert source[at] == ";"
|
|
at += 1
|
|
return source[start:at]
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("--cxx", default=os.environ.get("CXX", "clang++"), help="GCC/Clang C++ compiler")
|
|
parser.add_argument("--source", type=Path, default=ROOT / "gpu/vk/vk_draw.cpp",
|
|
help="Public vk_draw.cpp override for an original-source negative control")
|
|
parser.add_argument("--case", action="append", choices=CASES)
|
|
args = parser.parse_args()
|
|
cxx = shutil.which(args.cxx)
|
|
if not cxx:
|
|
raise SystemExit("C++ compiler not found: " + args.cxx)
|
|
source = args.source.read_text(encoding="utf-8")
|
|
tls_start = source.index("struct TlsOwned {")
|
|
tls_macro = source.index("#define TLS_OBJECT(", tls_start)
|
|
tls_end = source.index("\n\n", tls_macro)
|
|
actual = "\n\n".join((source[tls_start:tls_end], block(source, "struct FallbackBuffers {", True),
|
|
next(line for line in source.splitlines() if line.startswith("TLS_OBJECT(fallback_buffers,")),
|
|
block(source, "uint64_t fallback_buffer_address("), block(source, "bool fallback_buffers_of(")))
|
|
flags = subprocess.CREATE_NO_WINDOW | subprocess.BELOW_NORMAL_PRIORITY_CLASS if os.name == "nt" else 0
|
|
env = dict(os.environ)
|
|
env["PATH"] = str(Path(cxx).parent) + os.pathsep + env.get("PATH", "")
|
|
with tempfile.TemporaryDirectory(prefix="hookshot-fallback-init-") as folder:
|
|
tmp = Path(folder)
|
|
(tmp / "fallback_actual.inc").write_text(actual + "\n", encoding="utf-8")
|
|
exe = tmp / ("fallback.exe" if os.name == "nt" else "fallback")
|
|
command = [cxx, "-std=c++20", "-O0", "-Wall", "-Wextra", "-Werror", "-I" + str(tmp),
|
|
str(ROOT / "tests/fallback_buffer_cleanup_test.cpp"), "-o", str(exe)]
|
|
result = subprocess.run(command, cwd=tmp, env=env, capture_output=True, text=True, timeout=60,
|
|
creationflags=flags)
|
|
if result.returncode:
|
|
print(result.stdout + result.stderr)
|
|
return result.returncode
|
|
failed = 0
|
|
for case in args.case or CASES:
|
|
result = subprocess.run([str(exe), case], cwd=tmp, env=env, capture_output=True, text=True,
|
|
timeout=10, creationflags=flags)
|
|
print((result.stdout + result.stderr).strip())
|
|
failed += result.returncode != 0
|
|
print("fallback initialization: %d cases, %d failed" % (len(args.case or CASES), failed))
|
|
return int(failed != 0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|