Triforce v0.5.1

Hotfix for v0.5.0: crashes (NX2navi game folder refused by Setup, heap-full retries, GTX 10 series noise pass and whole VRAM mirrors, code-patch mods kept with their code, no page file warning), graphics (DLSS with frame generation, DLSS coming back, AMD storage buffer alignment, mesh index map, shared memory barrier, shader conversions, integrated GPUs' uniform snapshot, a Mesh shaders row), controls (microphone after restart, button prompts with a mod's size table, sprint vs Hide text, native mouse camera, controller after Restart now), Setup's Preparing shaders step, and the Linux link fix.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-18 12:06:48 -06:00
parent 72793f2231
commit a750a21025
54 changed files with 1806 additions and 114 deletions

View File

@@ -480,6 +480,7 @@ def check(a, work):
bid = build_id(os.path.join(probe, "exefs", "main"))
shutil.rmtree(probe, ignore_errors=True)
else:
refuse_packed_romfs(a.romfs) # (Setup passes the romfs folder too since 11-18)
bid = build_id(os.path.join(a.exefs, "main"))
if bid.startswith(BUILD_ID):
say("check", "ok", "This is the version Triforce supports (build %s)." % bid[:8])
@@ -1157,6 +1158,19 @@ def refuse_dump_links(folder):
% (folder, path))
PACKED_ROMFS = ("This romfs folder is NX2navi's: it holds the game's data packed in one file (romfs.bin), which Triforce cannot "
"read, so the game would crash at start. Choose your game file (.nup) instead, or romfs and exefs folders with "
"the game's files unpacked in them.")
def refuse_packed_romfs(folder):
"""(Triforce, 11-18) NX2navi keeps the game's RomFS as one image, <its game folder>\\romfs\\romfs.bin (+ index.json), not as
files: chosen as the romfs folder, it passed (only the exefs is checked) and the game was built without its data. It then
crashed at start in the game's own setup, a 0x268-byte allocation coming back null (f_80c4afa0: two players, 11-18)"""
if folder and os.path.isfile(os.path.join(folder, "romfs.bin")):
fail(PACKED_ROMFS)
def long_path(p):
"""(Windows) p as an extended-length path (\\\\?\\...): a game folder whose deepest file passes 260 characters still links
and is read (#1468); Python takes these without Windows' long-paths setting. Elsewhere, or one already: as is (nup.py's)"""
@@ -1586,15 +1600,28 @@ def fetch_streamline_sdk(a):
def place_dlssg_runtime(out):
"""(NVIDIA DLSS frame generation) a game built with NVIDIA's Streamline (HOOKSHOT_STREAMLINE_SDK, as nx2/build.py takes it)
gets Streamline's DLLs, nvngx_dlssg.dll and their license texts in its dlssg folder, where gpu/vk/vk_dlssg.cpp looks. A
folder built with them before and without them now loses them. Returns the folder, or None"""
folder built with them before and without them now loses them. Returns the folder, or None
(Triforce, 11-18) DLSS's own runtime too, a copy of the one place_ngx_runtime put in ngx (so this runs after it): with
Streamline up, NGX looks for nvngx_dlss.dll only in the dlssg folder, and without it there DLSS upscaling did not start
("not available on this GPU (0xbad00004)"), so the menu offered no DLSS while frame generation was on"""
sl = streamline_script()
if sl is None:
return None
sdk = os.environ.get("HOOKSHOT_STREAMLINE_SDK", "")
dlss_copy = os.path.join(out, "dlssg", "nvngx_dlss.dll")
if LINUX or not sl.complete(sdk):
with contextlib.suppress(OSError): # (before Streamline's files: the folder is left empty and goes with them)
os.remove(dlss_copy)
sl.remove_runtime(out)
return None
dst = sl.install_runtime(sdk, out)
dlss = os.path.join(out, "ngx", "nvngx_dlss.dll")
if os.path.isfile(dlss):
copy_writable(dlss, dlss_copy)
else: # (a build without NVIDIA DLSS: no stale copy of an earlier one's)
with contextlib.suppress(OSError):
os.remove(dlss_copy)
print("NVIDIA DLSS frame generation: %s (NVIDIA's, under NVIDIA's licenses: never share this game folder)" % dst, flush=True)
return dst
@@ -1812,6 +1839,7 @@ def main(a=None):
fail("This game folder has no copy of the game files to update from: it was built before updates came in. Choose your game files "
"in Triforce Setup and build into the same folder once; updates after that work by themselves.")
check_cache_paths(out, (kept, romfs))
refuse_packed_romfs(romfs) # (a folder built from NX2navi's before the check: it never started)
shutil.copytree(kept, exefs)
check_modules(exefs)
stand_in_damaged_files(out, romfs) # (a folder unpacked by an earlier builder from a 23.3 GB dump)
@@ -1871,6 +1899,7 @@ def main(a=None):
stand_in_damaged_files(out, romfs, unpacked_seen)
else:
check_cache_paths(out, (kept, romfs))
refuse_packed_romfs(a.romfs)
refuse_dump_links(a.exefs)
refuse_dump_links(a.romfs)
shutil.copytree(a.exefs, exefs) # (unpacked in place: the user's copy stays as it is)

View File

@@ -16,6 +16,9 @@ Each is a runtime switch where it can be, so the game's own path stays reachable
before any recompute. So the fixed path kept the dynamic path's last scale (0.75 docked: 1536x864 at every setting). Flag 1 now
also asks for the recompute, and on the fixed path the flags +0xe20 bits 3/4 (a hardcoded 0.75 / 0.5 in place of the scale)
are not looked at.
- The OptimizeChangeBank thread's allocations tried again when their heap is full (host/oot_heap_retry.c): f_804566e0's two
calls of f_80522050, its GPU memory (GPU_ALLOC_SITES), and its two tryAllocs of CPU buffers (HEAP_ALLOC_SITES). They went on
with a null pointer and crashed writing through it (issue 1697). The supported build only.
"""
import glob
import os
@@ -690,6 +693,46 @@ def patch_scene_format(s):
return s.replace(RGBA16F_OLD, RGBA16F_NEW, 1).replace('#include "a64.h"\n', '#include "a64.h"\n' + RGBA16F_DECL, 1)
# (from TomShafford/Hookshot 55d68e8cd6 and 65c1998222) f_804566e0's two calls of f_80522050, the GPU memory a model's material
# block is made with, made through host/oot_heap_retry.c hos_oot_gpu_alloc, which calls the game's own and tries a full heap's
# failure again in the heap's parents. f_80522050's other callers stay as they are.
GPU_ALLOC_SITES = (0x80456f1c, 0x80457098) # (the calls' return addresses)
GPU_ALLOC_OLD = "c->x[30] = %#xULL; f_80522050(c);"
GPU_ALLOC_NEW = "c->x[30] = %#xULL; hos_oot_gpu_alloc(c, f_80522050); /* (nx2/oot_patches.py: host/oot_heap_retry.c) */"
GPU_ALLOC_DECL = "void hos_oot_gpu_alloc(Ctx *A64_NOESC c, A64Fn game);\n"
# f_804566e0's tryAllocs of the CPU buffers at its MatBlock's +200 (its bump allocator's memory) and +168, each sized for the
# model (x0 the heap, x1 the size, x2 the alignment): a null result tried in the heap's parents (hos_oot_heap_retry)
HEAP_ALLOC_SITES = (0x80456910, 0x80456da4)
HEAP_ALLOC_OLD = "{ uint64_t _t = c->x[8]; c->x[30] = %#xULL; A64_ICALL(c, _t); }\n"
HEAP_ALLOC_NEW = ("{ const uint64_t _hh = c->x[0], _hn = c->x[1], _ha = c->x[2]; /* (nx2/oot_patches.py: host/oot_heap_retry.c) */\n"
" if (hos_oot_heap_refuse()) c->x[0] = 0;\n"
" else { uint64_t _t = c->x[8]; c->x[30] = %#xULL; A64_ICALL(c, _t); }\n"
" if (!c->x[0]) hos_oot_heap_retry(c, _hh, _hn, _ha, %#xULL); }\n")
HEAP_ALLOC_DECL = "int hos_oot_heap_refuse(void);\nvoid hos_oot_heap_retry(Ctx *c, uint64_t heap, uint64_t size, uint64_t align, uint64_t lr);\n"
def patch_heap_retry(s):
"""The four places above in one file's text: (text, [GPU sites, CPU sites] made now or found made). apply() wants
[2, 2] over the whole lift and warns otherwise"""
found = [0, 0]
decls = []
for kind, sites, old, new, decl in ((0, GPU_ALLOC_SITES, GPU_ALLOC_OLD, GPU_ALLOC_NEW, GPU_ALLOC_DECL),
(1, HEAP_ALLOC_SITES, HEAP_ALLOC_OLD, HEAP_ALLOC_NEW, HEAP_ALLOC_DECL)):
for lr in sites:
o, n = old % lr, (new % lr if kind == 0 else new % (lr, lr))
if n in s:
found[kind] += 1
elif s.count(o) == 1 and s.count('#include "a64.h"\n') == 1:
s = s.replace(o, n, 1)
found[kind] += 1
if decl not in decls:
decls.append(decl)
for decl in decls:
if decl not in s:
s = s.replace('#include "a64.h"\n', '#include "a64.h"\n' + decl, 1)
return s, found
def apply(gen, *, protect_hearts=False, required=False):
"""required: the lift of the supported build (LIFE_BUILD_ID), whole: a missing output-size edit stops it (apply_output_size).
The other patches only warn when their place is not found once."""
@@ -712,6 +755,7 @@ def apply(gen, *, protect_hearts=False, required=False):
sprint_sites = 0 # (patch_sprint: its two calls)
zstd_sites = 0 # (patch_host_zstd: its two calls, the supported build's alone)
mod_size_sites = 0 # ((Triforce) patch_mod_sizes: its one call, the supported build's alone)
heap_sites = [0, 0] # (the GPU memory's sites, the CPU buffers': patch_heap_retry, the supported build only)
for path in sorted(glob.glob(os.path.join(glob.escape(gen), "code_*.c"))):
with open(path, encoding="utf-8", newline="") as f:
s = f.read()
@@ -783,6 +827,12 @@ def apply(gen, *, protect_hearts=False, required=False):
step_files.append(path)
if sites:
print("oot_patches: the frame's time at %d step divide(s) in %s" % (sites, os.path.basename(path)))
heap, found = patch_heap_retry(out) if protect_hearts else (out, [0, 0])
heap_sites[0] += found[0]
heap_sites[1] += found[1]
if heap != out:
print("oot_patches: heap-full retries of the OptimizeChangeBank allocations in", os.path.basename(path))
out = heap
out, whole = patch_whole_frames(out)
whole_sites += out.count(WHOLE_MARK) # (made now, or by an earlier run over this file)
if whole:
@@ -847,6 +897,9 @@ def apply(gen, *, protect_hearts=False, required=False):
print("oot_patches: WARNING: the resource size table's lookup was found at %d of 1 place" % mod_size_sites)
if protect_hearts and zstd_sites != len(ZSTD_SITES): # (without them HOS_HOST_ZSTD does nothing, or half: host/hos_zstd.c)
print("oot_patches: WARNING: the host's zstd decoder's calls were found at %d of %d places" % (zstd_sites, len(ZSTD_SITES)))
if protect_hearts and heap_sites != [len(GPU_ALLOC_SITES), len(HEAP_ALLOC_SITES)]: # (the supported build's functions)
print("oot_patches: WARNING: the OptimizeChangeBank allocations were found %s times, not once each: a full heap is "
"not tried again" % heap_sites)
for what, n in done.items():
if n != 1:
print("oot_patches: WARNING: the %s was found %d times" % (what, n))