Renderer rewrite #1493
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#1493
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type: design · Scope:
gpu/vkand the host layer it calls · Status: first pass, for discussionTL;DR
The renderer grew from about 17,000 to about 86,000 lines in 11 days, and more than half of the commits that touch it are fixes, many of them fixing recent fixes. We propose to rebuild its core one piece at a time on main, behind the renderer interface we already have, while the game keeps shipping: no long-lived rewrite branch. Each piece is a second implementation that can be switched at run time and is checked against the old one by replaying recorded frames, and the safety net (record and replay, per-GPU image hashes, honest frame metrics) comes first.
Breakdown
vk_api.h) and the cache formats.How this fits the team's rework plan
The wiki's Renderer rework plan (draft of 16 Nov) already chose "rework, not rewrite": the lifter, the Horizon layer, the shader recompiler and
vk_api.hstay, the work happens behind the interface, and the old path stays selectable until the new one gives the same pictures on recorded traces, then goes in its own pull request. This issue agrees with all of that and is meant to feed it, not replace it. Work already in flight that this builds on: #1034 and its follow-ups (memory sync, TrashPanda), #1339 (budgets and the arbiter), #1121 (the render thread), #1340 and #1309 (draw predicates out ofvk_draw.cpp, 111 kill switches removed), #1300 and #980 (the switch table), #1288 (crash grouping), and the trace replay the plan's tools track asks for (#1113, #1198).What this issue adds: the numbers from nine research reports (below), a CPU and host track the plan does not cover (#1503 to #1506), the measurement problems that have to be fixed before any piece can be judged, and three points where it differs from the plan, for the plan's owners to decide: the menu, settings and upscalers move out of the renderer interface (the plan leaves them alone, but upscalers alone account for 52 fixes and most interface versions were menu services); descriptors become their own piece; and record and replay comes before anything else rather than beside it.
Why
This is a summary of nine research reports (lineage, architecture, regressions, performance, CPU, GPU and VRAM, translation, frame pacing, and other projects). Each will be summarised below as a comment once it is checked and cleaned of local paths and game details.
Size and shape. The renderer's own code (
gpu/vkwithout the vendored recompiler) is 172 files and 85,766 lines, about 9,500 of them data or generated (translations, operand tables, the switch table); it was 17,000 lines on 6 Nov. Five files hold 63% of its C++:vk_draw.cpp(11,712 lines),vk_replay.cpp(7,417),vk_memory.cpp(6,917),vk_menu.cpp(6,774) andvk_texture.cpp(5,721). Only about 3,500 lines ofvk_draw.cppare the draw path; the rest is pipeline building, the pipeline cache, shader preparation, samplers and diagnostics. The functiondrawalone is 804 lines with 325 branches.Everything touches everything. Headers include each other without cycles, but the code does not: 12 pairs of modules call each other both ways, and there are 1,111 file-scope variables. 63% of renderer commits touch one of
vk_draw,vk_replay,vk_memoryorvk_texture. 17 headers, including tuning rules, rebuild 34 of the 39.cppfiles.Fixes of fixes. 950 commits from 167 authors touched
gpu/vkin 11 days; 58% are fixes, and the share was between 43% and 70% every day. Of the 477 fixes that replace existing lines, 223 (47%) replace three or more lines another commit wrote, 193 of those within 72 hours. 35% of feature commits are patched the same way within 72 hours. Reverts are rare (3); we fix forward by flipping defaults.Knowledge hidden in code. 191 of 552 fixes encode a fact about a driver, the hardware, the OS or the game, not about our own design. 161 of those sit inside
.cppcode and only 2 indevice_policy.h. Any rewrite must turn them into data first, or find them again through bug reports.Not rendering, inside the renderer. The interface went from version 1 to 33 in 12 days. Of the 40 host functions added, 34 are menu services (input, audio, NFC, display), and only 3 of the 29 commits that bumped the version were for rendering. The renderer answers 52 option ids and is in effect the game's settings store; the menu and the replay changed together in 59 landed changes. Menu, translations, diagnostics, telemetry, bug report, crash window and pacing are about 22,400 lines (26%).
Switches.
switches.defhas 681 live rows: 281 diagnostics, 105 tuning, 104 kill, 80 attempt, 61 hardware and 50 player settings. Every switch multiplies what a test has to cover.Tests that cannot catch most bugs. 424 of 731 Python checks read a
vk_*.cppfile as text and 278 cut functions out of it by text, but no check runs any of the renderer's own translation units, where 89% of fixes land. Only 10% of fix commits bring a test that runs real code. There is no recording of the command stream to replay. The guide-screenshot check has been red on 277 of 290 pushes to main and the switch-table check on 43 of 64, so red checks stopped meaning anything.Memory. The VRAM policy is nine rules stacked in one 789-line function, and "small card" is decided at fifteen places with six different cut-offs (4.5 to 8.5 GiB) on three different quantities. The per-class budgets add up to 93 to 97% of the allowance before anything else is allocated. There is no ledger of what is allocated where (about 70 raw allocation sites in 15 files; #1339 starts one). Each temporary render target is a separate image keyed by its address, and a 4090 made 4,833 and destroyed 4,740 of them in 8 minutes. The address-keyed texture is behind the leak (#1443, #1462), the ASTC re-decode on area loads (#1069, #1222) and the trouble with the game's heap moving (#1478).
Synchronisation. One global all-commands barrier is used everywhere, every image stays in the GENERAL layout, and a 4090 gameplay frame records about 500 full barriers against 167 the game asked for. One queue carries game work, uploads, readbacks, sparse binds and the present copy, which is the Alt+Tab hang class (#316, #1376, #1355; fixed for now in #1458).
Device loss is mostly an AMD and Intel matter, and rarely about VRAM: 43 of 281 field logs end in a lost or hung device (AMD 30 of 120, Intel 11 of 17, NVIDIA 2 of 144), and only 4 of 41 were over 97% VRAM at the end. Losing the device ends the game.
CPU. The replay is a serial interpreter: 4.0 to 5.6 µs a draw on a 4090 and 9.5 to 12 µs on a 5600X, a Steam Deck or an old Xeon. Descriptors are rebuilt for 85 to 97% of draws. Everything loaded for shaders stays in memory until the game exits; on a 16 GB PC private memory grew from 2.9 to 5.1 GB over eight areas (#388). The host's wait-and-wake layer is 13 to 16% of sampled CPU, and on Linux the emulated Windows lock is a read-write lock that never spins and every wake is a system call. Speed is not the only reason, though: on a strong desktop the measured ceiling for any renderer change is near 17% in Kokiri Forest. The bigger costs are bugs and the time it takes to change anything safely.
Metrics. The dashboard's 1% low reads about 50 fps on a run that holds a perfect 60, and the farm's p99 at a 60 cap is the 13th slowest frame. We cannot judge a rewrite with numbers like these.
What other projects did
No comparable emulator or port replaced its whole renderer in one cut. yuzu, Dolphin, Ryujinx, Citra and RPCS3 each replaced one subsystem at a time, or added a second implementation behind a seam, while they kept shipping. The big replacements were long: yuzu's shader recompiler was 770 commits over about six and a half months and invalidated every player's shader cache, and RPCS3's renderer redesign took about two years; its author said bugs crept in as conflicts were resolved in that long-lived branch. Dolphin replays recorded frames for every commit on every back end and compares image hashes; that is the safety net we are missing.
We already have the seam they had to build: the renderer interface in
vk_api.h. Its rendering half (29 renderer functions, 26 host functions, 51 opcodes) is clean in shape today, though what it means around capture, write-back and present is not written down.What we keep
gpu/vk/eden, about 44,000 lines, 90% unchanged since it was imported) andsirit. Its fixes mostly encode game knowledge and it is not where the bugs are.sizeof(Program); in a review run on a Steam Deck a struct change forced 251.6 s of re-preparation).The plan
Step 0: nets and measurement, no change in behaviour.
Step 1: the leaves move out. Menu, settings, translations, upscalers, tools, bug report, telemetry and the pacing UI become modules with their own interfaces. About 30% of the renderer's C++ lines are upscalers, menu and tools.
Step 2: the core, one piece at a time, each one a second implementation that is chosen at run time:
vk_draw.cpp: hash and cache with an explicit key version, and pipeline binaries where the driver has them.Rules for every piece:
Beside the renderer: the host's CPU layer (a Linux lock shim that spins before it sleeps, fast paths for events and waiting on several objects, virtual cores without one global lock, one thread registry and budget instead of 96 creation sites and about ten CPU-count rules), and the translation measurements below.
Measured first, and what each result decides
How we stop regressions
What this is not
Open questions for the team
New on this forge; not opened on GitHub.
Possibly related, for context:
I corrected the description after the full synthesis and the issue drafts checked its numbers against the reports and against main. What changed:
sizeof(Program).The concrete pieces are filed so far as #1503, #1504, #1505, #1506 (the CPU and host track) and #1507 (lifter barriers). More follow as they are checked.
I added a section on how this fits HumanBean's Renderer rework plan, which I should have linked from the start: this issue agrees with it (rework behind
vk_api.h, the old path selectable until the same pictures on recorded traces) and is meant to feed it. It also lists the work already in flight it builds on (#1034, #1339, #1121, #1340, #1309, #1300, #980, #1288, #1113, #1198) and the three points where it differs, for the plan's owners to decide: the menu, settings and upscalers out of the renderer interface, descriptors as their own piece, and record and replay first.This is the second pass on this issue. The description above is the first pass, written while the research reports were still coming in and corrected on 18 Nov. This comment follows the full synthesis of the nine reports and the issues filed from them. It keeps the first pass's shape, replaces every number that turned out wrong, says where each item now lives, and lines the proposal up with HumanBean's Renderer rework plan; where we differ from it, its owners decide. The nine reports follow as comments of their own.
TL;DR
We still propose to rebuild the renderer's core one slice at a time on main, behind
vk_api.h, keeping the old path until recorded traces show equal pictures. It fits the rework plan's tracks and rules; the plan's owners decide where we differ. The safety net comes first: record and replay, counters, and measurements that can tell a regression from noise. The payoff is stability, memory, start-up and slow PCs, not fps on strong PCs, where the measured ceiling is near 17%.Breakdown
vk_api.h, cache formats, upscaler engines, the VMA wrapper.What changed since the first pass
sizeof(Program)(#1510).HOS_POLL_SLEEP_NScan only shorten a sleep, so it cannot stretch a 20 microsecond poll; the "1 to 2 ms" was the whole sleep and timer category (#1506).Why
Numbers are from the research pass unless an issue is named. Field numbers come from player logs attached to bug reports or about two days of consented summaries: leads, not verdicts.
The code grew fast and has no layers
gpu/vkwas 17,001 lines on 6 Nov, 42,551 on 10 Nov and 85,766 on 17 Nov.vk_draw.cpp11,712,vk_replay.cpp7,417,vk_memory.cpp6,917,vk_menu.cpp6,774,vk_texture.cpp5,721.vk_draw.cppwas in 213 landed changes by 50 authors in 12 days.RendererorTextureCacheobject: 1,111 file-scope variables, about 155 mutex declarations and 11 lock-order rules that exist only as comments.It breaks in the same places
draw()is 804 lines and was changed by 62 commits, 29 of them fixes..cppcode that a rewrite would replace; 2 are indevice_policy.h.We cannot see regressions before players do
vk_*.cppfile as text and 278 cut functions out of it by text. None includes one of the 39 translation units, where 89% of the fixes land. Only 10% of fix commits bring a test that runs real code.Memory and VRAM have no accountant
Hardware divergence is where players are hurt
Speed: what we can honestly promise
Our measurements cannot see it
What other projects did
No comparable multi-contributor project replaced a whole renderer in one cut. yuzu, Dolphin, Ryujinx, Citra and RPCS3 each replaced one subsystem, or added a second implementation behind a seam, while they kept shipping. The long replacements were slow (yuzu's shader recompiler took 770 commits over about six and a half months and invalidated every shader cache; RPCS3's redesign took about two years), and only RPCS3's author tied bugs to conflict resolution in a long-lived branch. Dolphin replays recorded frames per commit and back end and compares image hashes, which is the net we lack.
What we keep
vk_api.h: 29 renderer functions, 26 host functions and the 51-opcode op stream; 50 of those 55 are from the first commit.sizeof(Program)out of the key so a struct change does not re-prepare every player's shaders.How this lines up with the rework plan
Merged on the plan's side: crash grouping (#1288: 55 open crash reports in 16 groups, 27 of them a lost GPU device), the switch table and kill-switch deletions (#1300, #1309, #1390) and parts of 240 draws (#1484). Open and work in progress: the one-frame trace (#1334), and the budget line with host-write marking (#1339).
Where the filed items now live. PR #1542 (work in progress) carries them as one commit per issue, in order of risk. It is pushed with #1515, #1514, #1513, #1510 and the counting steps of #1509 and #1506; #1512, #1507, #1504, #1503 and #1505 follow in the next push, rebased on current main. Each commit has a game-free test that fails on main. The first six ran windowless on Linux with an RTX 4090, and a tester ran their fixtures and a smoke route on Windows. Nothing about speed or memory is measured yet. #1516 and #1517 to #1521 are not in it.
The plan's section 9 rules apply to every piece: the old path stays selectable until the same pictures on recorded traces, then goes in its own pull request; one area at a time in one file; numbers before and after for any change in speed or memory; no new switch outside the table; nothing made from the game leaves the PC;
MKWVK_API_VERSIONgoes up with every interface change.Where we differ, for the plan's owners to decide:
The plan
Step 0: nets and measurement (no behaviour change)
Optionsinto a config module, as one version bump. This alone removes the reason for about 20 of the 29 bumps.vk_draw.cpp).Step 1: leaves out
Tools and diagnostics, menu and UI, the upscaler and frame-generation hooks and the final passes move into modules with their own interfaces, struct in and struct out. About 18,000 of 60,906
.cpplines are leaves. This follows the config split (57Optionsfields are read by 18 files outside the menu) and precedes any hot swap of the core.Step 2: core slices
Each slice has an entry rule (interface with a fake, old code wrapped and hash-equal, facts as data, an owner, a removal date), an exit rule (hashes equal per GPU class, its gates, a nightly period with no worse crash, device-lost or over-budget rate) and its own deletion pull request.
a. Resource manager (A). One ledger and budget controller, one small-card policy, an aliasing arena for render targets (after its measurement), a content-keyed texture cache with an explicit state per image, one retire queue in place of 15 hand-written dead lists. Programs and pipelines get a release rule under pressure (#1509), and the colour-image format list is decided with the arena (#1512). Exit: transient targets stop being made new every frame; no render-target growth in a 2-hour soak.
b. Sync (C). Per-resource tracking or one barrier batcher, renderer-owned passes first; a present queue never shared with game work; bounded GPU work per submission; a device-lost path that restarts the renderer at the next present. It starts with the barrier measurement on AMD and Intel.
c. Descriptors (D). A bindless table matching the game's own texture and sampler tables; 85 to 97% of draws cannot reuse their neighbour's descriptors today. We expect nothing on strong PCs: the exit is "not slower, and better on slow cores", after the per-draw cost is priced and the minimum GPU decided.
d. Pipelines (D, E). The pipeline code (about 3,900 lines) leaves
vk_draw.cppfirst as a mechanical move. Then hash-and-cache with an explicit key version, pipeline binaries where the driver has them, one policy for wait, skip and fallback, and no silent drop of a draw that writes memory. The first run invalidates caches once, on purpose.e. Replay path and the memory and time model (B). Last, because it needs the measurements. Classify each guest range once (upload ring, readback, GPU-private) instead of capturing, mirroring and diffing everything, starting in a shadow mode that only logs where the new classification would differ. #1516 (pools with no CPU access are GPU-only from creation) is its first small step. #1513 to #1515 are three more places where the host answers differently from the console: a report call with no handler, render enable also skipping compute dispatches, and a wait on a never-fenced sync that answers timeout where the console answers failed. #1513 to #1516 come from a private study of the console driver (read, then confirmed by running the driver's functions alone in an emulator); no code, addresses or game data from it are here. Each has a game-free test that fails today. In the runs so far the render-enable counter stayed at 0, and the Windows route saw no report-value or never-fenced wait.
Beside the renderer
Measured first, and what each result decides
None of these has been run. Each can change the plan.
game_ms. Decides whether the lifter track starts with compiling hot giants whole or with locals as a proper pass.RADV_DEBUG=nodccon RDNA 3 as a ceiling. Decides whether the list is a small fix or part of the target design.How we stop regressions
presentreturns changes game behaviour above 60 fps (#1519). Those sites go in the corpus and in a gate. New modules are tested through their interface with a fake.What this is not
Open questions for the team
Research report: The architecture of the current renderer
This report maps the renderer as it was on main on 17 Nov: its modules, the dependency graph, global state, threads, locks, the interface to the host, switches, biggest functions, what changes together, how it is tested, and where it could be cut. It was read from a clean checkout with scripts that count files, symbols and history; nothing was built or run. The symbol graph comes from a parser without a compiler, so its counts are good to a few percent.
What it found
gpu/vkis 172 files and 85,766 lines (39.cppwith 60,906, 132 headers with 24,033), against 42,551 lines on 10 Nov and 17,001 on 6 Nov.vk_draw.cpp11,712,vk_replay.cpp7,417,vk_memory.cpp6,917,vk_menu.cpp6,774,vk_texture.cpp5,721. Each is 8 to 20 unrelated things. Only about 3,500 lines ofvk_draw.cppare the draw path; the rest is pipeline building, the on-disk pipeline cache, shader preparation (1,624 lines), samplers and diagnostics (1,061).vk_internal.hdeclares 183 functions of nine.cppfiles, and 17 headers rebuild 34 of the 39.cpp.Renderer,TextureCacheor memory-manager object.sizeof(Program).Optionsstruct is read by 18 files outside the menu, and the render-thread decision is made insidevk_menu.cpp.vk_draw.cpp. 86 functions of 100 lines or more hold 31.5% of function lines;drawis 804 lines with 325 branches and 27 environment reads.gpu/vksource as text and 127 of which cut a function out by its text. No test links the renderer, and there is no on-disk capture of the command stream.Optionsis a config struct. Not cuttable by moving code: the memory and time model, the per-draw path, the execution-mode matrix and the persisted layouts.What it means for the plan
Optionsa config module; this removes the reason for about 20 of the 29 bumps. It is the plan's track F plus the service-ABI split.vk_draw.cpp. Slices a and e own the memory model.What it could not establish
Corrections since it was written
sizeof(Program)(#1510).Research report: Where and why the renderer breaks
This report mined the first 11 days of the renderer's history (950 commits touching
gpu/vk), both trackers through the forge's read-only API (2,137 issues, 1,375 of them in the renderer area), and the test suite as a checkout. Commits and tracker items were classified with a model and spot-checked by hand (55 of 60 answers agreed); line-level overlaps come fromgit blame. No game, GPU or build was run, so everything here is read from history, text and counts.What it found
vk_draw.cpp258 commits (150 fixes),vk_replay.cpp227 (109),vk_texture.cpp122 (76).draw()(804 lines) was changed by 62 commits, 29 of them fixes;texture_frame()(789 lines) by 52;create_device()by 53;do_present()by 41..cppcode, 28 in the recompiler and 2 indevice_policy.h; 118 came with a test that pins the fact. Fix messages name AMD in 150 cases, NVIDIA in 106 and Intel in 42.vk_*.cppfile and 278 cut text out of it; 135 readvk_draw.cppand 116vk_replay.cpp. No check includes one of the 39 translation units, where 89% of fixes land. 84 of the 85 plain policy headers are run by checks. Only 10% of fix commits bring a test that runs real code; 35% bring a cut-and-compile fixture and 30% none.What it means for the plan
vk_draw.cppbreaks up to 135 checks and ofvk_replay.cpp116.What it could not establish
Corrections since it was written
Research report: Where the renderer spends CPU time and RAM
This report gathers what is known about the renderer's CPU cost per frame, the RAM it holds and its start-up cost. It combines code reading with the team's retained lab runs (an RTX 4090 with an i9-13900K on Linux, main of 11 and 12 Nov, with and without a profiler), the plan's later measurements, field summaries and every performance thread on the tracker. No new game runs were made; numbers are re-computed from retained logs and say which build they came from.
What it found
drawis 52 to 61% inclusive, the NVIDIA driver 25 to 28%,build_descriptors23 to 25%,program_for8 to 11%. 100perf(...)commits touchedgpu/vkin 11 days, each recovering 0.1 to 0.5 ms.build_descriptorsshare is 18, 25, 27 or 35% depending on the denominator.What it means for the plan
RX_VK_PROF_FINEoutput is not in any report. Expect nothing on strong PCs and a gain on slow cores.What it could not establish
Corrections since it was written
Research report: How the process uses the CPU
This report maps every thread the process runs (game, host and renderer), what decides how many there are, what a frame waits for, and where the host's locks, sleeps and spins cost time. It read the host and renderer code on main of 17 Nov and the one published CPU profile (Windows 11, Ryzen 7 5700X3D, 11 Nov build, synchronous mode), plus lab notes and tracker threads from other machines. Nothing new was measured; each number below names its machine through the evidence it came from, and estimates are marked as estimates.
What it found
RX_VK_PARALLELwas slower in five tests (10 to 30%).gpu/vk, 49 inhost/) and about ten CPU-count rules in eight files; the policy header computes three values that nothing reads.What it means for the plan
What it could not establish
Corrections since it was written
HOS_POLL_SLEEP_NScan only shorten a sleep, so the planned A/B (100 microseconds against 20) cannot be run as written; a stretch rule has to be written first (#1506).copy_lockshare is one profile on one machine (#1504).Research report: GPU handling and VRAM
This report looks at what the GPU is asked to do in a frame, how queues, barriers and descriptors are handled, how VRAM is budgeted and evicted, and how device loss ends. It was read from main of 17 Nov, from 393 player logs attached to bug reports (so biased toward trouble) and from retained lab logs on an RTX 4090, plus the tracker. Nothing was built or run for it; the figures are counts from code, logs and threads, and the vendor behaviour is read, not tested.
What it found
texture_framecombines a size budget by card, a dynamic floor, a 90% rule, hold and reserve lines, a 97% count line, the driver's refusals, a Windows commit reserve and a Linux pressure hold bymin(). 322 of the repository's 2,558 commits touch the memory files.vk_memory.cppis 6,917 lines (from 1,653). Readbacks cost 0.3 to 1.4 ms a frame on an RTX 4090, and #1268 saw 270 to 460 ms stalls after a burst of uploads.What it means for the plan
What it could not establish
Corrections since it was written
Research report: How the game's ARM64 code becomes running PC code
This report follows the lifter and its output: how the game's code is turned into C, what that C costs on the CPU, how the game talks to the renderer, and what a faster or safer lifter could buy. It read the lifter, its wrappers and the runtime on main of 18 Nov, ran the project's own census scripts over the lifted tree and over the relocated code image (counts only, nothing copied), and used the published CPU profile and the tracker threads for timings. No game was run and nothing was built.
What it found
-O1into 492.6 MB of x86, 6.8 times the guest code: 14 to 15 minutes on 24 threads and 14 to 15 GB of memory, and much longer on a Steam Deck. No game code can ship, so all of it has to fit a player's build.LONGSHOT_SPLIT_GIANTS(on since #385) compiles every lifted function of 256 KB of C or more (362 functions, 259 MB, 16.8% of the C) as pieces of about 8 KB under aswitchloop. 30 of the 100 hottest functions and 15 of the top 50 are such giants. 133,140 of the 224,995 jumps inside giants cross a piece (59%), and every piece starts from the context in memory. A forge profile put the giants at 18 of 61 ms of translated-code CPU a frame in the Market (#1020). #385 timed two functions (2 to 3% faster per call); no run of the switch off on a CPU-bound scene was found.game_mswent up on both PCs that reported it. Compile time rose 66% (298 to 494 s on 24 threads).dmb ishld,dmb ishst) need only a compiler barrier on x86-64 (921 with two rarer forms). No test pins the ordering the lifter writes (#1507).-O2costs a 23:25 build against 3:29 for +2.7% fps.runtime/floatat 6.1 to 7.4% of a core and vector registers that live in memory; a sibling port keeps eight of them in host registers.What it means for the plan
game_ms). It decides whether the lifter work starts with compiling hot giants whole or with locals as a proper pass.What it could not establish
Corrections since it was written
LDARandSTLRbecome plain loads and stores with no compiler ordering, a latent hazard that a higher optimization level would widen. That is wrong on main:nx2/insn.pyreplaces the translator's text for them, so they are sequentially consistent atomics (the store followed by its page mark), acquire loads forLDAPR, and sequentially consistent operations for the atomic update forms and the exclusive pair. The hazard is withdrawn. What stands is the fence count (919 need only a compiler barrier) and the missing test of the lifter's ordering.Research report: Frame pacing, fps and the performance metrics
This report follows how a frame is timed from the game's present call to the screen, where each fps and frame-time number in the project is computed, how the farm's frame-time gate behaves, and what the field statistics can and cannot say. It read the host and renderer code on main of 17 Nov, re-computed the farm's reports for #1458 and #1462 and simulated their frame histograms, and read the field data (30 days, all builds, read on 18 Nov) through the team's field-data helper. Nothing was run in a game or on a GPU; Windows paths and the frame-generation makers were read, not exercised.
What it found
presentreturns (#1519).What it means for the plan
presentreturns has to keep that behaviour (#1519).What it could not establish
Corrections since it was written
Research report: How other projects designed and replaced their renderers
This report asks how comparable renderers are designed, how they organise code for many contributors, and how they handled big rewrites: RT64, yuzu (read through Eden), Ryujinx, Dolphin, Citra and Azahar, RPCS3, Xenia, shadPS4, Granite, DXVK and Fossilize. It read shallow and history-only clones, counted lines and commits with scripts, and read the projects' own blogs, issue threads and pull requests. Only ideas were taken, never code, and nothing about Longshot was run: the Longshot numbers come from the other reports.
What it found
gpu/vkhas 85,766 top-level lines with the guest-facing and host-facing halves interleaved in a few files. Its op stream behind the versioned interface is the seam it already owns..cpplines are not translation work: upscalers and frame generation 9,036, menu 7,610, bug report, crash window and dumps 1,738: 18,384 of 60,906. The likeliest leaves.What it means for the plan
What it could not establish
Corrections since it was written
An outside audit of a fork's changes reached us today: a list of 20 changes it recommends for Longshot, plus ten smaller ones. It says itself that nothing in it was built or run and that its figures come from comments in the fork's source. I checked each claim against main (
430eef4f2) and against the forge. None of its numbers was reproduced, so they stay leads here, and none is repeated in this comment. The fork's public source is at git.triforceproject.com/triforce/source.What the check found
Of the 20 recommended items, 16 are true of main as the audit describes them, 3 are partly true and 1 is already fixed. Of the ten smaller items, five are true of main and four are partly true; one was not re-read. "True of main" only means the audit's statement about our code is right. It does not mean the fork's gain would show up here.
What it adds to the plan, by track
The tracks and slices are the ones in the wiki plan and in this issue.
Seven issues are opened for these items: #1606 (the upscalers' inputs), #1607 (a torn re-upload), #1608 (identical re-uploads), #1609 (the program pick's stage decode), #1610 (the region-free race), #1611 (the shader cache stamp), #1612 (DLSS creation after an out-of-memory failure).
What duplicates existing work
What stays a lead only
Several items are about pacing, the step the game takes per frame, descriptor reuse, view lookups and the pipeline cache file. They fit slices c and 2, the pacing issue #1519 and the budgets track, but each needs a measurement on our own code before anything changes. Pacing items go into #1519 as measurement ideas, not as changes.
How we act on it
The fork is outside reference only. Our rule for every item:
What this does not claim
No speed claim is made anywhere. Each issue that could change timing asks for a paired run after a main-against-main null pair, as the gates in this issue require. The seven issues were checked against all the open pull requests and issues on the forge on 18 November; the duplicates above are the ones found.
🔬 Windows numbers for the CPU track: all lifted chunks at
-O2were +10% in the Market and +7% in Hyrule Field on an RTX 4070 with a Ryzen 9 7900X (six timed pairs), and the cloth alone held King Zora's spot in Zora's Domain. This is written as a section for the wiki's Performance: what to fix next under its item 4; I don't have write access to the wiki. Could someone who does add it there, with one line beside the-O3entry in "Tried and ruled out": (Linux, RTX 3090. On Windows with an RTX 4070, all chunks at-O2gave +7 to 10% in the Market and Hyrule Field: see item 4 measured on Windows, above.)Item 4 measured on Windows (RTX 4070, Ryzen 9 7900X), 2026-11-18
From #1485 (Zora's Domain slows down near King Zora). One PC: Windows 11 Pro (26300), RTX 4070 12 GB (NVIDIA 616.56), Ryzen 9 7900X, 64 GB; output 2560x1440 in a 1280x720 window, Quality preset Auto (tier 4, the game's own upscaler), frame generation off, cap 240. Builds: dev packs over a
310e7c9dbase, the "-O1" side as a player's build has it (no hot list: every lifted chunk at-O1).All lifted chunks at
-O2(LONGSHOT_CHUNK_OPT=all, 6 MB parts) with the cloth gate on, against-O1with it off. Six interleaved pairs in the job queue's timing mode, each a teleport arrival settled 12 s and measured over 20 s by the game's frame counter:-O1-O2In the Market and Hyrule Field 5 of the 6
-O2runs are above the best-O1run; the sixth (the third run) fell inside-O1's range at all three spots, before outside load was recorded. In runs 4 to 6 the PC had 1.0 to 1.8 cores busy outside the game on both sides. The pack built in 7:54 here (5:52 of compiling). Run records:docs/tested/2026-11-18-cloth60-o2-enum-*.md(#1630).This differs from the Linux result above ("all game code at
-O3on its own: no fps"): on this PC the game's loop, not the render chain, seems to hold the frame in these scenes, so a faster loop shows in fps. Not checked withRX_VK_FRAME_TRACEyet.Cloth alone. At the stairs behind King Zora the frame is held by the cloth: the main thread waits 77% of the time for the job workers, and the cloth solve (
f_81b47080) is 45.7% of the workers' game code there against 15% on the path below, about 10.5 ms of CPU a frame against about 2 (all-thread samples, 10 s each). Inside the solve, 30% of the time is the float helpers (a64_fpx_mul32_fma32alone 8.6%, the slow exactrecomp_fpe_fma323.3%) and most of the rest the lifted code, a third of it in one split piece of its hot routine (f_81b5a3c0, 32.5%). Only the cloth's chunks at-O2(7 chunks, 17 functions covering 97% of the cloth's lifted samples, 2:39 to build) took that spot from about 54 to about 66 fps, and all chunks at-O2to about 72. These stairs numbers are hand readings (the bridge can't walk Link there), not timed pairs.The cloth gate (#1628,
HOS_FPS_CLOTH_60=1): above a 60 cap it solves the cloth at most 60 times a second, so it keeps the clock (it ran fps / 60 times too fast). Three interleaved pairs at the same spots,-O1, the gate off against on: no fps change (Market 68.1 -> 68.7, Hyrule Field 94.1 -> 95.3, Zora's Domain 89.6 -> 89.8, all within the spread; 1.8 to 4.3 cores busy outside the game). Where a frame is already slower than 60 (the King Zora stairs on this PC) there is nothing for it to skip.Not tried yet: the cloth and physics functions on a hot list (
A64_HOT_FUNCS, for the float helpers' inline fast paths), andLONGSHOT_SPLIT_GIANTSoff for the cloth's hot routine.@mooki, a heads-up on your Step 1 and point 6 (the menu and settings out of the renderer, the options struct a config module the menu owns): I've opened #1633 for the menu's part of that, and I'm claiming it unless you already have work or a design for it.
In short: a settings model with no ImGui in it, each setting described once with an explicit ini key and its own hooks (shown, locked, step, change), modules registering their own rows with
after/before/ weights that are sorted at start-up, and the ImGui menu becoming one presenter of the model's snapshot (so the game's own menu could present it later). Six steps, each changing nothing a player sees, the first an ini-key freeze.If you'd shape it differently to fit the rest of #1493 (where the module should live, how it talks to the host), say so and I'll follow your plan.