WIP: perf(host): a model's box and the transform history's rotation step on host code, bit for bit (HOS_NATIVE_BOUNDS, on by default) #1899
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1899
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:perf/native-bounds"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two routines of the game's model bounds run on host code with the game's exact results, behind a new switch, on by default (
HOS_NATIVE_BOUNDS=0gives the lifted code):Most of both runs on the executors and the module workers. A third piece, the sphere merge f_800a8000, is exact offline and in this branch's host code, but it is not spliced in: against main's form it did not beat its cost with the switch off (
BOUNDS_SPHERE_SPLICE = False).The goal is less CPU work for the same frames. A call the host cannot prove exact runs the lifted routine, with nothing written.
The model box answers a call whole or not at all. It declines when:
A done call writes the six words once, marks the page (
HOS_WRITTEN), sets NZCV as the game does and leaves x0 as the game does.The rotation step answers when every binary64 operation passes FPX1, or when an exact-zero fused multiply-add is proven by magnitudes (each operand zero or at least 2^-480). It needs a hardware FMA. It writes every register the stretch writes (d0-d17 and d24-d27 with their upper halves cleared, s11 / s15, x8-x10), the last FCMP's NZCV and the three stack stores.
How:
nx2/oot_patches.py(the supported build only) splices the hooks in:if (hos_bounds_80ba37a0(c, f_80ba37a0)) return;first in f_80ba37a0;L_800232c0that jumps to either end, plus exit hooks at both ends for check mode.f_80ba37a0 and f_800a8000 are declared at file scope, because
nx2/split_giants.pymay put a hook in a piece written beforef_<addr>. The hooks' declarations takeA64_NOESC, as the lifted code's own calls do. Guest addresses are checked against the whole 39-bit guest window (hos_guest_range,HOS_SPACE_END). The first version required addresses below 4 GB, and in the game it declined every call; see Testing.Read first:
host/oot_bounds.c: the switch, the counters, check mode.host/bounds_kernels.c: the model box. Its header describes the game's routine.host/bounds_rot.c: the rotation step.nx2/oot_patches.py:patch_bounds_native,patch_bounds_rot,BOUNDS_SPHERE_SPLICE.tests/test_bounds_kernels.py,tests/test_oot_bounds.py.gpu/vk/switches.def.Testing
Tested: Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X. This code ran in the game in test trees on main
068fb8ebthat merge nine rewrite branches, as follows.HOS_NATIVE_BOUNDS=check, the Market and Hyrule Field, about five minutes): the hooks answered nothing.a64.h's 32-bit guest pointer for the game's. The game's build widens it to a 39-bit window, with the heap at 64 GB and the thread stacks near 2^39.142cc160here (69c7351d on the session's branch).tests/test_oot_bounds.pynow runs its fixture with the guest window at 0, at 64 GB and just below 2^39, and fails on any address decline there. The old code fails it.test/rewrites@ e614ef49, in the CPU measurement below, every other rewrite on; all 15 runs held 60 fps):Exactness offline. Unicorn runs the game's own routine on the executable, and a driver runs the real host files.
Game-free checks at this head:
tests/test_bounds_kernels.pyandtests/test_oot_bounds.pypass. They cover:tests/test_switch_table.py,tests/test_patch_hooks_defined.py,test_log_levels,test_utf8_paths,test_doc_anchors,test_check_third_partyandtest_env_onpass.nx2/oot_patches.pyornx2/entry_hooks.pypass. The other five fail here and on maina104182balike:test_dev_packs,test_high_fps_fixes,test_libc_hooks,test_lift_cache,test_song_note_cue.tests/run_all.pywas not run.Still to test:
HOS_NATIVE_BOUNDS=checkin the Market and Hyrule Field. Expectoot: bounds (HOS_NATIVE_BOUNDS=check)lines with calls taken natively andMISMATCHES 0, and nooot: bounds: MISMATCHline. Then=1: no model missing, popping or wrongly lit at the screen's edges (by hand).HOS_NATIVE_BOUNDS=0against unset (on), and main against this branch with the switch unset. Measure the game's CPU seconds with the frame rate capped at 60, standing and turning, and the frame times uncapped. Expect less CPU time with the switch on, the same frame rate or better, no cost with it=0, and the picture as without it (@Beanstalk linux, amd).Measurements
Verdict: less CPU work, measured together with the other rewrite branches, not yet alone. In a test tree that merges nine rewrite branches (named in the baseline below; the cloth and particle effect rewrites and some later pieces are not among them), at a 60 fps cap in the Market:
How much of that is this branch is not separated. The Test Farm request asks for this branch's own number.
Baseline: main
068fb8eb(#1802) against the test treetest/rewrites@ e614ef49. That tree is main068fb8ebwith nine rewrite branches merged (not every rewrite there is: the cloth and particle effect branches were not in it): the seven maths units, the maths library, animation, this branch at 6171f3d6 (before theA64_NOESCdeclarations), crowd, visibility, glue, the effect triggers with the reverb, and the solver. It was lifted withA64_FPXKEEP=0, so that the lift is main's apart from the hooks. It is not this PR alone: the run-time switches were all on together. Main has moved since068fb8eb; this branch was not measured on current main.Setup: Windows 11, Ryzen 9 5900X, RTX 3090, 3840x2160; the child Market, hands-free; frame rate capped at 60 (all 15 runs held 60). Each run: 30 s standing, then 30 s turning the camera. Five variants, interleaved over three rounds, the PC otherwise idle. The figure: CPU seconds per second of play (cores busy on average) of the whole process, from the processor's cycle counter; the median of three runs (the three in brackets).
068fb8ebThe off figures are inside the runs' spread. The process includes the renderer's threads (about 1.4 cores standing), which the rewrites do not touch. With the nine on: the executors -4.1 % / -4.0 %; the module workers, where the rotation step runs, 0.847 to 0.844 cores standing and 0.884 to 0.875 turning (they also run other rewrites' routines).
Offline: CPU time a call, not the game. Ryzen 9 5900X, best of 7. Main's form is the lift with registers as C locals that main writes, approximated from the stock lift by the translator kit's
localizepass (not main's lifter). A spliced function is written in the older context form, and "switch off" is that form plus the hook. The switch-off column was measured before the declarations tookA64_NOESC.The sphere merge was 0.88x (copy path) and 1.3x (merge path) against main's form, so it stays unspliced.
The rotation splice puts the whole of f_80021ca0 into the old form. Its other 77 % (pointer chasing and logic) is where main's locals help most, and that is not measurable offline. If main's locals save more than about 21 % of that remainder, the splice loses. The game measurement above found no off cost at the process's scale, but only this branch's own farm number settles it.
The switch
HOS_NATIVE_BOUNDS(new, run time,kill, on by default):0off (the lifted routines, main's results); unset or1on (host code where it is exact, the rest lifted).checkruns both on every call. The game keeps the lifted result. The first difference logsoot: bounds: MISMATCH (the first) in ....Every 10 s a line counts the calls:
In check mode the line adds
compared N, MISMATCHES 0. The row ingpu/vk/switches.defstill names the sphere merge, whose host code is here unspliced. It ships on: docs/dev/standards.md has a switch ship at its value from the first push, never off because it is new, and the measurement with the rewrite branches together says on.HOS_NATIVE_BOUNDS=0gives main's lifted code. This PR's own measurement (the farm request) can still turn it off before it leaves WIP.Risks
What could break: a wrong model box would show as a model culled while on screen, or drawn and lit with the wrong bounds. A wrong rotation step would feed the transform history a wrong angle. In the game nothing has been compared since the fix. The check run in Still to test is the next step.
Open: in the CPU measurement, the renderer's
mkw_vk capture copythread used 10 to 18 % more CPU (0.009 to 0.017 cores), in both variants with the rewrites on and in neither without. That thread copies guest memory the game marked as written, and the native kernels mark what they write (HOS_WRITTEN; here the model box's output page). Which rewrite causes it is not determined; this branch is one of several candidates.Turning it off:
HOS_NATIVE_BOUNDS=0.After updating: the game is translated again once (
nx2/oot_patches.pyis in the lift's key). The routines run on the host by default, with the game's exact results; saves,longshot_options.iniand the caches do not change.Checklist
Ready for review
main; the title is a Conventional Commit.068fb8ebafter the fix; check mode not since the fix; this head is not built or played.)mise run testpasses (any failure that also fails onmainis named). (The tests that read the changed files pass, apart from five that fail on maina104182btoo; the whole suite not run.)main, or Measurements says why there is nothing to measure. (Measured with the other rewrite branches merged; this branch alone not yet.)third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def. (The row is there; on by default,=0gives main's lifted code; this PR's own measurement can still turn it off.)tests/that reads changed source is updated, not weakened. (tests/test_bounds_kernels.pyandtests/test_oot_bounds.py, new; they find functions by their head lines.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
The lifted functions' own context parameter is A64_NOESC; the bounds hooks were declared `extern int hos_bounds_<x>(Ctx *c, ...)`, so the compiler had to take the context for escaped at the hook's call, in the hooked function's code whether the switch is on or not. hos_bounds_80ba37a0, hos_bounds_800a8000 (declared, not spliced), hos_bounds_80021ca0_rot and hos_bounds_80021ca0_rot_exit now take `Ctx *A64_NOESC c`, as the lifted code's own calls do. The functions the hooks pass (f_80ba37a0, f_800a8000) were already declared at file scope. tests/test_oot_bounds.py finds the other functions by their head line `void f_<addr>(Ctx *__restrict A64_NOESC c) {`, not their first mention. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Ran in the game in merged test trees of the rewrite branches on main
068fb8eb(Windows, RTX 3090): the first check run found its hooks declining every call for their address (fixed for the 39-bit guest window), and after the fix, switched on in a 15-run CPU measurement at a 60 fps cap (every run held 60), the model box answered 191,487 of 191,488 calls and the rotation step 667,648 of 667,648; check mode has not been run since the fix, and this head itself is not built or played.@Beanstalk linux, and amd: this branch with HOS_NATIVE_BOUNDS unset against HOS_NATIVE_BOUNDS=1 (the same build), and main against this branch with the switch unset, each in the child Market for a few minutes and in Hyrule Field by day for a few minutes. Measure the game's CPU seconds with the frame rate capped at 60 (on a PC that holds 60 there), standing and turning the camera, and the frame times uncapped. Expect less CPU time with the switch at 1, the same frame rate or better, no extra CPU time with the switch unset against main, the picture as without the switch (no model missing or popping at the screen's edges), an "oot: bounds (HOS_NATIVE_BOUNDS=1)" line in the log with calls taken natively, and no "MISMATCH" in the log.
@snaildev99 only members of
BigBeanscan start the farm.One of them can approve this request by reacting 👍 to it or to this comment.This request was for2e7be22, and the PR has changed since (ba1907e), so a 👍 no longer approves it. Comment@Beanstalkagain to ask for the new commit.Recommendation: Request changes. The non-FMA fallback can read uninitialized values, and the rotation splice may impose a cost even at the default setting that has not been isolated. The branch also carries an unspliced sphere implementation and a test that fails on machines without hardware FMA.
The change attempts to reduce CPU work in model bounds and transform history while preserving lifted results. Offline comparisons are encouraging, but the in-game gain for this branch is unproven, and the default-off hooks still change the lifted code. Fix the fallback and test portability, remove the unused sphere path, and measure the branch independently before choosing its default.
Does it help: Unproven. The reported three-run Market medians show 2.7% less whole-process CPU standing and 2.4% less turning with all rewrite branches enabled together, against an older main; they do not isolate this PR. The switch-off differences of -0.3% and -0.2% are within the reported spread. No branch-only average FPS, 1% lows or frame times are supplied.
Other systems: The hooks affect the lifted functions even with the switch unset, including the rest of f_80021ca0 where register localization is lost. Windows NVIDIA was exercised in a merged test tree, but this head has not been played or checked in-game after the address fix. Linux, AMD and Steam Deck behavior, frame pacing, build time and the reported increase in renderer capture-copy CPU remain unverified. The rotation kernel declines without hardware FMA.
Switches: HOS_NATIVE_BOUNDS is new and defaults to off; 1 attempts the native paths and check compares them with the lifted paths. The default has not been chosen from isolated platform measurements, contrary to the switch standard. Its table row also claims the sphere merge runs natively, although that splice is disabled.
Reviewed:
2e7be224ecagainsta104182b40: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, commit log, the splice diff and substantial portions of the changed host code and tests. The combined file output was truncated, so portions of the rotation kernel, sphere kernel and tests were only skimmed; the unchanged portions of nx2/oot_patches.py and dependent code were searched selectively. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Network access was unavailable, so overlapping PRs could not be checked.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Suggestions (the author may take or leave)
Testing: No commands from the project were run, and no files were changed. The PR reports game-free checks and offline comparisons, but the full suite and this head's in-game check remain outstanding.
Overlaps and merge order: Unknown; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), on the pull request's opening. Nothing was run; a maintainer decides.
@ -0,0 +102,4 @@const double s = (double)a * (double)b + (double)z;uint64_t d;memcpy(&d, &s, 8);if ((d & UINT64_C(0x1fffffff)) == UINT64_C(0x10000000)) return 0; /* (a64_suyu.h RECOMP_FPX_MIDPOINT) */On a non-FMA build this returns without writing
*r, but both callers read that value before declining the box. Please initialize the output or return immediately from the callers, and test a midpoint on the non-FMA path.@ -799,0 +839,4 @@# HOS_NATIVE_BOUNDS: the transform history's rotation step, a hook at the label L_800232c0 of f_80021ca0 (it answers# by jumping to L_80023870 or L_80023890) and one after each of those two labels (check mode compares there)BOUNDS_ROT_HEAD = "void f_80021ca0(Ctx *__restrict A64_NOESC c) {\n"BOUNDS_ROT = (("L_800232c0", " { const int _h = hos_bounds_80021ca0_rot(c); if (_h == 1) goto L_80023870; if (_h == 2) goto L_80023890; }"),This splice also changes the rest of the function when the switch is off by preventing register localization. The combined runs do not isolate that possible cost; please measure this branch alone against its base and preserve the localized path or remove the splice if it regresses.
@ -799,0 +829,4 @@# HOS_NATIVE_BOUNDS: the sphere merge f_800a8000, a hook first in the lifted function. NOT spliced (BOUNDS_SPHERE_SPLICE):# measured offline against main's locals form it lost on its copy path (45.6 against 40.2 ns a call) and won 1.3x on# its merge path, for 0.04 % of game code; a piece that does not beat main's form stays unwired (the rewrite brief).BOUNDS_SPHERE_SPLICE = FalseWith this permanently false, the sphere kernel, hook, counters and tests have no runtime benefit, while the switch row says the sphere runs natively. Please remove the unused path and correct the row until it has a measured benefit.
@ -0,0 +342,4 @@static void test_rot_on(void) {rot_consts(), rot_expect();Ctx c = rot_ctx();CHECK(hos_bounds_80021ca0_rot(&c) == 1);Without hardware FMA the rotation kernel intentionally declines every call, so this assertion fails on that supported configuration. Please assert the fallback there and keep the native assertions for FMA builds.
WIP: perf(host): a model's box and the transform history's rotation step on host code, bit for bit (HOS_NATIVE_BOUNDS, off by default)to WIP: perf(host): a model's box and the transform history's rotation step on host code, bit for bit (HOS_NATIVE_BOUNDS, on by default)HOS_NATIVE_BOUNDSis now on by default (75e49610), as docs/dev/standards.md asks: a switch ships at its value from the first push, not off because it is new.HOS_NATIVE_BOUNDS=0gives main's lifted code. The row's kind iskill, unset reads as on (env_on_or), and the test runs it unset and=1(on),=0and=off(off) andcheck; it fails when the old read is put back. Title and description updated to match.Recommendation: Request changes. The host code is the game's routines transcribed from its disassembly (most plainly
host/bounds_rot.c, which follows the game's instructions one at a time, keeps the game's register numbers and labels each branch block with its address). CONTRIBUTING.md's Licensing section forbids that whatever the speed gain. Separately, this branch's own gain isn't measured yet, and the hook costs f_80021ca0 its register locals even with the switch at 0.The PR moves two hot routines of the game's model bounds onto host code (the model box f_80ba37a0, and the rotation step inside f_80021ca0), aiming for less CPU time per frame with the same picture. The offline speedups are large (7-10x for the box, 2.5-5x for the rotation step), and the exactness work is careful: a gate, the FPX1 rule in every lane, aliasing and range declines, and a check mode. It can't merge in this form because of how the code was written.
Does it help: Unproven. The only in-game numbers come from a merged tree of nine rewrite branches on an old main (
068fb8eb): -2.7 % / -2.4 % whole-process CPU in the Market at a 60 fps cap, as medians of 3 runs. They don't isolate this PR. The "every switch off" column (-0.3 % / -0.2 %) is inside the spread. No branch-only frame times or 1 % lows are given. Check mode hasn't run in the game since the 39-bit address fix, and this head hasn't been built or played.Other systems: Patched functions keep the context instead of locals (
nx2/guest_locals.py,touches()/keep_mentioned()). So f_80ba37a0 and the whole of f_80021ca0 lose the locals for every player, with the switch on or off. The PR says the other 77 % of f_80021ca0 is where locals help most and that the splice loses if they save more than ~21 % there. That cost is not measured. A CPU below x86-64-v3 gets an x86-64-v2 / x86-64 build (nx2/build.pyMARCH). There the rotation step declines every call (no FMA) but still pays the de-localised function. The model box takes the binary64 path and declines at midpoints.nx2/build.pynow compiles every host file with-DA64_MARK_BITMAP. Today that changes onlyA64_MARKin host code (rtgen.py:64), which only these hooks use, so nothing else moves. Linux, AMD and the Steam Deck weren't run. The renderer's capture-copy thread rose 10-18 % in the merged runs, and the cause is still open.Switches:
HOS_NATIVE_BOUNDSis new, kindkill, default on (unset or 1;=0lifted;check). On is the right default only once the gain is this PR's own and exactness has been checked in the game. Neither holds yet: the gain is Unproven and check mode hasn't run since the fix. The row (switches.def:107) still says the sphere merge f_800a8000 runs on host code, but it is not spliced. The row also has a stray " ," after "bones)".Reviewed:
75e496103againsta104182b(its fork point), and the same 11 commits rebased onto main@originb62932a96(local 40670c2c; see below). Read in full:host/oot_bounds.c,host/bounds_kernels.c/.h,host/bounds_rot.c,host/bounds_sphere.c, thenx2/oot_patches.pyandnx2/build.pydiffs, andnx2/guest_locals.py's touches / keep_mentioned / check_patched. Skimmed: the C fixtures oftests/test_oot_bounds.pyandtests/test_bounds_kernels.py, andtests/test_mark_bitmap_host.py. Nothing was run (this is a code review).Fixed in this review: I rebased the 11 commits onto main
b62932a96one by one. The conflicts were only theHOS_NATIVE_ZSTDrow main changed beside the new row, and main's " The supported build only." on the line before the new docstring bullet. I also added one commit,fix(host): the model box's no-FMA multiply-add writes its result on a decline too(see Blocking 4). The push to the head branch was refused, so neither landed. The PR still conflicts with main. The fix is given below as a suggestion.Checked and fine:
touches(), so the patched functions keep the context the hooks read.check_patchedwould stop a lift that gave one locals.sp+0xe8, 0x24 bytes).bounds_inside/sphere_insideguards stop a check-mode call from recursing.guest_locals.HEAD).env_on_or.Blocking (to change before merge)
host/bounds_rot.cis an instruction-by-instruction transcription of 0x800232c0..0x80023890 and its branch blocks:d3 = r_fma(&r, d1, d6, d2), thend1 = ...(d0, d6, d2),d0 = ...(d5, d6, d2));/* 80024bdc */, :171(8002337c), :213qB (80023380), :30880023720);tbnz w9, :424ldr s11, [sp, #0xe8]);x8 = 0x3ba3d70a, x9 = 0x3cf5c28f, x10).host/bounds_sphere.candhost/bounds_kernels.care written more as behaviour, but are also "read from the game's code" (their headers say so). They carry its instructions in comments (bounds_kernels.c:292ldr x0, [x9, x1, lsl #3], :326add x0, sp, #0x180 before the BL, :392b.le; bounds_sphere.cfcsel mi,fcmp s0, s0). They also rebuild the game's leftover register file (x0, v0-v5, x8-x10, NZCV) from it.nx2/oot_patches.py:833-835:BOUNDS_SPHERE_HEAD/BOUNDS_SPHERE_DECLcontainvoid f_800a8000, whichmentioned_addresses()matches. Sokeep_mentionedtakes f_800a8000's locals away on every build, althoughBOUNDS_SPHERE_SPLICE = Falseand the PR found the sphere loses against main's form. Unspliced code costs a hot function its locals and gains nothing. As BeanBot asked, remove the sphere path (the kernel, the hook, its counters, the row text and the tests), or at least keep its address out of this file until it is spliced.nx2/oot_patches.py:841(the rotation splice): it takes f_80021ca0's locals for everyone, including atHOS_NATIVE_BOUNDS=0and on CPUs without FMA, where it can never answer. The PR's own estimate says this can cost more than it saves. Measure this branch alone on current main: switch unset,=0, and main, each as CPU time plus frame times. Drop the rotation splice if the=0column or main-vs-on shows a cost. (BeanBot's point, still open.)host/bounds_kernels.c:105: on a no-FMA build,fma1returns 0 at a midpoint without writing*r, and both callers readrbefore they checkok. Suggested fix (the commit I couldn't push): (BeanBot's point, still open at this head.)tests/test_oot_bounds.py:346: the fixture is built with-march=nativewhen it can be, and requires the rotation hook to answer. On a CPU without FMA, which gets an x86-64-v2 game build, the kernel declines by design, so the test fails.test_bounds_kernels.pyalready has the#if !(defined(__FMA__) ...)branch; do the same here. (BeanBot's point, still open.)gpu/vk/switches.def:107: the row says the sphere merge runs on host code; it doesn't. Also remove the stray " ," after "bones)".Suggestions
rot_pending.onis cleared only at an exit hook. If the lifted stretch ever left by another path, the next arrival at an exit would compare against stale state and log a false MISMATCH. Clearing it at the entry hook would close that.Testing: The PR reports offline Unicorn comparisons, but those run the game's routine from the executable on this author's PC. In-game, it ran only in a merged tree on Windows / RTX 3090 / 5900X. Check mode hasn't run since the fix, and this head hasn't been built or played. Linux, AMD, the Steam Deck and a branch-only measurement are still missing. The Beanstalk request was for
2e7be22and has lapsed. CI on the head was not looked at.Overlaps and merge order:
switches.defand splices tonx2/oot_patches.py. Several carry the samenx2/build.pyMARK_BITMAP change and a newtests/test_mark_bitmap_host.py. Whichever merges second conflicts; the build.py change belongs in one PR only.@ -104,6 +104,7 @@ SW(HOS_MOVIE_PACE, kill, bool, "on: a 60 FPS cap is raised for a movie's pictureSW(HOS_MUTEX_TRACE, diag, int, "0: off", "Logs mutex waits longer than <ms>, with the thread that held the mutex.")SW(HOS_MUTEX_WATCH, diag, string, "off", "Logs every operation on the mutex at that guest address (hex) and its condition variables' signals.")SW(HOS_MW_WAKE, kill, enum, "only changes to objects linked into a multi-wait wake WaitAny", "=all: every event, semaphore or queue change wakes every WaitAny, as before.")SW(HOS_NATIVE_BOUNDS, kill, enum, "on: the model bounds routines on host code where it gives the game's bits exactly, the rest lifted", "=0 (or false, off, no): every call runs as lifted, as on main; 1 (or unset) runs the model box (f_80ba37a0: a model's box from its meshes' boxes under their bones) , the transform history's rotation step (in f_80021ca0) and the sphere merge (f_800a8000) on host code where it gives the game's bits exactly, the rest lifted; check runs both on every call and logs any difference (slow). An oot: bounds line every 10 s counts the calls (host/oot_bounds.c).")The sphere merge is not spliced, so the row shouldn't say it runs on host code. Also remove the stray " ," after "bones)".
@ -0,0 +102,4 @@const double s = (double)a * (double)b + (double)z;uint64_t d;memcpy(&d, &s, 8);if ((d & UINT64_C(0x1fffffff)) == UINT64_C(0x10000000)) return 0; /* (a64_suyu.h RECOMP_FPX_MIDPOINT) */Without a hardware FMA this returns 0 before it writes
*r, but both callers readrbefore they checkok. Write*r = (float)s;first and return the midpoint test (the suggestion is in the review).@ -0,0 +289,4 @@const float o0 = f_of(ld32(mh + 0x2d0)), o1 = f_of(ld32(mh + 0x2d4)), o2 = f_of(ld32(mh + 0x2d8));for (uint32_t i = 0; i < n; i++) {RD(tp, tbl + 8 * (uint64_t)ld16(idx + 2 * i), 8);x0 = ld64(tp); /* (ldr x0, [x9, x1, lsl #3]) */Instruction text from the game's disassembly (also :326
add x0, sp, #0x180 before the BL, :392b.le). Rebuilding the game's leftover x0 from its code is part of the licensing problem in the review.@ -0,0 +155,4 @@d0 = r_fma(&r, d5, d6, d2);if (!r.ok) goto declined;f = r_cmp(d2, d3);if (LE(f)) { /* 80024bdc */Licensing: this follows the game's instructions one at a time, with the game's register allocation (d0..d27) and each branch block labelled by its address (
80024bdc,8002337c,80023380,80023720). That is a transcription of the game's code, which CONTRIBUTING.md's Licensing section forbids.@ -799,0 +830,4 @@# measured offline against main's locals form it lost on its copy path (45.6 against 40.2 ns a call) and won 1.3x on# its merge path, for 0.04 % of game code; a piece that does not beat main's form stays unwired (the rewrite brief).BOUNDS_SPHERE_SPLICE = FalseBOUNDS_SPHERE_HEAD = "void f_800a8000(Ctx *__restrict A64_NOESC c) {\n"void f_800a8000here is matched bymentioned_addresses(), sokeep_mentionedtakes f_800a8000's locals away although the sphere is not spliced. Remove the sphere path, or keep its address out of this file until it is spliced.Splicing this costs the whole of f_80021ca0 its locals, including at
HOS_NATIVE_BOUNDS=0and on CPUs without FMA, where it never answers. Please give a branch-only measurement on current main (unset / =0 / main), CPU time and frame times.@ -0,0 +343,4 @@static void test_rot_on(void) {rot_consts(), rot_expect();Ctx c = rot_ctx();CHECK(hos_bounds_80021ca0_rot(&c) == 1);On a CPU without FMA (
-march=nativegives none) the kernel declines by design and this fails. Expect a decline under#if !(defined(__FMA__) || defined(__aarch64__)), as test_bounds_kernels.py does.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.