WIP: perf(host): the box-against-view test and the occlusion grid's build on host code, bit for bit (HOS_NATIVE_VISIBILITY, on by default) #1902
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
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1902
Loading…
Reference in a new issue
No description provided.
Delete branch "snaildev99/Longshot:perf/native-visibility"
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 of the game's visibility routines run on host code with the game's exact results, behind a new switch, on by default (
HOS_NATIVE_VISIBILITY=0gives the lifted code): the box-against-view test the per-model visibility job calls for every model (f_80029240, 42 instructions, a leaf) and the build of the coarse occlusion depth grid that job tests models against, once a frame (f_808226e0, 1,466 instructions with its callee f_80823e00 and the logf it calls). In the Market profile they hold 0.46 % and 0.69 % of the game's code time (0.56 % and 0.77 % on a Kakariko and trail route), nearly all on the module workers.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 box test answers when every compared lane, product and sum is in a class where the PC's IEEE arithmetic gives Arm's bits (no NaN, infinity or subnormal; products and distances zero or in [2^-62, 2^62); sums zero or at least 2^-126) and the lift's own float gate is open (FPCR 0 or FZ, FPSR.IXC set); the grid build checks every float operation as it is made (operands zero or normal, results finite and above the smallest normal or an exact zero, no division by zero, no conversion out of range), saves every region it writes first and puts them back on a decline, and needs a hardware FMA (x86-64-v3).
How:
nx2/oot_patches.py(patch_visibility, the supported build only) puts a gate first in each lifted function:hos_vis_on_<addr>is 1 until the first call has read the switch, then 0 unless it is on, so with the switch off the gate is one load and an untaken branch.host/oot_visibility.canswers withhost/visibility_kernels.c(the box test: SSE2 with the planes four at a time, one plane a lane, the same operations on the same operands as the game's; a plain C version for other hosts and plane counts above 6) andhost/visibility_occlusion.c(the grid: the game's operations in the game's order, its writes marked for the GPU mirror withHOS_WRITTEN). The hook writes every register the routine leaves (box: x0, x8, x9, x10, v0..v3, NZCV; grid: the callee-saved registers, v8..v15's upper halves cleared as the routine's restore leaves them). Each gated function is also declared at file scope (VIS_FWD), becausenx2/split_giants.pymay put the gate in a piece written beforef_<addr>.Read first:
host/oot_visibility.c,host/visibility_kernels.c,host/visibility_occlusion.c(vis_occlusion_808226e0),nx2/oot_patches.py(patch_visibility),tests/test_native_visibility.py, the two rows ingpu/vk/switches.def.Testing
Tested: Windows 11, RTX 3090 (NVIDIA 610.88), Ryzen 9 5900X. In the game, with this branch's code (at 38f0ad29, before the switch rows and the declaration changes) merged with other rewrite branches into a test tree on main
068fb8eb,HOS_NATIVE_VISIBILITY=check, the Market and Hyrule Field for about five minutes: the box test answered 6,291,456 of 6,291,456 calls on the host and the grid build 4,095 of 4,096, with noDIFFERENTline (every answered call compared with the lifted routine, register for register and byte for byte). Then the CPU measurement below (test treetest/rewrites@ e614ef49, this code at 9e7311d1,HOS_NATIVE_VISIBILITY=1with the other eight branches' switches on): all 15 runs held 60 fps. This head (the rebase onto current main and the upkeep commit) is not built or played.Exactness offline (Unicorn runs the game's own routine on the executable; a driver runs the real host files): the box test on 1,000,000 calls (frusta with boxes inside, outside and across, 127,050 boxes exactly on a plane, the volume's own box touching the model's, plane counts 0 to 9, 100, negative and extreme, edge values, cancelling products, random bits, eight FPCR and many FPSR settings): 661,041 answered natively, 0 mismatches in every x register, SP, all 32 q registers (128 bits), NZCV, FPSR and memory, in the SSE build and the plain C build. Five deliberately broken versions are caught (11 to 3,514 mismatching cases of 10,000 each). The grid build on 19,625 calls that the game's routine finished in Unicorn (views with projections landing exactly on .5, on the grid's edges and on +0 / -0; grids 1x1 to 24x16 with sub-cells 1 to 4; tile levels 0 to 4; height fields up to 12x12; stale contents; edge values): 11,399 answered natively, 0 mismatches in every byte of every block, FPSR, x19 to x30, SP and q8 to q15, in the FMA build and the build without (which answers only the routine's "off" path); 375 cases the game's routine did not finish were all declined with memory as it was; five broken versions are caught (21 to 218 cases), the last one (the running minimum's tie rule for -0 / +0) after a generator of signed-zero ties was added (43 of 4,000). Run again on this branch's host files after the rebase (they are byte for byte the ones proven; the harnesses run the hooks against the stock lift's routines, so the gate's declaration is not in what they compile): the box test 250,000 calls, 164,889 answered natively, 0 mismatches in both builds; the grid build 19,644 finished calls, 11,484 answered natively, 0 mismatches in both builds, 356 unfinished all declined.
Game-free checks at this head:
tests/test_native_visibility.pypasses (the gates once each, first in their functions, declared at file scope, the supported build only; both box kernels against a model of the game's instructions on 60,000 cases; the declines; the hooks off, on, check and on another build; the grid on an empty scene against a result worked out by hand), and so dotests/test_switch_table.py(731 switches),tests/test_patch_hooks_defined.pyand 36 of the other 41 tests that readnx2/oot_patches.pyornx2/entry_hooks.py. 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_VISIBILITY=0against unset (on), and main against this branch with the switch unset; the game's CPU seconds with the frame rate capped at 60, and the frame times uncapped. Expecting 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).HOS_NATIVE_VISIBILITY=checkin the Market and Hyrule Field, expecting thevisibility:count lines with calls taken and noDIFFERENTline; then=1, expecting no model missing or popping (by hand).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 are not among them), at a 60 fps cap in the Market, the nine on used 2.7 % less CPU standing and 2.4 % less turning (the whole process) than main, and the hooks in with every switch off cost nothing measurable (-0.3 % / -0.2 %). 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 (main068fb8ebwith nine rewrite branches: the seven maths units, the maths library, animation, bounds, crowd, visibility (this branch at 9e7311d1), glue, the effect triggers with the six-channel reverb, and the solver; the cloth and particle effect rewrites, the two- and four-channel reverb and later pieces of other branches are not among them), lifted withA64_FPXKEEP=0so that the lift is main's apart from the hooks. Not this PR alone: the run-time switches were all on together. Main has moved 28 commits 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. 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 nine do not touch; on the executors the nine on were -4.1 % / -4.0 %. The module workers, where these two routines run, went 0.847 to 0.844 cores standing and 0.884 to 0.875 turning with the nine on (they also run other branches' routines).
Offline (CPU time a call, not the game; Ryzen 9 5900X with other jobs running; best of 5; the hook timed through its gate). Main's form is the lift with registers as C locals that main writes for these functions, approximated offline from the stock lift with the translator kit's own
localize_regs(not main's lifter); a gated function is written in the older context form, and "switch off" is that form plus the gate.The box test's fixed cost through the hook is about 20 ns, more than a whole lifted call that stops before the planes; the share of such calls in the game is not measured. The switch-off column was measured before the hook's declaration took
A64_NOESC(the upkeep commit), and the game measurement above found no off cost at the process's scale.The switch
HOS_NATIVE_VISIBILITY(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 the host code into a copy, then the lifted routine, compares registers and every region written, logsvisibility: f_<addr> DIFFERENT from the lifted routine: ...on a difference and keeps the lifted result.HOS_NATIVE_VISIBILITY_LOG=1(always in check mode) logsvisibility: <routine> <n> calls: taken <k>, lifted for float mode / range / input / path ..., checked: different <d>every 2^20 calls (2^12 for the grid). Another game build leaves it off with a log line. 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_VISIBILITY=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 answer from the box test would cull a model that should be drawn or draw one that should be culled (a model missing or popping); a wrong grid would do the same through the occlusion test. Every answered call in the in-game check run matched the lifted routine. The grid build saves and restores up to its whole output on a decline. 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 nine 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 grid build, the box test writes no memory). Which rewrite causes it is not determined; this branch is one of several candidates.Turning it off:
HOS_NATIVE_VISIBILITY=0.After updating: 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.068fb8eb, in check mode and on; this head is not built or played.)mise run testpasses (any failure that also fails onmainis named). (The 39 tests that read the changed files pass, the five failures are main's; the whole suite not run.)main, or Measurements says why there is nothing to measure. (Measured with nine rewrite branches merged; this branch alone not yet.)third_party/untouched; nothing GPL-incompatible.When it applies
gpu/vk/switches.def. (The rows are 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_native_visibility.py, new; its "no other function was gated" slice finds the 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
VIS_DECL declares hos_vis_<addr>(Ctx *A64_NOESC c, A64Fn lifted): without it the compiler takes the lifted function's context for escaped at the gate's call, which costs the gated function with the switch off. Only the declaration in the lifted code changes; the host code does not. tests/test_native_visibility.py's "no other function was gated" slice looked for "void f_808226e0(", which now first finds the file-scope declaration VIS_FWD puts at the file's head (the slice came out empty). It looks for the head line "void f_<addr>(Ctx *__restrict A64_NOESC c) {". Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Ran in the game in a test tree of nine merged rewrite branches on main
068fb8eb(Windows, RTX 3090): in check mode in the Market and Hyrule Field the box test answered 6,291,456 of 6,291,456 calls and the grid build 4,095 of 4,096 with no difference from the lifted routines, and with the switch on in a 15-run CPU measurement at a 60 fps cap (every run held 60); this head itself is not built or played.@Beanstalk linux: this branch with HOS_NATIVE_VISIBILITY unset against HOS_NATIVE_VISIBILITY=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), and a "visibility: the box-against-view test ... on the host" line in the log with the switch set.
@snaildev99 only members of
BigBeanscan start the farm. One of them can approve this request by reacting 👍 to it or to this comment.@Beanstalk
Beanstalk test farm · an earlier run: commit
5f0c55d(the newer results are in a comment below)Commit
5f0c55d· approved by llun (reviewed) · dashboardDone (started 19:55 UTC, last report 23:56 UTC). Comment
@Beanstalkto run it again.linuxvisibility-route· frame time p99 (ms)HOS_NATIVE_VISIBILITY=0(reference)HOS_NATIVE_VISIBILITY=1linuxWhy it failed
linux:visibility-route · HOS_NATIVE_VISIBILITY=0 (PR only)screenshot.max_diff:limit 0.0linux:visibility-route · HOS_NATIVE_VISIBILITY=1 (PR only)field-standing.cpu_s: HOS_NATIVE_VISIBILITY=1 vs HOS_NATIVE_VISIBILITY=0 (PR):69.1 → 75.2 (+8.7%); limit 5.0; the PR's own cells: HOS_NATIVE_VISIBILITY=1 against HOS_NATIVE_VISIBILITY=0 (HOS_NATIVE_VISIBILITY=0 (PR only))linux:visibility-route · HOS_NATIVE_VISIBILITY=1 (PR only)market-standing.cpu_s.max_delta_pct:98.9 → 120.7 (+22.0%); limit 10.0linux:visibility-route · HOS_NATIVE_VISIBILITY=1 (PR only)screenshot.max_diff:limit 0.0linux:visibility-route · HOS_NATIVE_VISIBILITY=1 (PR only)market-standing.cpu_s: HOS_NATIVE_VISIBILITY=1 vs HOS_NATIVE_VISIBILITY=0 (PR):112.2 → 120.7 (+7.5%); limit 5.0; the PR's own cells: HOS_NATIVE_VISIBILITY=1 against HOS_NATIVE_VISIBILITY=0 (HOS_NATIVE_VISIBILITY=0 (PR only))What was tested
What will be tested · AI plan (
gpt-6.1-terra)On Linux, the plan compares main with the PR’s visibility switch off and on in the child Market and Hyrule Field. It measures capped CPU time at two camera angles, uncapped frame times, and matching views for missing models or other visual changes; it also times lift builds. Crashes, failure to activate the switch, substantial CPU or frame-time regressions, or picture differences fail the plan. Gameplay takes roughly half an hour per tester, with timed builds counted separately.
0or1(PR only).Measurements on `linux`, for the PR description
Verdict: fail on linux (2 reports):
visibility-route screenshot.max_diff;visibility-route field-standing.cpu_s: HOS_NATIVE_VISIBILITY=1 vs HOS_NATIVE_VISIBILITY=0 (PR) (+8.7%);visibility-route market-standing.cpu_s.max_delta_pct (+22.0%)failed.Hardware: 1: linux+nvidia+nvidia-proprietary+dgpu
NVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAM; 2: linux+nvidia+nvidia-proprietary+dgpuNVIDIA GeForce RTX 5080, 620.73.4AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMScene: visibility-route, from a new save (frame_rate_cap=0); each cell's settings and switches as the table names them
Method: the Beanstalk test farm: main and this PR built and run on the same PC in one session, game starts alternating (ABBA); visibility-route: 1 game start a side, market-standing 30 s after 5 s warm-up, market-turned 20 s after 2 s warm-up, field-standing 30 s after 5 s warm-up, field-turned 20 s after 2 s warm-up, field-uncapped 30 s after 5 s warm-up, market-uncapped 30 s after 5 s warm-up; timed builds: main and this PR each built 2 times a cache, alternating, each a whole build in a fresh folder (lift; shader preparation not timed); each number the median of the runs, then of 2 reports
How to reproduce: the farm's plan above (
@Beanstalkon this PR runs it again)a1041825f0c55dHOS_NATIVE_VISIBILITY=0 (PR only)· field-turned · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· market-turned · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· field-standing · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· field-uncapped · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· market-standing · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· market-uncapped · CPU time (s)HOS_NATIVE_VISIBILITY=0 (PR only)· field-turned · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=0 (PR only)· market-turned · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=0 (PR only)· field-standing · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=0 (PR only)· field-uncapped · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=0 (PR only)· market-standing · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=0 (PR only)· market-uncapped · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· field-turned · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· market-turned · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· field-standing · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· field-uncapped · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· market-standing · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· market-uncapped · CPU time (s)HOS_NATIVE_VISIBILITY=1 (PR only)· field-turned · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· market-turned · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· field-standing · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· field-uncapped · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· market-standing · frame time (p99) (ms)HOS_NATIVE_VISIBILITY=1 (PR only)· market-uncapped · frame time (p99) (ms)Build times (each a median of the timed builds; caches: lift = the lift again (no kept lift, main's compiled objects kept))
a1041825f0c55dFlags and settings
HOS_NATIVE_VISIBILITY0,1As Markdown for the PR description:
The testers' hardware
linuxNVIDIA GeForce RTX 5070, 620.70.6AMD Ryzen 5 9600X 6-Core Processor, 32 GB RAMlinuxNVIDIA GeForce RTX 5080, 620.73.4AMD Ryzen 7 7800X3D 8-Core Processor, 32 GB RAMRecommendation: Request changes. The hooks have an initialization data race, and check mode can report success without comparing all claimed state. The performance gain and the cost of the default-off path are not established for this branch.
This adds optional host implementations of two visibility routines, with fallback to the lifted game code and a comparison mode. The potential CPU saving comes at the cost of substantial exactness and fallback code, synchronization risk, and an unmeasured change to the default path.
Does it help: Unproven. Three interleaved Windows runs of nine combined rewrite branches used 2.7% less process CPU standing and 2.4% less turning than an older main; they do not isolate this PR. Offline timings show the native box path is slower for calls that stop before the planes, while the measured share of those calls is unknown. This head has no isolated game measurement against its base, including frame-time and 1% low results.
Other systems: The gates run on module workers even with the switch unset; the grid also marks guest memory for the GPU mirror. The reported capture-copy thread increase of 0.010–0.014 cores has not been attributed. Linux, AMD, Steam Deck, other Tier 1 configurations and this head on Windows remain untested. The reported Unicorn comparisons and earlier Windows check run support exactness for their inputs, but do not establish coverage on those systems.
Switches: HOS_NATIVE_VISIBILITY is new and defaults off; HOS_NATIVE_VISIBILITY_LOG is new and defaults off, with logging forced in check mode. Both have table rows. The performance switch's default was chosen because the change is unmeasured, rather than from platform measurements as the project requires; its default-off overhead also needs measurement.
Reviewed:
5f0c55d218againsta104182b40: Read the repository rules, contribution guide, PR template, standards, commits, changed host files and headers, and the changed sections of the patcher and switch table. Reviewed the test fixture and its stated coverage, and inspected guest-memory marking and gate dependencies. The remainder of the large patcher, the test file and unrelated callers were skimmed; the unavailable sibling Tooling rules and live Forgejo state could not be inspected. No generated files or translations changed.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Suggestions (the author may take or leave)
Testing: No commands that build, execute project code or run tests were used, as requested. The PR reports game-free checks and an earlier Windows game run; this head has not been built or played.
Overlaps and merge order: No overlapping PRs could be established from the provided material; network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), on the pull request's opening. Nothing was run; a maintainer decides.
@ -104,6 +104,8 @@ 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_VISIBILITY, attempt, enum, "off: the visibility routines run as lifted", "1 runs the render calc's visibility routines (the box-against-view test f_80029240, the occlusion grid's build f_808226e0) 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; host/oot_visibility.c).")The default is off because this branch has not been measured alone. The switch standard requires a default chosen from platform measurements; please establish those results and choose the default accordingly.
@ -0,0 +63,4 @@hos_log("visibility: the box-against-view test (f_80029240) and the occlusion grid (f_808226e0) on the host%s ""(HOS_NATIVE_VISIBILITY)",m == VIS_CHECK ? ", each call checked against the lifted routine" : "");vis_mode = m;Multiple module workers can read vis_mode and the volatile gates while this thread writes them, including with the switch unset. Please publish and read the gates atomically and acquire completed initialization before reading the mode and log state.
@ -0,0 +129,4 @@/* (what the lifted code writes: x0, x8, x9, x10, v0..v3; it keeps only the NZCV bits it needs) */VisBoxRegs g;regs_from(c, &g);if (g.x0 != r.x0 || g.x8 != r.x8 || g.x9 != r.x9 || g.x10 != r.x10 || memcmp(g.q, r.q, sizeof g.q)) {The native path writes NZCV, but check mode does not compare it. A flag-only mismatch is therefore reported as a match; please compare it and cover that case in the fixture.
@ -0,0 +158,4 @@OccCopy *k = (OccCopy *)ctx;if (k->n == k->cap) {const int cap = k->cap ? 2 * k->cap : 32;OccRegion *r = (OccRegion *)realloc(k->r, (size_t)cap * sizeof *r);If this allocation fails, the region is silently omitted and the check can report a match without comparing it. Please propagate the failure and report or decline the incomplete check.
@ -386,0 +389,4 @@# Each gets a gate first in its lifted function: hos_vis_on_<addr> is 1 until the first call has read the switch, then 0# unless it is on (one load and an untaken branch when off); hos_vis_<addr>(c, f_<addr>) returns 1 when it answered.VIS_GATES = ("80029240", "808226e0")VIS_GATE = (" if (__builtin_expect(hos_vis_on_%s, 0) && hos_vis_%s(c, f_%s)) return; "These gates change the default-off lifted path too; the offline approximation shows up to 10% and 7% overhead for the two routines. Please measure this head alone against its merge base, including frame pacing and the suspected mirror cost, and revise the change if its cost outweighs the gain.
@fix
I changed this pull request by bringing it up to date: the new head is
caca43f11c. I rebased it ontomain(a764653726).Conflicts resolved
Left for the author
Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
5f0c55d218caca43f11cRecommendation: Request changes. The production host build cannot see the floating-point gate used by both hooks, and the default-off path still has an initialization race. Check mode can report a match with state left unchecked, and the available runs leave the CPU gain and Linux regressions unresolved.
Adds opt-in host implementations for two rendering visibility routines, with a lifted fallback and a diagnostic comparison mode. The potential CPU saving comes with two implementations to maintain, a changed lifted path even when disabled, and per-frame grid snapshots and dirty-page marking.
Does it help: Unproven. Three interleaved Windows rounds with nine rewrites enabled used 2.7% less process CPU standing and 2.4% less turning in the capped Market. The combined off deltas of −0.3% and −0.2% were within the spread. Offline, box calls that exit before the plane tests took 28–35 ns versus 9–22 ns, and their in-game share is unknown. On the earlier Linux head, the RTX 5080 used 120.7 CPU seconds in the Market with visibility on versus 112.2 with it off and 98.9 on main. The current head lacks an isolated comparison.
Other systems: The hooks run on module workers across GPU vendors and can affect model visibility, the GPU mirror, and frame pacing. The earlier Windows check run found no reported differences among 6,291,456 native box calls and 4,095 native grid calls, within the fields that check mode compared. The earlier Linux farm flagged screenshot differences with the switch off on both NVIDIA systems, and several p99 comparisons lacked enough usable starts. AMD, Steam Deck, older CPUs without FMA, and the current Windows and Linux builds still need coverage. The diff adds no save, audio, input, or path-format changes.
Switches: HOS_NATIVE_VISIBILITY defaults off and accepts 1 or check. The default avoids the native kernels, but the gated lift still changes and the project requires a measured default. HOS_NATIVE_VISIBILITY_LOG defaults off and is forced on in check mode. That diagnostic default is appropriate. Both have switch-table rows.
Reviewed:
caca43f11cagainsta764653726: Read AGENTS.md, CONTRIBUTING.md, developer standards, the measurement guidance, the Forgejo template, the six commits, the complete diff, and all new host files, headers, and tests. Read the changed patcher and switch-table sections and traced the lift, split, host build, guest memory, and GPU marking paths. Skimmed unrelated portions of the existing files. Read the supplied recorded runs, comments, and stale review. The review checklist file and sibling Tooling checkout were absent. No generated files or translations changed. The proprietary routine and offline harnesses were unavailable for independent inspection.; nothing run (a code review).Checked and fine:
Blocking (to change before merge)
Waiting on the author (a run, a measurement or a decision; no edit does it)
Suggestions (the author may take or leave)
Testing: Read-only review. No builds, tests, scripts, or game runs executed. The author reports earlier Windows gameplay, offline Unicorn comparisons, and partial game-free checks. The farm reports failures for
5f0c55dand a pending run forcaca43f.Overlaps and merge order: The Windows evidence combined eight sibling rewrites with this PR. No merge dependency or required order was identified in the checkout.
Automated code review by BeanBot (gpt-6.2-sol), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -0,0 +64,4 @@"(HOS_NATIVE_VISIBILITY)",m == VIS_CHECK ? ", each call checked against the lifted routine" : "");vis_mode = m;hos_vis_on_80029240 = hos_vis_on_808226e0 = m != VIS_OFF;The workers race on these volatile gates and can bypass the acquire through vis_mode. Make both sides of the generated gate atomic and acquire initialization before reading its state.
@ -0,0 +80,4 @@why_name[WHY_TAKEN], k[WHY_TAKEN], why_name[WHY_FLOAT_MODE], k[WHY_FLOAT_MODE], why_name[WHY_RANGE],k[WHY_RANGE], why_name[WHY_INPUT], k[WHY_INPUT], why_name[WHY_PATH], k[WHY_PATH],vis_mode == VIS_CHECK ? ", checked: " : "", vis_mode == VIS_CHECK ? why_name[WHY_DIFF] : "",vis_mode == VIS_CHECK ? k[WHY_DIFF] : 0);When logging with visibility on, the final format argument appends a stray 0 to the preceding count. Emit the difference suffix only in check mode.
@ -0,0 +108,4 @@int hos_vis_80029240(Ctx *c, A64Fn lifted) {if (vis_mode < 0) vis_start();if (vis_mode == VIS_OFF || (vis_mode == VIS_CHECK && vis_inside)) return 0; /* (the thread-local only in check mode: it can be a call) */if (!RECOMP_FPX_OPEN(c)) return vis_count(&stats_box, WHY_FLOAT_MODE), 0;The normal host build does not get RECOMP_FPX_OPEN from hos.h or runtime a64.h. The test injects it. Share the real definition and compile the fixture against the production interface.
@ -0,0 +129,4 @@/* (what the lifted code writes: x0, x8, x9, x10, v0..v3; it keeps only the NZCV bits it needs) */VisBoxRegs g;regs_from(c, &g);if (g.x0 != r.x0 || g.x8 != r.x8 || g.x9 != r.x9 || g.x10 != r.x10 || memcmp(g.q, r.q, sizeof g.q)) {A flag-only mismatch passes this comparison. Use a reference that retains NZCV and test a mismatch limited to one flag.
@ -0,0 +163,4 @@k->r = r, k->cap = cap;}uint8_t *mine = (uint8_t *)malloc((size_t)n);if (!mine) return;A failed capture allocation drops a region and can report a false match. Treat the check as incomplete and exercise allocation failure in the fixture.
@ -0,0 +191,4 @@vis_inside = 0;int diff = -1;uint64_t at = 0;for (int i = 0; i < keep.n; i++) {A grid result with incorrect saved vector state still counts as a match. Compare the promised register state and test a register-only mismatch.
@ -0,0 +604,4 @@enum { I_C1 = 2, I_R1 = 3, I_C2 = 4, I_R2 = 5, I_K = 6, I_LOG = 7 };int i_g = -1, i_t = -1, i_l = -1, i_b = -1, i_h = -1, i_f = -1;if (ok && ncells >= 1) i_g = k, ok = add_reg(reg, &k, range, ld64(O + 0x668), 8 * (uint64_t)(uint32_t)ncells, 1);if (ok && levels) {An unused null record array still produces a 48-byte snapshot range. The host window check accepts address zero, which can fault on Windows. Skip unused arrays and validate the ranges the snapshot touches.
@ -0,0 +924,4 @@if (!((int64_t)lvl < (int64_t)lv - 1)) break;}}const uint8_t top = O[0x6d9];This marks entire capacities, including untouched pages. Isolate the PR's effect on copied pages, capture CPU, peak RAM, and frame pacing.
@ -406,0 +409,4 @@# Each gets a gate first in its lifted function: hos_vis_on_<addr> is 1 until the first call has read the switch, then 0# unless it is on (one load and an untaken branch when off); hos_vis_<addr>(c, f_<addr>) returns 1 when it answered.VIS_GATES = ("80029240", "808226e0")VIS_GATE = (" if (__builtin_expect(hos_vis_on_%s, 0) && hos_vis_%s(c, f_%s)) return; "The gate also changes how both lifted functions handle registers when off. Measure the current default-off build against main and include matched screenshots for the earlier Linux failures.
@ -0,0 +589,4 @@exe = tmp / ("fixture.exe" if os.name == "nt" else "fixture")occ = tmp / ("occ_fixture.exe" if os.name == "nt" else "occ_fixture")# (-mfma where the compiler takes it: the grid's build needs a fused multiply-add, as the game's build has)fma = ["-mfma"] if subprocess.run([cc, "-mfma", "-x", "c", "-c", "-o", os.devnull, "-"], input="int x;\n",Compiler support for -mfma does not establish CPU support. Run the baseline fixture everywhere and gate the FMA executable on runtime support.
@fix
@Beanstalk
Beanstalk test farm · an earlier run: commit
5370110(the newer results are in a comment below)Commit
5370110· approved by HumanBean (reviewed) · dashboard⚠️ Note: The explicit off value exercises the default-off path; main ignores both values of the new switch.
⚠️ Note: Check mode and its per-routine coverage counts are omitted to keep the run short, so this plan does not establish bit-for-bit agreement or detect transient popping between screenshots.
⚠️ Note: Copied GPU-mirror pages and allocation-failure or register-only mismatch fixtures cannot be measured directly by these gameplay probes.
Started at 07:34 UTC.
Estimate: done in about 2 h 15 min, from the queue and the testers online now.
linuxwindowsvisibility-route· frame time p99 (ms)HOS_NATIVE_VISIBILITY=0(reference)HOS_NATIVE_VISIBILITY=1linuxwindowsWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)On Linux and Windows, the plan compares the default-off and enabled visibility paths in the Market and Hyrule Field, with matched pictures and capped and uncapped measurements. It records CPU time, peak memory and frame times, and also times lift builds; gameplay takes about 21 minutes per tester. Crashes, substantial performance regressions or screenshot differences fail the pull request.
0or1(PR only).market-entrance(settings frame_rate_cap=0), then teleport to Market, take the picture market to compare with main, measure market-capped for 30 s (after 5 s warm-up), set frame_rate_cap to 6, move the stick, take the picture market-turned to compare with main, measure market-uncapped for 20 s (after 5 s warm-up), set frame_rate_cap to 0, teleport to Hyrule Field, take the picture field to compare with main, measure field-capped for 30 s (after 5 s warm-up), take the picture field-turned to compare with main, measure field-uncapped for 20 s (after 5 s warm-up); 1 run on each side for each of 2 cells (2 game starts a run).I changed this pull request where an edit could (the rest needs runs, measurements or decisions): the new head is
e1e0089257. I rebased it ontomain(7486869e64).Conflicts resolved
Changed
Left for the author
Still for the author (no edit does these)
Nothing was built or run: check the change. It will be reviewed again.
Automated fix by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
537011092fe1e0089257Beanstalk test farm
Commit
41c96c3· approved by nobody yet · dashboardA member of
BigBeanscan review this commit and comment@Beanstalkto test it.Recommendation: Request changes. The native box test can read inaccessible memory that the lifted routine would never touch, and check mode can miss differences in the grid’s writes. The claimed performance gain for this branch and the cost of its changes with the switch off remain unproven.
This adds optional host implementations of two visibility routines, with lifted fallbacks and a comparison mode. It also changes GPU write tracking for host code and lifted stores regardless of the new switch; the potential CPU saving is not yet isolated from eight other rewrites.
@fixwill do (6)host/visibility_kernels.c:173: The SIMD path loads four planes before it knows which plane ends the test, while vis_range only checks the reserved guest window, not committed memory. (more on the line)host/oot_visibility.c:224: Check mode compares only regions reported by the native implementation. (more on the line)nx2/rtgen.py:69: Limit the host flag to files that need it and avoid changing the shared store path if an equivalent synchronized implementation costs less.For the author (3) (a run, a measurement or a decision)
nx2/rtgen.py:69: The atomic bitmap read runs on lifted stores even with visibility off, and the changed host flags invalidate cached host objects. (more on the line)More: does it help, other systems, switches, what was read
Does it help: Unproven. The Windows measurement reports 2.7% less whole-process CPU standing and 2.4% less turning, but nine branches were enabled together on an older base. The offline box timings also show early-exit calls slowing from 9–22 ns to 28–35 ns, with their in-game share unknown. No current-head comparison isolates this PR or reports uncapped frame-time and low-FPS effects.
Other systems: The visibility paths can affect model culling on both Windows and Linux, including Steam Deck and other CPU classes. The bitmap and generated-header changes affect GPU write tracking even with visibility disabled. The reported game check covered an older version on Windows/NVIDIA; this head, Linux, AMD and Steam Deck remain unverified. The host compile flag also changes object-cache keys and can cause recompilation.
Switches: HOS_NATIVE_VISIBILITY is new and defaults off; 1 attempts native execution and check compares with the lift. Off is conservative but has not been selected by the required isolated measurements. HOS_NATIVE_VISIBILITY_LOG is new and defaults off; it enables diagnostic counts and is also enabled by check mode. RX_MARK_BITMAP retains its default but now also controls host compilation, extending its scope.
Reviewed:
e1e0089257against7486869e64: Read AGENTS.md, CONTRIBUTING.md, the pull request template, relevant standards, the commit log and diff, the new host visibility files and tests, and the changed build and patch sections. Examined guest-range and bitmap definitions and their writers. The repository has no docs/review-checklist.md, and the adjacent Tooling rules were unavailable. The large unchanged portions of build.py, oot_patches.py and rtgen.py, and unrelated generated and translation files, were skimmed rather than read in full.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no builds, tests, project scripts or game runs were executed. The supplied CI reports no head-only failures.
Overlaps and merge order: Not checked: network access is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.
@ -0,0 +221,4 @@vis_inside = 0;int diff = -1;uint64_t at = 0;for (int i = 0; i < keep.n; i++) {L2: Check mode compares only regions reported by the native implementation. If a native path omits a store that the lifted routine makes outside those regions, no difference is logged, so a successful check can conceal precisely the missing write that would leave the native result stale. Snapshot and compare all potentially written allocations, including bytes the native path did not report, and add a case where the lifted stand-in writes outside the native region.
@ -0,0 +170,4 @@game's for each plane, so each lane's bits are that plane's. Planes past the count (or past 6) are zero lanes andnot looked at. Out: T (the sums plus distance), D (the distances), bad (a bit a plane out of class), gt (t > 0) */static inline void plane_group(const uint8_t *obj, uint32_t first, uint32_t n, __m128 mn, __m128 mx, __m128 *T, __m128 *D,int *bad, int *gt) {L1: The SIMD path loads four planes before it knows which plane ends the test, while vis_range only checks the reserved guest window, not committed memory. If the first plane culls the box and a later plane lies on an uncommitted page, the lifted routine returns after the first plane but this path faults while preloading the later one. Validate that every speculatively read page is committed, or avoid reading planes beyond the one the lifted routine would test.
@ -67,3 +67,3 @@before is caught by its first byte; read-only on the store path */extern uint8_t a64_gpu_pages[A64_DIRTY_PAGES / 8];#define A64_GPU_PAGE(a) ((a64_gpu_pages[A64_DIRTY_AT(a) >> 3] >> (A64_DIRTY_AT(a) & 7)) & 1)#define A64_GPU_PAGE(a) ((__atomic_load_n(&a64_gpu_pages[A64_DIRTY_AT(a) >> 3], __ATOMIC_ACQUIRE) >> (A64_DIRTY_AT(a) & 7)) & 1)L6 (minor): The atomic bitmap read runs on lifted stores even with visibility off, and the changed host flags invalidate cached host objects. Measure current-head switch-off frame times and clean and incremental build time against the base; the older combined run predates these changes.
WIP: perf(host): the box-against-view test and the occlusion grid's build on host code, bit for bit (HOS_NATIVE_VISIBILITY, off by default)to WIP: perf(host): the box-against-view test and the occlusion grid's build on host code, bit for bit (HOS_NATIVE_VISIBILITY, on by default)HOS_NATIVE_VISIBILITYis now on by default (41c96c3a, on top of BeanBot'se1e00892), as docs/dev/standards.md asks: a switch ships at its value from the first push, not off because it is new.HOS_NATIVE_VISIBILITY=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 grid build and the box test's host code are the game's Arm routines transcribed one instruction at a time, which CONTRIBUTING.md's Licensing section rules out, the same problem that blocks sibling #1911. Separately, the switch ships on although the only measurement of this branch alone leans the other way.
For a player this would mean a little less CPU time in the per-model culling job and the occlusion grid build each frame (0.46 % and 0.69 % of the game's code time in the Market). The cost is ~1,500 lines of bit-exact float code plus a gate in two lifted functions. As it stands, the code doesn't come out better on net.
Does it help: Unproven, and the one isolated run leans No.
5f0c55d, Linux, RTX 5070 and RTX 5080, one start a side). Market standing CPU was 112.2 → 120.7 s (+7.5 %) and Field standing 69.1 → 75.2 s (+8.7 %) with the switch on against=0in the same build. Uncapped p99 was +20 % / +24 % against main.5370110was superseded before it reported. Offline, the box hook is slower than the lift on calls that end before the planes (28-35 ns against 9-22 ns), and their share in the game is unknown.Other systems:
=0against main is inside its noise.nx2/rtgen.pyA64_GPU_PAGE changes every lifted store's mark andrt/a64.h, so every player's whole lift recompiles, with the switch on or off. It is unmeasured and outside this PR's topic.nx2/build.pynow gives every host file-DA64_MARK_BITMAP. No host file usesA64_MARKitself today (only comments), so behaviour is unchanged, but every host object's cache key changes.5f0c55dsay +16 % whole build (+75 s compile), which nothing in the diff explains. Players compile locally, so this needs measuring again.commit_on_touchinhost/mkw_glue.ccommits the page and it reads zero. AMD, Intel, the Steam Deck and CPUs without FMA (every grid call declines there) are not run.Switches:
HOS_NATIVE_VISIBILITY(kill, on by default,=0lifted,check): the on default is not backed by a measurement of this PR. The one isolated run shows more CPU with it on. It should not ship on until an isolated, repeated, interleaved measurement shows a gain past the noise on Linux and Windows. If that measurement shows no gain, the change doesn't earn its code.HOS_NATIVE_VISIBILITY_LOG(diag, off; always on in check mode): the right default.Reviewed:
41c96c3a8against7486869e6(its merge base), all 12 commits.host/oot_visibility.c,host/visibility_kernels.c/.h,host/visibility_occlusion.c/.h, the changed parts ofnx2/oot_patches.py,nx2/build.py,nx2/rtgen.pyandgpu/vk/switches.def, andtests/test_mark_bitmap_host.py.tests/test_native_visibility.py, for what it runs (it compiles and runs fixtures in a temp dir and touches nothing else).Fixed in this review: nothing landed on the head. A rebase onto main
b62932a96was clean commit by commit, with no conflicts. A one-line commit puttingA64_GPU_PAGEback to main's plain load was made, but the push to the head branch was refused. Both are left as suggestions below.Checked and fine:
vis_startpublishes the mode with release/acquire. A worker that loses the race spins until the mode is published.vis_rangechecked, and lanes past the count are masked out of bothgtsandbads. Its x8/x9/x10 match the scalar loop's.written()regions cover every store on the success path: O+0x288..0x4ea, both strip headers, 0x690..0x6a9, 0x6da, the used plane records, the grid, the tiles by page and the bounds.third_party/.Blocking (to change before merge)
host/visibility_occlusion.c:3says "The game's operations in the game's order: every Arm FMADD / FMSUB / FNMADD / FNMSUB is one fused multiply-add here".planes_80823e00(host/visibility_occlusion.c:226-300,:331-420) is one statement per instruction, with the temporaries named after the routine's registers:float s17 = f_sub(bad, p58, p4c);(:233),float s22 = -f_mul(bad, s20, s29);(:244),s31b, s30b, s28b(:265). Comments like/* (s8*s8 + s31*s31 + s9*s9) */record the register order.low_corners/tall_corners(:483-560) and the grid loops follow the same pattern.host/visibility_kernels.c:57"LDR q0, a; LDR q1, b; FCMGT v0.4s; ADDV s0; FMOV w8, s0",:121"EXT #8 then FADD .2s",:122"FADDP",:134"LDR s3".host/oot_visibility.c:10; v8..v15's upper halves from "its LDP d8..d15 restore" at:246). Those can only come from the routine's instruction listing.game_logffollows the public optimized-routines logf and reads the game's table from guest memory at run time, which is fine on its own. The rest needs rewriting from a description of what the routines compute, or dropping.gpu/vk/switches.def:108: on by default with no isolated measurement, while the only isolated run shows +7.5 % / +8.7 % CPU with it on (above). Measure this branch alone, against its base and against=0in the same build, with several interleaved runs a side on Linux and Windows: capped CPU, uncapped frame times and 1 % lows, and the share of early-exit box calls. Choose the default from those runs.nx2/rtgen.py:69: the__ATOMIC_ACQUIREload (BeanBot'se1e00892) changes every lifted store in the game, recompiles the whole lift and was never measured, and it has nothing to do with visibility. Put main's line back:#define A64_GPU_PAGE(a) ((a64_gpu_pages[A64_DIRTY_AT(a) >> 3] >> (A64_DIRTY_AT(a) & 7)) & 1). If the bitmap's race should be fixed, that belongs in its own measured PR, and a relaxed load would be enough there.5f0c55d. Measure it again at the new head and explain it, or remove the cause, since players build locally.Suggestions (the author may take or leave)
-DA64_MARK_BITMAPonly tooot_visibility.c, the one host file that testsA64_GPU_PAGE, rather than to every host compile job, so the other host objects keep their cache.host/oot_visibility.c:136: box check mode still doesn't compare NZCV, and grid check mode compares only the regions the host reports, not registers. Either compare them or narrow the "register for register" wording in the description.Testing:
5f0c55d, which failed (CPU and screenshot limits; the screenshot differences also appear with=0, so they look like scene noise).Overlaps and merge order:
gpu/vk/switches.defand hooks innx2/oot_patches.py. Expect textual conflicts in whatever merges second.game_logf. If 1904 lands a host logf, use one copy.@ -105,6 +105,8 @@ 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_VISIBILITY, kill, enum, "on: the visibility routines on host code where it gives the game's bits exactly, the rest lifted", "=0 (or false, off, no): the visibility routines run as lifted, as on main; 1 (or unset) runs the render calc's visibility routines (the box-against-view test f_80029240, the occlusion grid's build f_808226e0) 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; host/oot_visibility.c).")On by default, but the only isolated measurement (farm,
5f0c55d, Linux) shows +7.5 % Market / +8.7 % Field CPU with it on against =0, from single runs. Choose the default from repeated, interleaved runs of this branch alone.@ -0,0 +133,4 @@/* (what the lifted code writes: x0, x8, x9, x10, v0..v3; it keeps only the NZCV bits it needs) */VisBoxRegs g;regs_from(c, &g);if (g.x0 != r.x0 || g.x8 != r.x8 || g.x9 != r.x9 || g.x10 != r.x10 || memcmp(g.q, r.q, sizeof g.q)) {Nit: check mode doesn't compare NZCV here, and the grid check compares only the regions the host reports. Compare them, or narrow the 'register for register' wording.
@ -0,0 +54,4 @@}static inline uint32_t nzcv_fcmp0(float s) { return s < 0.0f ? 8u : s == 0.0f ? 6u : 2u; }/* one of the two box steps: LDR q0, a; LDR q1, b; FCMGT v0.4s; ADDV s0; FMOV w8, s0. 0 when a lane is out of class */Licensing: the comments are the routine's disassembly (here, and at :121, :122, :134), and the hook writes back its dead registers. Write it from the routine's behaviour, not its instruction listing.
@ -0,0 +230,4 @@const float t = f_add(bad, off, s7);const float p4c = ldf(P + 0x4c), p54 = ldf(P + 0x54), p58 = ldf(P + 0x58), p7c = ldf(P + 0x7c);const float p84 = ldf(P + 0x84), p88 = ldf(P + 0x88), p8c = ldf(P + 0x8c), p90 = ldf(P + 0x90);float s17 = f_sub(bad, p58, p4c);Licensing: one statement per Arm instruction, with temporaries named after the routine's registers (s17, s28, s30, s7b...). This is the game's code as C, which CONTRIBUTING.md's Licensing section rules out. Rewrite it from a description of what the routine computes, or drop it.
@ -67,3 +67,3 @@before is caught by its first byte; read-only on the store path */extern uint8_t a64_gpu_pages[A64_DIRTY_PAGES / 8];#define A64_GPU_PAGE(a) ((a64_gpu_pages[A64_DIRTY_AT(a) >> 3] >> (A64_DIRTY_AT(a) & 7)) & 1)#define A64_GPU_PAGE(a) ((__atomic_load_n(&a64_gpu_pages[A64_DIRTY_AT(a) >> 3], __ATOMIC_ACQUIRE) >> (A64_DIRTY_AT(a) & 7)) & 1)Outside this PR's topic: an acquire load in every lifted store's mark changes rt/a64.h, so the whole lift recompiles for everyone, switch on or off, and it was never measured. Put main's plain load back:
#define A64_GPU_PAGE(a) ((a64_gpu_pages[A64_DIRTY_AT(a) >> 3] >> (A64_DIRTY_AT(a) & 7)) & 1). A fix for the race goes in its own measured PR (relaxed would be enough).View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.