mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-21 09:09:58 -04:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user