Renderer rewrite #1493

Open
opened 2026-11-18 00:48:36 +00:00 by mooki · 15 comments
Member

Type: design · Scope: gpu/vk and the host layer it calls · Status: first pass, for discussion

TL;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

  • Why: five files hold 63% of the renderer's C++, 58% of its commits are fixes, and of the fixes that replace existing lines, 47% rewrite lines another commit wrote (40% within three days).
  • What we keep: the shader recompiler from Eden, the small policy headers, the versioned renderer interface (vk_api.h) and the cache formats.
  • Step 0, no change in behaviour: record and replay of the renderer's input, image hashes per GPU vendor, counters for VRAM, barriers and waits, frame metrics that mean what they say, fewer switches, and the menu's services split out of the renderer interface.
  • Step 1: menu, settings, translations, upscalers, tools, bug report and telemetry move out of the core into modules of their own.
  • Step 2, the core, in this order: memory and resources, synchronisation, descriptors, pipelines, and last the replay and draw path.
  • Beside it, outside the renderer: the host's CPU layer (locks, waits, virtual cores, threads) and two translation measurements.
  • What we need from the team: an owner per piece, agreement on the gates, and a test machine per GPU vendor.
  • How it fits: it builds on HumanBean's Renderer rework plan and the work already in flight; where they differ, the plan's owners decide.

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.h stay, 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 of vk_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/vk without 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) and vk_texture.cpp (5,721). Only about 3,500 lines of vk_draw.cpp are the draw path; the rest is pipeline building, the pipeline cache, shader preparation, samplers and diagnostics. The function draw alone 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_memory or vk_texture. 17 headers, including tuning rules, rebuild 34 of the 39 .cpp files.

Fixes of fixes. 950 commits from 167 authors touched gpu/vk in 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 .cpp code and only 2 in device_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.def has 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_*.cpp file 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

  • The shader recompiler (gpu/vk/eden, about 44,000 lines, 90% unchanged since it was imported) and sirit. Its fixes mostly encode game knowledge and it is not where the bugs are.
  • The header-only policy files. 84 of the 85 plain policy headers are run by checks today.
  • The versioned renderer interface as the seam every new piece plugs into.
  • The cache formats on disk. They change only on purpose, with a version number, never as a side effect (the shader cache key still hashes sizeof(Program); in a review run on a Steam Deck a struct change forced 251.6 s of re-preparation).
  • The driver and game knowledge from the fixes, moved into data tables with tests before any piece replaces the code that holds it.

The plan

Step 0: nets and measurement, no change in behaviour.

  1. Record and replay. Record the renderer's calls, its command streams and the guest memory pages they read, and replay them in the synchronous mode against either implementation. The size per frame is an open question: an estimate of the page changes is about 36 MB a frame, not measured yet, and the one full frame recorded so far was 2.0 GB. Recorded frames come from the game, so they stay private to testers; only their hashes go in the repository.
  2. Image hashes per GPU vendor and per commit for that corpus.
  3. Counters that are always on and cheap: VRAM by class (a ledger), barriers per frame, fallback mesh draws, render pass breaks, and what each thread waited on.
  4. Frame metrics that mean what they say: one definition of 1% low and p99, and the pacing gates from the pacing report.
  5. Fewer switches: diagnostics in one registry, and every kill or attempt switch gets a removal date.
  6. Split the interface into renderer calls and host services (menu, input, audio, NFC, settings), and make the 85-field options struct a config module the menu owns.

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:

  1. Resources and memory: one ledger, one budget controller and one small-card rule; a reusable pool for the game's temporary render targets (once the alignment measurement says it fits); a texture cache keyed by content, with an explicit state for each image.
  2. Synchronisation: barriers tracked per resource or batched in one place, a present queue that is never shared with game work, bounded GPU work per submission, and rebuilding after a lost device instead of exiting.
  3. Descriptors: bindless tables that match NVN's own texture and sampler pools, instead of rebuilding sets per draw.
  4. Pipelines, out of vk_draw.cpp: hash and cache with an explicit key version, and pipeline binaries where the driver has them.
  5. Last, the replay and draw path and the guest memory model: classify each guest range once (upload ring, readback, GPU only) instead of capturing, mirroring and comparing pages every frame.

Rules for every piece:

  • It lands on main in small pull requests. No rewrite branch lives longer than a pull request.
  • Entry: the corpus replays on the old path, and the piece's counters exist.
  • Exit: image hashes equal on NVIDIA, AMD and Intel (or each difference explained), paired timing not worse under the quiet rule, the VRAM ledger not worse.
  • Deletion: the old path is removed on a date written down at exit, and its switch with it.

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

  1. The giant-function split in the lifted code, on and off, on a CPU-bound scene (with #1469's build beside it). It decides whether the translation work comes before the renderer for slower PCs.
  2. AMD's colour compression with a format list (a run with it turned off by the driver against one with it on). It decides whether changing how colour images are created is worth it.
  3. Vulkan alignment against the game's own alignment for render targets. It decides whether the reusable target pool is possible.
  4. Whether the game flushes the memory it writes (the flush hook is empty today). It decides how guest ranges can be classified.
  5. Threaded rendering chosen from measured stage times instead of the CPU count. Auto turns it on at 12 processors today, and forced on a Steam Deck it was 31% and 13% slower.
  6. The metrics themselves, checked against runs with a known answer before anything is judged with them.

How we stop regressions

  • The replay corpus, private to testers, with hashes in the repository, run per commit on each vendor we have a machine for.
  • Paired timing for any speed claim, after a main-against-main null pair on the same machine shows the scene can tell the difference (the farm's gates today are as noisy as the changes they judge).
  • Tests that run the code: each piece comes with fixtures that compile and execute it, not checks that read its source as text.
  • Checks that gate: a red check on main is fixed or removed the same day.

What this is not

  • Not a rewrite on a branch, and not a feature freeze.
  • Not a change of the shader recompiler.
  • Not new switches without a removal date.
  • Not a new minimum Vulkan version by accident: other projects' rewrites raised theirs, so if a piece needs an extension we decide it here first.

Open questions for the team

  1. Who wants to own a piece? Step 0's record and replay is the first one, and nothing else can start before it.
  2. Are these gates the right ones, and is "equal image hashes or an explained difference" strict enough?
  3. Who can run the corpus on AMD and Intel machines regularly?
  4. Do we keep both the synchronous and the threaded execution modes in the new core?
  5. Where should the private replay corpus live, and who may hold it?

New on this forge; not opened on GitHub.

**Type:** design · **Scope:** `gpu/vk` and the host layer it calls · **Status:** first pass, for discussion ## TL;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 - **Why:** five files hold 63% of the renderer's C++, 58% of its commits are fixes, and of the fixes that replace existing lines, 47% rewrite lines another commit wrote (40% within three days). - **What we keep:** the shader recompiler from Eden, the small policy headers, the versioned renderer interface (`vk_api.h`) and the cache formats. - **Step 0, no change in behaviour:** record and replay of the renderer's input, image hashes per GPU vendor, counters for VRAM, barriers and waits, frame metrics that mean what they say, fewer switches, and the menu's services split out of the renderer interface. - **Step 1:** menu, settings, translations, upscalers, tools, bug report and telemetry move out of the core into modules of their own. - **Step 2, the core, in this order:** memory and resources, synchronisation, descriptors, pipelines, and last the replay and draw path. - **Beside it, outside the renderer:** the host's CPU layer (locks, waits, virtual cores, threads) and two translation measurements. - **What we need from the team:** an owner per piece, agreement on the gates, and a test machine per GPU vendor. - **How it fits:** it builds on HumanBean's [Renderer rework plan](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/Renderer-rework-plan) and the work already in flight; where they differ, the plan's owners decide. ## How this fits the team's rework plan The wiki's [Renderer rework plan](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/Renderer-rework-plan) (draft of 16 Nov) already chose "rework, not rewrite": the lifter, the Horizon layer, the shader recompiler and `vk_api.h` stay, 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 of `vk_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/vk` without 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) and `vk_texture.cpp` (5,721). Only about 3,500 lines of `vk_draw.cpp` are the draw path; the rest is pipeline building, the pipeline cache, shader preparation, samplers and diagnostics. The function `draw` alone 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_memory` or `vk_texture`. 17 headers, including tuning rules, rebuild 34 of the 39 `.cpp` files. **Fixes of fixes.** 950 commits from 167 authors touched `gpu/vk` in 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 `.cpp` code and only 2 in `device_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.def` has 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_*.cpp` file 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 - **The shader recompiler** (`gpu/vk/eden`, about 44,000 lines, 90% unchanged since it was imported) and `sirit`. Its fixes mostly encode game knowledge and it is not where the bugs are. - **The header-only policy files.** 84 of the 85 plain policy headers are run by checks today. - **The versioned renderer interface** as the seam every new piece plugs into. - **The cache formats on disk.** They change only on purpose, with a version number, never as a side effect (the shader cache key still hashes `sizeof(Program)`; in a review run on a Steam Deck a struct change forced 251.6 s of re-preparation). - **The driver and game knowledge** from the fixes, moved into data tables with tests before any piece replaces the code that holds it. ## The plan **Step 0: nets and measurement, no change in behaviour.** 1. Record and replay. Record the renderer's calls, its command streams and the guest memory pages they read, and replay them in the synchronous mode against either implementation. The size per frame is an open question: an estimate of the page changes is about 36 MB a frame, not measured yet, and the one full frame recorded so far was 2.0 GB. Recorded frames come from the game, so they stay private to testers; only their hashes go in the repository. 2. Image hashes per GPU vendor and per commit for that corpus. 3. Counters that are always on and cheap: VRAM by class (a ledger), barriers per frame, fallback mesh draws, render pass breaks, and what each thread waited on. 4. Frame metrics that mean what they say: one definition of 1% low and p99, and the pacing gates from the pacing report. 5. Fewer switches: diagnostics in one registry, and every kill or attempt switch gets a removal date. 6. Split the interface into renderer calls and host services (menu, input, audio, NFC, settings), and make the 85-field options struct a config module the menu owns. **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: 1. **Resources and memory:** one ledger, one budget controller and one small-card rule; a reusable pool for the game's temporary render targets (once the alignment measurement says it fits); a texture cache keyed by content, with an explicit state for each image. 2. **Synchronisation:** barriers tracked per resource or batched in one place, a present queue that is never shared with game work, bounded GPU work per submission, and rebuilding after a lost device instead of exiting. 3. **Descriptors:** bindless tables that match NVN's own texture and sampler pools, instead of rebuilding sets per draw. 4. **Pipelines,** out of `vk_draw.cpp`: hash and cache with an explicit key version, and pipeline binaries where the driver has them. 5. **Last, the replay and draw path and the guest memory model:** classify each guest range once (upload ring, readback, GPU only) instead of capturing, mirroring and comparing pages every frame. **Rules for every piece:** - It lands on main in small pull requests. No rewrite branch lives longer than a pull request. - Entry: the corpus replays on the old path, and the piece's counters exist. - Exit: image hashes equal on NVIDIA, AMD and Intel (or each difference explained), paired timing not worse under the quiet rule, the VRAM ledger not worse. - Deletion: the old path is removed on a date written down at exit, and its switch with it. **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 1. **The giant-function split in the lifted code, on and off, on a CPU-bound scene** (with #1469's build beside it). It decides whether the translation work comes before the renderer for slower PCs. 2. **AMD's colour compression with a format list** (a run with it turned off by the driver against one with it on). It decides whether changing how colour images are created is worth it. 3. **Vulkan alignment against the game's own alignment** for render targets. It decides whether the reusable target pool is possible. 4. **Whether the game flushes the memory it writes** (the flush hook is empty today). It decides how guest ranges can be classified. 5. **Threaded rendering chosen from measured stage times instead of the CPU count.** Auto turns it on at 12 processors today, and forced on a Steam Deck it was 31% and 13% slower. 6. **The metrics themselves,** checked against runs with a known answer before anything is judged with them. ## How we stop regressions - The replay corpus, private to testers, with hashes in the repository, run per commit on each vendor we have a machine for. - Paired timing for any speed claim, after a main-against-main null pair on the same machine shows the scene can tell the difference (the farm's gates today are as noisy as the changes they judge). - Tests that run the code: each piece comes with fixtures that compile and execute it, not checks that read its source as text. - Checks that gate: a red check on main is fixed or removed the same day. ## What this is not - Not a rewrite on a branch, and not a feature freeze. - Not a change of the shader recompiler. - Not new switches without a removal date. - Not a new minimum Vulkan version by accident: other projects' rewrites raised theirs, so if a piece needs an extension we decide it here first. ## Open questions for the team 1. Who wants to own a piece? Step 0's record and replay is the first one, and nothing else can start before it. 2. Are these gates the right ones, and is "equal image hashes or an explained difference" strict enough? 3. Who can run the corpus on AMD and Intel machines regularly? 4. Do we keep both the synchronous and the threaded execution modes in the new core? 5. Where should the private replay corpus live, and who may hold it? New on this forge; not opened on GitHub.
Collaborator

Possibly related, for context:

  • issue #1113 Idea: Record and replay inputs for automated testing — Related request for recording/replaying gameplay inputs for testing
  • PR #1340 WIP: refactor(vk): the draw code's pure predicates move to draw_key.h, and their checks include it — Renderer rework initiative; extracted draw predicates and added real-code checks
  • PR #1309 refactor(vk): 111 kill switches are deleted, the host's switches join the table, and the per-PC decisions get one place and one rule — Merged renderer rework step removing switches and centralizing device policy
Possibly related, for context: - issue #1113 Idea: Record and replay inputs for automated testing — Related request for recording/replaying gameplay inputs for testing - PR #1340 WIP: refactor(vk): the draw code's pure predicates move to draw_key.h, and their checks include it — Renderer rework initiative; extracted draw predicates and added real-code checks - PR #1309 refactor(vk): 111 kill switches are deleted, the host's switches join the table, and the per-PC decisions get one place and one rule — Merged renderer rework step removing switches and centralizing device policy
Author
Member

I corrected the description after the full synthesis and the issue drafts checked its numbers against the reports and against main. What changed:

  • TL;DR and Breakdown: "most work on it is now fixing earlier fixes" overstated it. 58% of renderer commits are fixes; of the fixes that replace existing lines, 47% rewrite lines another commit wrote, 40% within three days.
  • Size: about 9,500 of the 85,766 lines are data or generated (translations, operand tables, the switch table).
  • Interface versions: 3 of the 29 commits that bumped the version were for rendering (it said "3 of the version bumps").
  • Memory: "small card" is decided at fifteen places, not nine (six cut-offs on three different quantities); #1339 already starts the ledger. One sentence that did not come from our own measurements is removed.
  • Shader memory: the "5.2 GB made before the title screen" was a start-mode number from before load-at-create became the default on 12 Nov. What holds today: everything loaded for shaders stays until exit (#388 has the 2.9 to 5.1 GB growth over eight areas).
  • Cache key: the 251.6 s on a Steam Deck was a review run of #223, fixed before it merged, not something players got; the key still hashes sizeof(Program).
  • Other projects: only RPCS3's author tied the bugs to conflict resolution in a long-lived branch.
  • Record and replay: the 36 MB a frame is an estimate of page changes, not a measurement; the one full frame recorded so far was 2.0 GB.
  • The interface: clean in shape; what it means around capture, write-back and present is not written down.
  • Timing: speed claims come after a main-against-main null pair, since the farm's gates are as noisy as the changes they judge.

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 corrected the description after the full synthesis and the issue drafts checked its numbers against the reports and against main. What changed: - **TL;DR and Breakdown:** "most work on it is now fixing earlier fixes" overstated it. 58% of renderer commits are fixes; of the fixes that replace existing lines, 47% rewrite lines another commit wrote, 40% within three days. - **Size:** about 9,500 of the 85,766 lines are data or generated (translations, operand tables, the switch table). - **Interface versions:** 3 of the 29 commits that bumped the version were for rendering (it said "3 of the version bumps"). - **Memory:** "small card" is decided at fifteen places, not nine (six cut-offs on three different quantities); #1339 already starts the ledger. One sentence that did not come from our own measurements is removed. - **Shader memory:** the "5.2 GB made before the title screen" was a start-mode number from before load-at-create became the default on 12 Nov. What holds today: everything loaded for shaders stays until exit (#388 has the 2.9 to 5.1 GB growth over eight areas). - **Cache key:** the 251.6 s on a Steam Deck was a review run of #223, fixed before it merged, not something players got; the key still hashes `sizeof(Program)`. - **Other projects:** only RPCS3's author tied the bugs to conflict resolution in a long-lived branch. - **Record and replay:** the 36 MB a frame is an estimate of page changes, not a measurement; the one full frame recorded so far was 2.0 GB. - **The interface:** clean in shape; what it means around capture, write-back and present is not written down. - **Timing:** speed claims come after a main-against-main null pair, since the farm's gates are as noisy as the changes they judge. 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.
Author
Member

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.

I added a section on how this fits HumanBean's [Renderer rework plan](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/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.
Author
Member

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

  • Why: 12 days old, 85,766 lines, five files hold 63% of the C++, 58% of commits are fixes, and no test runs its Vulkan code.
  • What we keep: the shader recompiler, policy headers, the render half of vk_api.h, cache formats, upscaler engines, the VMA wrapper.
  • Step 0, no change in behaviour: record and replay, counters and a ledger, one frame record, fewer switches, a split interface, driver and game facts as data.
  • Step 1: menu, settings, translations, upscalers, tools, bug report and telemetry leave the core.
  • Step 2: resources, sync, descriptors, pipelines, then the replay path and memory model.
  • Beside it: the host CPU layer (#1503 to #1506) and the lifter (#1507).
  • Measured first: nine experiments that can change the order.
  • Fit with the plan: its tracks T and A to F, its section 9 rules, and four points where we differ.

What changed since the first pass

  • Shader stock: the "5.2 GB made before the title" was a start-mode number from 11 Nov, before load-at-create became the default on 12 Nov. Today nothing releases programs, modules or pipelines in play (#1509).
  • Cache key: the 251.6 s on a Steam Deck was a review run of #223, fixed before it merged. The key still hashes sizeof(Program) (#1510).
  • Small card: fifteen places on three quantities, not nine (#1511).
  • Lifter ordering: acquire and release accesses are already sequentially consistent atomics on main, so the reported hazard is not there. A test is missing, and 919 of 3,823 barriers need only a compiler barrier (#1507).
  • Poll sleeps: HOS_POLL_SLEEP_NS can 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).
  • Farm and dashboard: the farm's frame log counts made frames too. The dashboard has no session ids by design; the relay counts real sessions, which the helper's sessions column does not (#1520).
  • Switches, flips, trace: #1309 deleted 111 kill switches and #1390 15 more. The write-back diff and present queue defaults were decided four times in three hours, not "five". 36 MB a frame of trace is an estimate.

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

  • Top-level gpu/vk was 17,001 lines on 6 Nov, 42,551 on 10 Nov and 85,766 on 17 Nov.
  • Five files hold 63% of the C++: vk_draw.cpp 11,712, vk_replay.cpp 7,417, vk_memory.cpp 6,917, vk_menu.cpp 6,774, vk_texture.cpp 5,721. vk_draw.cpp was in 213 landed changes by 50 authors in 12 days.
  • There is no Renderer or TextureCache object: 1,111 file-scope variables, about 155 mutex declarations and 11 lock-order rules that exist only as comments.
  • The interface went from version 1 to 33. Of the 40 host functions added, 34 serve the menu, and 3 of the 29 version-bumping commits were for rendering. About 31% of the code is not rendering. 681 switches are live and 139 removed.

It breaks in the same places

  • About 950 renderer commits in 11 days, 58% of them fixes.
  • Of the 477 fix commits that replace existing lines, 47% replace lines another commit of the same window wrote, 40% within 72 hours.
  • draw() is 804 lines and was changed by 62 commits, 29 of them fixes.
  • Defaults flip back and forth: the write-back diff and the present queue were decided four times in three hours on 9 Nov, and flipped again on 11 and 17 Nov.
  • 35% of the 552 fixes encode a fact about a driver, a GPU, an OS or the game. 161 of those 191 sit inside .cpp code that a rewrite would replace; 2 are in device_policy.h.

We cannot see regressions before players do

  • 424 of 731 Python checks read a vk_*.cpp file 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.
  • CI has not run the suite on pull requests since 13 Nov. 30 checks were red on main on 17 Nov, and the guide-screenshot and switch-table checks were red on 95% and 67% of main commits.
  • Of 1,375 renderer-area reports, 98 say "regression", and most name a release, not a change.

Memory and VRAM have no accountant

  • VRAM policy is nine stacked rules in one 789-line function. "Small card" is decided at fifteen places with six cut-offs between 4.5 and 8.5 GiB, on three different quantities (#1511). The static texture and mirror budgets add up to 93 to 97% of an assumed allowance before render targets, shadows and upscaler images.
  • About 1 GB of VRAM is attributed to no allocation (median 0.95 GB in field logs). #1339 counts every allocator buffer and brings the figure on one RTX 3090 from 426 to about 280 MB.
  • Everything loaded for shaders stays in memory until exit. On a 16 GB PC private memory grew from 2.9 to 5.1 GB over eight areas (#388).
  • Render targets are keyed by the address they sit at. On an RTX 4090, 4,833 images were made and 4,740 destroyed in 28,740 presents (about 8 minutes). In field logs kept tiles are 84% of the render-target images at the end, growing 211 an hour at the median (#1443; #1462 lets finalized targets go).
  • The game's memory is kept in step with the GPU by copying and waiting, across five files, with no owner.

Hardware divergence is where players are hurt

  • 43 of 281 field logs end in a lost or hung device: AMD 30 of 120, Intel 11 of 17, NVIDIA 2 of 144. The logs came with bug reports, so the rates are biased up; the vendor order is the finding. Device loss is fatal by design.
  • One queue carries game work, uploads, readbacks and the present: the class of the Alt+Tab hangs on AMD's Windows driver (fixed in #1458).
  • A gameplay frame on an RTX 4090 records 501.5 full barriers and drops 237.8 as duplicates; the game asked for 167. Four other scenes record 379 to 446. The cost on AMD and Intel is unmeasured.

Speed: what we can honestly promise

  • The replay costs 4.0 to 5.6 microseconds a draw on an RTX 4090 and 9.5 to 12 on slow cores (a Steam Deck, a 5600X). It decides the frame on slow cores and in the unthreaded mode.
  • On a strong PC with the render thread on, the plan's measurements (RTX 3090, Ryzen 9 7900X, 1440p) say a frame is the GPU's time plus 3 to 7 ms: the game waits once a frame for the GPU to finish the frame before, then signals, and nothing with draws can be recorded before that signal. The ceiling for any renderer change in one scene is about 17%. A frame-gate switch, a presenter thread, two presents ahead, a program-pick cache, descriptors by section and recording on four threads each gained nothing worth shipping; parts of 240 draws (#1484) did.
  • In the field the game's own part is 72.5% of a busy-scene frame and the renderer's 24%.
  • So we do not promise fps on strong PCs. The plan agrees: the heavy areas could reach the mid-80s to mid-90s, and more needs the game's own simulation or geometry to cost less.

Our measurements cannot see it

  • The farm's p99 over 20 s at a 60 cap is the 13th slowest of 1,200 frames. In a simulation, 12 frames of 25 ms leave it at 17.5 ms and a 13th moves it to 25.0 (+43%).
  • Same-build noise in one report was 11.3% in p99, 28.8% in the 1% low and 98% in the maximum, against gates of 10 to 20%. #1462 failed at +26.9% on one run a side while its two other reports passed (#1517).
  • A frame is stamped at six moments and none is scan-out (#1518); the farm's frame log counts made frames too and cannot say whether frame generation ran.
  • 52.4% of 80,270 field hitches have the cause "other"; "game" is the time nothing else claimed (#1521). The dashboard's 1% low reads about 50 fps on a perfect 60 (#1520).

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

  • The shader recompiler (about 44,000 lines, 90% unchanged since import), whose five-file interface is already a library boundary.
  • The policy headers (88) and their tests; 84 of the 85 plain ones are run by checks.
  • The render half of vk_api.h: 29 renderer functions, 26 host functions and the 51-opcode op stream; 50 of those 55 are from the first commit.
  • The persisted cache formats, changed on purpose with a version and a release note. #1510 takes sizeof(Program) out of the key so a struct change does not re-prepare every player's shaders.
  • The upscaler and frame-generation engines, with their hooks into the draw path named.
  • The VMA wrapper, the cleanest module.

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).

  • T, tools: Step 0. A, budgets: slice a (#1339, #1509, #1511). B, memory sync: slice e and the pool flags (#1516, #799).
  • C, frame pipeline: slice b and the threaded-mode choice (#1121). D, draw translation: slices c and d. E, pipeline preparation: slice d and the cache key (#1510). F, switches and capabilities: the table, one small-card classifier (#1511) and the per-GPU rules as data.

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_VERSION goes up with every interface change.

Where we differ, for the plan's owners to decide:

  1. Menu, settings and upscalers leave the renderer interface. The plan leaves them alone, but upscalers account for 52 fixes and most interface versions were menu services.
  2. Descriptors become their own piece, not part of draw translation.
  3. Slices that change behaviour wait for a trace that can show equal pictures; counters, tables and deletions do not.
  4. A CPU and host track and a lifter test, which the plan does not cover.

The plan

Step 0: nets and measurement (no behaviour change)

  • Record and replay, image hashes (T, M1). #1334 records one frame and plays it with no game. Once the trace carries the GPU-written images, the plan's notes show a played frame differing from the live one by 0.009, where two live sessions differ by 0.007 to 0.018. The first full frame was 2.0 GB; a minute of play is only estimated, at 15 to 30 GB, so the design needs one snapshot per scene and small deltas per submit. Hashes are kept per GPU and driver, linked to the parent version, with a human "accept" step. Recordings stay private; the repository holds hashes and a manifest.
  • Counters: a ledger of VRAM and RAM by class (#1339 starts it), barriers per frame, mesh-fallback draws, render-pass breaks, and one wrapper for the 25 or so places that block on the GPU.
  • One frame record and one clock (#1518), read by the counter, the field summary, the frame log and the Reflex markers; finer field buckets, queries without the title and loads, and honest hitch causes (#1520, #1521).
  • Fewer switches: one registry with owner, default, reason and a removal date for test switches (#1300, #1309 and #1390 are in; #1527 is open).
  • Split the interface into renderer calls and host services, and move the 85-field Options into a config module, as one version bump. This alone removes the reason for about 20 of the 29 bumps.
  • Driver and game facts as data: the 191 facts become rows with tests on made-up PCs, and one function classifies a card (#1511).
  • Suggested additions: the game-free suite on pull requests again, a software-Vulkan lane with validation, and a test migration plan before any split (135 checks read 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 .cpp lines are leaves. This follows the config split (57 Options fields 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.cpp first 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

  • Host CPU layer: in the one published Windows profile (an 11 Nov build; several costs are cut since) the host layer is 20 to 23% of sampled CPU and its wait and wake machinery 13 to 16%. #1503: a virtual-core gate without a global lock and a starve limit that follows the machine (a Steam Deck logged 184 waits of 50 ms or more, none with a 20 ms limit). #1504: a Linux lock shim that spins before it sleeps. #1505: signals that skip the wake when nobody waits (at most 0.3 to 0.8 ms of CPU a frame, unmeasured). #1506: measure the poll sleeps first. None claims an fps gain.
  • The lifter: the lifted code is 54 to 59% of on-CPU time. #1507 asks for a test of the ordering it writes and a compiler-only lowering for load-only and store-only barriers. #1469's gain is flat in the register count, which fits un-splitting giant functions, so the A/B below comes first.

Measured first, and what each result decides

None of these has been run. Each can change the plan.

  1. Giant-function split A/B: main, split off, and #1469 on one CPU-bound PC, comparing the lifted code's own CPU time, not game_ms. Decides whether the lifter track starts with compiling hot giants whole or with locals as a proper pass.
  2. Format list and DCC (#1512): count view formats on any GPU, check an RDNA 2 card, use RADV_DEBUG=nodcc on RDNA 3 as a ceiling. Decides whether the list is a small fix or part of the target design.
  3. Render-target alignment: NVN size and alignment against Vulkan's. Decides whether slice a gets the arena.
  4. Does the game flush what it writes? Flush calls against the pages the write watch reports. Decides whether flush hooks can replace the page watch for upload rings.
  5. Threaded-mode choice: one CPU held to 4 up to 24 processors. Auto is a guess at 12 today: +17% on a 5600X, 6% less frame time on a 7900X, 31% and 13% slower on a Deck forced on.
  6. Pacing metrics (#1517): the null pair, the six moments with PresentMon, a farm cell that proves frame generation ran. Decides the gate thresholds.
  7. Barriers on AMD and Intel: is slice b worth doing for sync, or only for the present queue and device loss?
  8. Replay twice and its size: the one-frame trace answers part; no minute-long trace exists.
  9. Poll sleeps (#1506): which polls are idle and which are on the critical path.

How we stop regressions

  • A replay corpus, private, with hashes and a manifest in the repository; each farm machine can record its own.
  • No gate before its null pair. A threshold is the larger of the nominal limit and 1.5 times the same-build spread on that rig and scene, printed with every result (#1517; the farm's side is Beanstalk #88). Until the pair exists, frame-time gates are advisory.
  • Candidate gates: a deterministic windowless lane (median at most 1.02 times old, valid when the same build agrees within 5%), a capped windowed lane, the present path, a cold shader cache, a 2-hour soak. p99 is reported but never a gate alone; the mean of the slowest 1% moves smoothly where p99 jumps.
  • Game time is not the renderer's. The host averages the last five present intervals for the game's step, so a slice that changes when present returns 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

  • Not a big-bang branch, and not a freeze: fixes keep landing, but a slice that has started takes no new behaviour in its old implementation.
  • Not new switches without a removal date, and not a change of the cache formats except by a version bump with a reason.
  • Not a promise of fps on strong PCs, a new shader recompiler, a new lifter, or an assignment of people.

Open questions for the team

  1. Who owns each slice, leaf and plan track? What happens to open pull requests against a file being reworked (merge or close them first, then fixes only), and do we keep taking upstream fixes into it?
  2. What is the lowest card and system we promise (the plan proposes 4 GB of VRAM and 16 GB of RAM), and do we accept a small slowdown on old cards if a slice helps newer ones?
  3. Which of our players' GPUs have descriptor indexing with update-after-bind, memory budget and pipeline libraries? Nobody has the coverage.
  4. Is a replay the same twice, how large may a scene be, and where does each recording live?
  5. Who runs the null pair on the farm, and which gates do we adopt?
  6. Do we add a software-Vulkan lane to CI, and make the guide and switch checks cheap enough to stay green, or drop them as required checks?
  7. Does the host and lifter track belong here or under its own owner?
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](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/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 - **Why:** 12 days old, 85,766 lines, five files hold 63% of the C++, 58% of commits are fixes, and no test runs its Vulkan code. - **What we keep:** the shader recompiler, policy headers, the render half of `vk_api.h`, cache formats, upscaler engines, the VMA wrapper. - **Step 0, no change in behaviour:** record and replay, counters and a ledger, one frame record, fewer switches, a split interface, driver and game facts as data. - **Step 1:** menu, settings, translations, upscalers, tools, bug report and telemetry leave the core. - **Step 2:** resources, sync, descriptors, pipelines, then the replay path and memory model. - **Beside it:** the host CPU layer (#1503 to #1506) and the lifter (#1507). - **Measured first:** nine experiments that can change the order. - **Fit with the plan:** its tracks T and A to F, its section 9 rules, and four points where we differ. ## What changed since the first pass - **Shader stock:** the "5.2 GB made before the title" was a start-mode number from 11 Nov, before load-at-create became the default on 12 Nov. Today nothing releases programs, modules or pipelines in play (#1509). - **Cache key:** the 251.6 s on a Steam Deck was a review run of #223, fixed before it merged. The key still hashes `sizeof(Program)` (#1510). - **Small card:** fifteen places on three quantities, not nine (#1511). - **Lifter ordering:** acquire and release accesses are already sequentially consistent atomics on main, so the reported hazard is not there. A test is missing, and 919 of 3,823 barriers need only a compiler barrier (#1507). - **Poll sleeps:** `HOS_POLL_SLEEP_NS` can 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). - **Farm and dashboard:** the farm's frame log counts made frames too. The dashboard has no session ids by design; the relay counts real sessions, which the helper's sessions column does not (#1520). - **Switches, flips, trace:** #1309 deleted 111 kill switches and #1390 15 more. The write-back diff and present queue defaults were decided four times in three hours, not "five". 36 MB a frame of trace is an estimate. ## 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 - Top-level `gpu/vk` was 17,001 lines on 6 Nov, 42,551 on 10 Nov and 85,766 on 17 Nov. - Five files hold 63% of the C++: `vk_draw.cpp` 11,712, `vk_replay.cpp` 7,417, `vk_memory.cpp` 6,917, `vk_menu.cpp` 6,774, `vk_texture.cpp` 5,721. `vk_draw.cpp` was in 213 landed changes by 50 authors in 12 days. - There is no `Renderer` or `TextureCache` object: 1,111 file-scope variables, about 155 mutex declarations and 11 lock-order rules that exist only as comments. - The interface went from version 1 to 33. Of the 40 host functions added, 34 serve the menu, and 3 of the 29 version-bumping commits were for rendering. About 31% of the code is not rendering. 681 switches are live and 139 removed. ### It breaks in the same places - About 950 renderer commits in 11 days, 58% of them fixes. - Of the 477 fix commits that replace existing lines, 47% replace lines another commit of the same window wrote, 40% within 72 hours. - `draw()` is 804 lines and was changed by 62 commits, 29 of them fixes. - Defaults flip back and forth: the write-back diff and the present queue were decided four times in three hours on 9 Nov, and flipped again on 11 and 17 Nov. - 35% of the 552 fixes encode a fact about a driver, a GPU, an OS or the game. 161 of those 191 sit inside `.cpp` code that a rewrite would replace; 2 are in `device_policy.h`. ### We cannot see regressions before players do - 424 of 731 Python checks read a `vk_*.cpp` file 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. - CI has not run the suite on pull requests since 13 Nov. 30 checks were red on main on 17 Nov, and the guide-screenshot and switch-table checks were red on 95% and 67% of main commits. - Of 1,375 renderer-area reports, 98 say "regression", and most name a release, not a change. ### Memory and VRAM have no accountant - VRAM policy is nine stacked rules in one 789-line function. "Small card" is decided at fifteen places with six cut-offs between 4.5 and 8.5 GiB, on three different quantities (#1511). The static texture and mirror budgets add up to 93 to 97% of an assumed allowance before render targets, shadows and upscaler images. - About 1 GB of VRAM is attributed to no allocation (median 0.95 GB in field logs). #1339 counts every allocator buffer and brings the figure on one RTX 3090 from 426 to about 280 MB. - Everything loaded for shaders stays in memory until exit. On a 16 GB PC private memory grew from 2.9 to 5.1 GB over eight areas (#388). - Render targets are keyed by the address they sit at. On an RTX 4090, 4,833 images were made and 4,740 destroyed in 28,740 presents (about 8 minutes). In field logs kept tiles are 84% of the render-target images at the end, growing 211 an hour at the median (#1443; #1462 lets finalized targets go). - The game's memory is kept in step with the GPU by copying and waiting, across five files, with no owner. ### Hardware divergence is where players are hurt - 43 of 281 field logs end in a lost or hung device: AMD 30 of 120, Intel 11 of 17, NVIDIA 2 of 144. The logs came with bug reports, so the rates are biased up; the vendor order is the finding. Device loss is fatal by design. - One queue carries game work, uploads, readbacks and the present: the class of the Alt+Tab hangs on AMD's Windows driver (fixed in #1458). - A gameplay frame on an RTX 4090 records 501.5 full barriers and drops 237.8 as duplicates; the game asked for 167. Four other scenes record 379 to 446. The cost on AMD and Intel is unmeasured. ### Speed: what we can honestly promise - The replay costs 4.0 to 5.6 microseconds a draw on an RTX 4090 and 9.5 to 12 on slow cores (a Steam Deck, a 5600X). It decides the frame on slow cores and in the unthreaded mode. - On a strong PC with the render thread on, the plan's measurements (RTX 3090, Ryzen 9 7900X, 1440p) say a frame is the GPU's time plus 3 to 7 ms: the game waits once a frame for the GPU to finish the frame before, then signals, and nothing with draws can be recorded before that signal. The ceiling for any renderer change in one scene is about 17%. A frame-gate switch, a presenter thread, two presents ahead, a program-pick cache, descriptors by section and recording on four threads each gained nothing worth shipping; parts of 240 draws (#1484) did. - In the field the game's own part is 72.5% of a busy-scene frame and the renderer's 24%. - So we do not promise fps on strong PCs. The plan agrees: the heavy areas could reach the mid-80s to mid-90s, and more needs the game's own simulation or geometry to cost less. ### Our measurements cannot see it - The farm's p99 over 20 s at a 60 cap is the 13th slowest of 1,200 frames. In a simulation, 12 frames of 25 ms leave it at 17.5 ms and a 13th moves it to 25.0 (+43%). - Same-build noise in one report was 11.3% in p99, 28.8% in the 1% low and 98% in the maximum, against gates of 10 to 20%. #1462 failed at +26.9% on one run a side while its two other reports passed (#1517). - A frame is stamped at six moments and none is scan-out (#1518); the farm's frame log counts made frames too and cannot say whether frame generation ran. - 52.4% of 80,270 field hitches have the cause "other"; "game" is the time nothing else claimed (#1521). The dashboard's 1% low reads about 50 fps on a perfect 60 (#1520). ### 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 - **The shader recompiler** (about 44,000 lines, 90% unchanged since import), whose five-file interface is already a library boundary. - **The policy headers** (88) and their tests; 84 of the 85 plain ones are run by checks. - **The render half of `vk_api.h`:** 29 renderer functions, 26 host functions and the 51-opcode op stream; 50 of those 55 are from the first commit. - **The persisted cache formats,** changed on purpose with a version and a release note. #1510 takes `sizeof(Program)` out of the key so a struct change does not re-prepare every player's shaders. - **The upscaler and frame-generation engines,** with their hooks into the draw path named. - **The VMA wrapper,** the cleanest module. ## 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). - **T, tools:** Step 0. **A, budgets:** slice a (#1339, #1509, #1511). **B, memory sync:** slice e and the pool flags (#1516, #799). - **C, frame pipeline:** slice b and the threaded-mode choice (#1121). **D, draw translation:** slices c and d. **E, pipeline preparation:** slice d and the cache key (#1510). **F, switches and capabilities:** the table, one small-card classifier (#1511) and the per-GPU rules as data. **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_VERSION` goes up with every interface change. **Where we differ, for the plan's owners to decide:** 1. Menu, settings and upscalers leave the renderer interface. The plan leaves them alone, but upscalers account for 52 fixes and most interface versions were menu services. 2. Descriptors become their own piece, not part of draw translation. 3. Slices that change behaviour wait for a trace that can show equal pictures; counters, tables and deletions do not. 4. A CPU and host track and a lifter test, which the plan does not cover. ## The plan ### Step 0: nets and measurement (no behaviour change) - **Record and replay, image hashes (T, M1).** #1334 records one frame and plays it with no game. Once the trace carries the GPU-written images, the plan's notes show a played frame differing from the live one by 0.009, where two live sessions differ by 0.007 to 0.018. The first full frame was 2.0 GB; a minute of play is only estimated, at 15 to 30 GB, so the design needs one snapshot per scene and small deltas per submit. Hashes are kept per GPU and driver, linked to the parent version, with a human "accept" step. Recordings stay private; the repository holds hashes and a manifest. - **Counters:** a ledger of VRAM and RAM by class (#1339 starts it), barriers per frame, mesh-fallback draws, render-pass breaks, and one wrapper for the 25 or so places that block on the GPU. - **One frame record and one clock** (#1518), read by the counter, the field summary, the frame log and the Reflex markers; finer field buckets, queries without the title and loads, and honest hitch causes (#1520, #1521). - **Fewer switches:** one registry with owner, default, reason and a removal date for test switches (#1300, #1309 and #1390 are in; #1527 is open). - **Split the interface** into renderer calls and host services, and move the 85-field `Options` into a config module, as one version bump. This alone removes the reason for about 20 of the 29 bumps. - **Driver and game facts as data:** the 191 facts become rows with tests on made-up PCs, and one function classifies a card (#1511). - **Suggested additions:** the game-free suite on pull requests again, a software-Vulkan lane with validation, and a test migration plan before any split (135 checks read `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 `.cpp` lines are leaves. This follows the config split (57 `Options` fields 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.cpp` first 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 - **Host CPU layer:** in the one published Windows profile (an 11 Nov build; several costs are cut since) the host layer is 20 to 23% of sampled CPU and its wait and wake machinery 13 to 16%. #1503: a virtual-core gate without a global lock and a starve limit that follows the machine (a Steam Deck logged 184 waits of 50 ms or more, none with a 20 ms limit). #1504: a Linux lock shim that spins before it sleeps. #1505: signals that skip the wake when nobody waits (at most 0.3 to 0.8 ms of CPU a frame, unmeasured). #1506: measure the poll sleeps first. None claims an fps gain. - **The lifter:** the lifted code is 54 to 59% of on-CPU time. #1507 asks for a test of the ordering it writes and a compiler-only lowering for load-only and store-only barriers. #1469's gain is flat in the register count, which fits un-splitting giant functions, so the A/B below comes first. ## Measured first, and what each result decides None of these has been run. Each can change the plan. 1. **Giant-function split A/B:** main, split off, and #1469 on one CPU-bound PC, comparing the lifted code's own CPU time, not `game_ms`. Decides whether the lifter track starts with compiling hot giants whole or with locals as a proper pass. 2. **Format list and DCC (#1512):** count view formats on any GPU, check an RDNA 2 card, use `RADV_DEBUG=nodcc` on RDNA 3 as a ceiling. Decides whether the list is a small fix or part of the target design. 3. **Render-target alignment:** NVN size and alignment against Vulkan's. Decides whether slice a gets the arena. 4. **Does the game flush what it writes?** Flush calls against the pages the write watch reports. Decides whether flush hooks can replace the page watch for upload rings. 5. **Threaded-mode choice:** one CPU held to 4 up to 24 processors. Auto is a guess at 12 today: +17% on a 5600X, 6% less frame time on a 7900X, 31% and 13% slower on a Deck forced on. 6. **Pacing metrics (#1517):** the null pair, the six moments with PresentMon, a farm cell that proves frame generation ran. Decides the gate thresholds. 7. **Barriers on AMD and Intel:** is slice b worth doing for sync, or only for the present queue and device loss? 8. **Replay twice and its size:** the one-frame trace answers part; no minute-long trace exists. 9. **Poll sleeps (#1506):** which polls are idle and which are on the critical path. ## How we stop regressions - **A replay corpus, private,** with hashes and a manifest in the repository; each farm machine can record its own. - **No gate before its null pair.** A threshold is the larger of the nominal limit and 1.5 times the same-build spread on that rig and scene, printed with every result (#1517; the farm's side is Beanstalk #88). Until the pair exists, frame-time gates are advisory. - **Candidate gates:** a deterministic windowless lane (median at most 1.02 times old, valid when the same build agrees within 5%), a capped windowed lane, the present path, a cold shader cache, a 2-hour soak. p99 is reported but never a gate alone; the mean of the slowest 1% moves smoothly where p99 jumps. - **Game time is not the renderer's.** The host averages the last five present intervals for the game's step, so a slice that changes when `present` returns 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 - Not a big-bang branch, and not a freeze: fixes keep landing, but a slice that has started takes no new behaviour in its old implementation. - Not new switches without a removal date, and not a change of the cache formats except by a version bump with a reason. - Not a promise of fps on strong PCs, a new shader recompiler, a new lifter, or an assignment of people. ## Open questions for the team 1. Who owns each slice, leaf and plan track? What happens to open pull requests against a file being reworked (merge or close them first, then fixes only), and do we keep taking upstream fixes into it? 2. What is the lowest card and system we promise (the plan proposes 4 GB of VRAM and 16 GB of RAM), and do we accept a small slowdown on old cards if a slice helps newer ones? 3. Which of our players' GPUs have descriptor indexing with update-after-bind, memory budget and pipeline libraries? Nobody has the coverage. 4. Is a replay the same twice, how large may a scene be, and where does each recording live? 5. Who runs the null pair on the farm, and which gates do we adopt? 6. Do we add a software-Vulkan lane to CI, and make the guide and switch checks cheap enough to stay green, or drop them as required checks? 7. Does the host and lifter track belong here or under its own owner?
Author
Member

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

  1. Doubled in a week, no layers. Top-level gpu/vk is 172 files and 85,766 lines (39 .cpp with 60,906, 132 headers with 24,033), against 42,551 lines on 10 Nov and 17,001 on 6 Nov.
  2. Five files are 63% of the C++: vk_draw.cpp 11,712, vk_replay.cpp 7,417, vk_memory.cpp 6,917, vk_menu.cpp 6,774, vk_texture.cpp 5,721. Each is 8 to 20 unrelated things. Only about 3,500 lines of vk_draw.cpp are the draw path; the rest is pipeline building, the on-disk pipeline cache, shader preparation (1,624 lines), samplers and diagnostics (1,061).
  3. The include graph is acyclic (415 edges); the symbol graph is a tangle. 12 pairs of modules call each other both ways with five or more symbols each way. The widest cell is replay to memory: 48 distinct functions and 118 references, with 10 going back. vk_internal.h declares 183 functions of nine .cpp files, and 17 headers rebuild 34 of the 39 .cpp.
  4. State is singletons. 1,111 file-scope variables (757 mutable, 157 atomic, 95 mutex-like, 101 thread-local) plus 775 function-local statics and locks. There is no Renderer, TextureCache or memory-manager object.
  5. Two execution models, about 13 thread roles. The replay runs on the submitting thread or on a render thread (Auto from 12 usable CPUs), beside a recorder thread, optional workers, a presenter, compile workers, an import thread, capture helpers and a frame-generation display thread. About 155 mutex declarations (about 180 counting condition variables and slim locks) and 11 lock-order rules, all in comments.
  6. The guest-memory and time model is the centre, and nobody owns it. Guest memory is authoritative, the GPU works on imports and mirrors, the replay reads memory as it was at the submit, and GPU results reach the CPU only by write-back. It is spread over five files; the only specification is about 2,700 lines of comments.
  7. Lifetimes are hand-rolled. At least 15 separate "dead" lists free an object once the GPU's timeline passes its last use, which one shared retire queue could replace. Programs and pipelines are never freed while the game runs, and the cache key hashes sizeof(Program).
  8. The interface is clean in shape and wrong in content. 65 host functions and 36 renderer functions, version 1 to 33 in 12 days (64 landed changes by 23 authors). Of the 40 host functions added, 34 serve the menu, and only 3 of the 29 version-bumping commits were render-path changes. The renderer answers 52 option ids and is in effect the game's settings store.
  9. A third of the code is not rendering: about 22,400 lines (26%) by subsystem plus about 4,000 inside replay and draw, near 31% together. The 85-field Options struct is read by 18 files outside the menu, and the render-thread decision is made inside vk_menu.cpp.
  10. Switches and giants. 681 live switches and 139 removed, 792 environment reads, 145 distinct switches named in vk_draw.cpp. 86 functions of 100 lines or more hold 31.5% of function lines; draw is 804 lines with 325 branches and 27 environment reads.
  11. Testing is by text. 760 Python test files, 484 of which read gpu/vk source 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.
  12. Seams that exist. The render half of the interface (29 renderer and 26 host functions, 51 opcodes; 50 of those 55 from the first commit), the VMA wrapper (512 lines, 2 symbols out), the shader translator (about 7,400 lines, about 10 symbols out), the command recorder, 88 policy headers, and the menu once Options is 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

  • Step 0: split the interface (services out, one version bump) and make Options a 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.
  • Step 1: menu, diagnostics, telemetry and the upscaler hooks (three named points in the draw path) are the cleanest cuts.
  • Slice d starts by moving the pipeline code (about 3,900 lines in contiguous banners) out of vk_draw.cpp. Slices a and e own the memory model.
  • A differential harness is feasible at the interface: record the 36 renderer calls, the op streams and the guest-page changes, and replay in the synchronous mode against each library. Lock-step shadowing is unsafe because both renderers would write the same guest memory, so a trace replayed per renderer is the sound design. This is plan track T and M1.
  • The 12 days of fixes in these files are measured behaviour whose only record is comments, so the harness comes before any core rewrite.

What it could not establish

  • Exact coupling: the parser has no compiler, so name collisions and header-inline functions can shift the symbol counts.
  • Whether the memory and time model can be stated in a smaller form than the code; that needs the replay measurements.
  • Anything about runtime cost: this report is structure only.
  • The size of a trace; the report gives an estimate of page changes, not a measurement.

Corrections since it was written

  • The 251.6 s re-preparation on a Steam Deck was a tester's review run of #223, fixed before it merged, not something players got. The key still hashes sizeof(Program) (#1510).
  • Mutex count: 179 counted every use of the token, including parameters. The declarations are about 155, or about 180 counting condition variables and slim locks.
  • Interface entries: 65 plus 36 is this report's count; another report counted 106 by a different rule.
  • Two file sizes were 7,419 and 6,797 lines on a slightly later main. The switch table had 682 live rows on that read; the first table counted 571 at #1300, before the kill-switch deletions.
**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 1. **Doubled in a week, no layers.** Top-level `gpu/vk` is 172 files and 85,766 lines (39 `.cpp` with 60,906, 132 headers with 24,033), against 42,551 lines on 10 Nov and 17,001 on 6 Nov. 2. **Five files are 63% of the C++:** `vk_draw.cpp` 11,712, `vk_replay.cpp` 7,417, `vk_memory.cpp` 6,917, `vk_menu.cpp` 6,774, `vk_texture.cpp` 5,721. Each is 8 to 20 unrelated things. Only about 3,500 lines of `vk_draw.cpp` are the draw path; the rest is pipeline building, the on-disk pipeline cache, shader preparation (1,624 lines), samplers and diagnostics (1,061). 3. **The include graph is acyclic (415 edges); the symbol graph is a tangle.** 12 pairs of modules call each other both ways with five or more symbols each way. The widest cell is replay to memory: 48 distinct functions and 118 references, with 10 going back. `vk_internal.h` declares 183 functions of nine `.cpp` files, and 17 headers rebuild 34 of the 39 `.cpp`. 4. **State is singletons.** 1,111 file-scope variables (757 mutable, 157 atomic, 95 mutex-like, 101 thread-local) plus 775 function-local statics and locks. There is no `Renderer`, `TextureCache` or memory-manager object. 5. **Two execution models, about 13 thread roles.** The replay runs on the submitting thread or on a render thread (Auto from 12 usable CPUs), beside a recorder thread, optional workers, a presenter, compile workers, an import thread, capture helpers and a frame-generation display thread. About 155 mutex declarations (about 180 counting condition variables and slim locks) and 11 lock-order rules, all in comments. 6. **The guest-memory and time model is the centre, and nobody owns it.** Guest memory is authoritative, the GPU works on imports and mirrors, the replay reads memory as it was at the submit, and GPU results reach the CPU only by write-back. It is spread over five files; the only specification is about 2,700 lines of comments. 7. **Lifetimes are hand-rolled.** At least 15 separate "dead" lists free an object once the GPU's timeline passes its last use, which one shared retire queue could replace. Programs and pipelines are never freed while the game runs, and the cache key hashes `sizeof(Program)`. 8. **The interface is clean in shape and wrong in content.** 65 host functions and 36 renderer functions, version 1 to 33 in 12 days (64 landed changes by 23 authors). Of the 40 host functions added, 34 serve the menu, and only 3 of the 29 version-bumping commits were render-path changes. The renderer answers 52 option ids and is in effect the game's settings store. 9. **A third of the code is not rendering:** about 22,400 lines (26%) by subsystem plus about 4,000 inside replay and draw, near 31% together. The 85-field `Options` struct is read by 18 files outside the menu, and the render-thread decision is made inside `vk_menu.cpp`. 10. **Switches and giants.** 681 live switches and 139 removed, 792 environment reads, 145 distinct switches named in `vk_draw.cpp`. 86 functions of 100 lines or more hold 31.5% of function lines; `draw` is 804 lines with 325 branches and 27 environment reads. 11. **Testing is by text.** 760 Python test files, 484 of which read `gpu/vk` source 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. 12. **Seams that exist.** The render half of the interface (29 renderer and 26 host functions, 51 opcodes; 50 of those 55 from the first commit), the VMA wrapper (512 lines, 2 symbols out), the shader translator (about 7,400 lines, about 10 symbols out), the command recorder, 88 policy headers, and the menu once `Options` is 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 - Step 0: split the interface (services out, one version bump) and make `Options` a 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. - Step 1: menu, diagnostics, telemetry and the upscaler hooks (three named points in the draw path) are the cleanest cuts. - Slice d starts by moving the pipeline code (about 3,900 lines in contiguous banners) out of `vk_draw.cpp`. Slices a and e own the memory model. - A differential harness is feasible at the interface: record the 36 renderer calls, the op streams and the guest-page changes, and replay in the synchronous mode against each library. Lock-step shadowing is unsafe because both renderers would write the same guest memory, so a trace replayed per renderer is the sound design. This is plan track T and M1. - The 12 days of fixes in these files are measured behaviour whose only record is comments, so the harness comes before any core rewrite. ## What it could not establish - Exact coupling: the parser has no compiler, so name collisions and header-inline functions can shift the symbol counts. - Whether the memory and time model can be stated in a smaller form than the code; that needs the replay measurements. - Anything about runtime cost: this report is structure only. - The size of a trace; the report gives an estimate of page changes, not a measurement. ## Corrections since it was written - The 251.6 s re-preparation on a Steam Deck was a tester's review run of #223, fixed before it merged, not something players got. The key still hashes `sizeof(Program)` (#1510). - Mutex count: 179 counted every use of the token, including parameters. The declarations are about 155, or about 180 counting condition variables and slim locks. - Interface entries: 65 plus 36 is this report's count; another report counted 106 by a different rule. - Two file sizes were 7,419 and 6,797 lines on a slightly later main. The switch table had 682 live rows on that read; the first table counted 571 at #1300, before the kill-switch deletions.
Author
Member

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 from git blame. No game, GPU or build was run, so everything here is read from history, text and counts.

What it found

  1. 58% of commits are fixes, and the share does not fall. Of 950 non-merge commits, 550 are fixes, 202 features and 157 performance changes, from 167 authors, about 80 a day. The fix share is between 43% and 70% on every day.
  2. Fixes of fixes are the normal case. Of 477 fix commits that replace existing lines, 223 (47%) replace three or more lines that another commit of the window wrote; 193 (40%) did so within 72 hours and 144 (30%) within 24 hours. 97 were fixes on a fix and 114 fixes on a feature or perf change. 35% of larger feature commits and 16% of larger perf commits are patched this way within 72 hours.
  3. A handful of files and functions take the churn. vk_draw.cpp 258 commits (150 fixes), vk_replay.cpp 227 (109), vk_texture.cpp 122 (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.
  4. The project fixes forward and flips defaults. There were three explicit reverts. Instead, 45 commits name a default or an opt-in, and three features flipped back within hours. The write-back diff and the present queue had four default decisions inside three hours on 9 Nov and flipped again on 11 and 17 Nov.
  5. 35% of the 552 fixes encode a fact about a driver, hardware, the OS or the game: 119 plus 72, which is 191. 161 of them sit inside top-level .cpp code, 28 in the recompiler and 2 in device_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.
  6. The tracker confirms the vendor split. Renderer-area reports: AMD 569, NVIDIA 500, Intel 88. Device lost or GPU hang is 28% of Intel's reports, 16% of AMD's and 4% of NVIDIA's.
  7. Only 98 of 1,375 reports (7%) say regression, and 83 of those name a release, not a change. Regressions are found per release, not per commit.
  8. Tests pin text. Of 731 Python checks, 424 read a vk_*.cpp file and 278 cut text out of it; 135 read vk_draw.cpp and 116 vk_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.
  9. The protective checks are red most of the time. On 17 Nov 30 checks failed on the tip (2 of 529 on 12 Nov). The guide-screenshot check was red on 277 of 290 main pushes (95%) and the switch-table check on 43 of 64 (67%). CI has not run the suite on pull requests since 13 Nov.
  10. Merged renderer PRs are validated on one vendor. Of 127 with the template header, 86 list hardware or an OS they still need; 56 were tested on NVIDIA, 33 on AMD, 8 on Intel.
  11. The 552 fixes by class: translation semantics 79, sync and ordering 64, driver quirk 57, error paths 56, UI logic 55, defaults and policy 48, stale cache or state 42, size and bounds 40, lifetime and memory 39, upscaler library 31. The report's judgement, an order of magnitude only, is that 36% are what a refactor with tests mostly stops, 26% need a design change and 30% are knowledge that stays under either path.

What it means for the plan

  • Step 0 comes first because there is no net: record and replay (track T), a software-Vulkan lane, and a test migration plan before any split, since a split of vk_draw.cpp breaks up to 135 checks and of vk_replay.cpp 116.
  • The 191 facts must become data with tests before the code that holds them is replaced (Step 0 and the plan's track F). Finishing the per-GPU rules in one place is the same work on either path.
  • Slices a and e address the sync, lifetime and stale-state classes that a refactor only reduces. Slice d and the config split address size and conflicts.
  • The default flips argue for the rule that every behaviour change brings numbers before and after and a written removal date.

What it could not establish

  • Causes are the model's classification of commit subjects, bodies and files; the split of fixes between refactor and rewrite is a judgement.
  • Eleven days of history cannot show a trend, and the import's own history is invisible.
  • The tracker's regression count relies on what reporters wrote.
  • Nothing was run, so no claim about speed or about any picture.

Corrections since it was written

  • The summary said the write-back diff default flipped four times in five hours; the traced commits give four decisions inside three hours.
  • It credited #1390 with the deletion of 111 kill switches. #1309 deleted 111; #1390 deleted the 15 that the translation read.
  • Test counts depend on the glob (731 Python checks here, 760 test files in the architecture report), and the red rates are as of 17 Nov. The report's line total (76,330) probably leaves out about 9,500 lines of data and generated files; the whole top-level tree is 85,766 lines.
**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 from `git blame`. No game, GPU or build was run, so everything here is read from history, text and counts. ## What it found 1. **58% of commits are fixes, and the share does not fall.** Of 950 non-merge commits, 550 are fixes, 202 features and 157 performance changes, from 167 authors, about 80 a day. The fix share is between 43% and 70% on every day. 2. **Fixes of fixes are the normal case.** Of 477 fix commits that replace existing lines, 223 (47%) replace three or more lines that another commit of the window wrote; 193 (40%) did so within 72 hours and 144 (30%) within 24 hours. 97 were fixes on a fix and 114 fixes on a feature or perf change. 35% of larger feature commits and 16% of larger perf commits are patched this way within 72 hours. 3. **A handful of files and functions take the churn.** `vk_draw.cpp` 258 commits (150 fixes), `vk_replay.cpp` 227 (109), `vk_texture.cpp` 122 (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. 4. **The project fixes forward and flips defaults.** There were three explicit reverts. Instead, 45 commits name a default or an opt-in, and three features flipped back within hours. The write-back diff and the present queue had four default decisions inside three hours on 9 Nov and flipped again on 11 and 17 Nov. 5. **35% of the 552 fixes encode a fact about a driver, hardware, the OS or the game:** 119 plus 72, which is 191. 161 of them sit inside top-level `.cpp` code, 28 in the recompiler and 2 in `device_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. 6. **The tracker confirms the vendor split.** Renderer-area reports: AMD 569, NVIDIA 500, Intel 88. Device lost or GPU hang is 28% of Intel's reports, 16% of AMD's and 4% of NVIDIA's. 7. **Only 98 of 1,375 reports (7%) say regression,** and 83 of those name a release, not a change. Regressions are found per release, not per commit. 8. **Tests pin text.** Of 731 Python checks, 424 read a `vk_*.cpp` file and 278 cut text out of it; 135 read `vk_draw.cpp` and 116 `vk_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. 9. **The protective checks are red most of the time.** On 17 Nov 30 checks failed on the tip (2 of 529 on 12 Nov). The guide-screenshot check was red on 277 of 290 main pushes (95%) and the switch-table check on 43 of 64 (67%). CI has not run the suite on pull requests since 13 Nov. 10. **Merged renderer PRs are validated on one vendor.** Of 127 with the template header, 86 list hardware or an OS they still need; 56 were tested on NVIDIA, 33 on AMD, 8 on Intel. 11. **The 552 fixes by class:** translation semantics 79, sync and ordering 64, driver quirk 57, error paths 56, UI logic 55, defaults and policy 48, stale cache or state 42, size and bounds 40, lifetime and memory 39, upscaler library 31. The report's judgement, an order of magnitude only, is that 36% are what a refactor with tests mostly stops, 26% need a design change and 30% are knowledge that stays under either path. ## What it means for the plan - Step 0 comes first because there is no net: record and replay (track T), a software-Vulkan lane, and a test migration plan before any split, since a split of `vk_draw.cpp` breaks up to 135 checks and of `vk_replay.cpp` 116. - The 191 facts must become data with tests before the code that holds them is replaced (Step 0 and the plan's track F). Finishing the per-GPU rules in one place is the same work on either path. - Slices a and e address the sync, lifetime and stale-state classes that a refactor only reduces. Slice d and the config split address size and conflicts. - The default flips argue for the rule that every behaviour change brings numbers before and after and a written removal date. ## What it could not establish - Causes are the model's classification of commit subjects, bodies and files; the split of fixes between refactor and rewrite is a judgement. - Eleven days of history cannot show a trend, and the import's own history is invisible. - The tracker's regression count relies on what reporters wrote. - Nothing was run, so no claim about speed or about any picture. ## Corrections since it was written - The summary said the write-back diff default flipped four times in five hours; the traced commits give four decisions inside three hours. - It credited #1390 with the deletion of 111 kill switches. #1309 deleted 111; #1390 deleted the 15 that the translation read. - Test counts depend on the glob (731 Python checks here, 760 test files in the architecture report), and the red rates are as of 17 Nov. The report's line total (76,330) probably leaves out about 9,500 lines of data and generated files; the whole top-level tree is 85,766 lines.
Author
Member

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

  1. The replay is a serial per-draw interpreter. On the RTX 4090 the replay thread is the busiest at 65 to 74% of a core. "Submit" is 6.8 to 8.9 ms a frame at 4.0 to 5.6 microseconds a draw, nearly the same in four scenes of 1,284 to 2,105 draws.
  2. Whether it decides the frame depends on the PC. On slow cores it costs 9.5 to 12 microseconds a draw (Steam Deck, 5600X, an old Xeon) and limits the frame. On a strong desktop with the render thread on, the plan's measurements put the ceiling for any renderer change near 17% in a forest scene, and a town scene is limited by the game's own loop.
  3. No function is a hot spot. In the replay's active samples draw is 52 to 61% inclusive, the NVIDIA driver 25 to 28%, build_descriptors 23 to 25%, program_for 8 to 11%. 100 perf(...) commits touched gpu/vk in 11 days, each recovering 0.1 to 0.5 ms.
  4. Descriptors are rebuilt for every draw. 85 to 97% of draws cannot reuse their neighbour's set (kept: 2.9%, 11.3%, 15.4% and 9.1% in four scenes), and 26.8% of 134 million program picks revalidate against bound texture types.
  5. Guest memory is kept consistent by copying and waiting. Capture of dirty pages takes 10 to 20% of the game thread's active samples (0.3 to 0.7 ms a frame). One run synced 13 MB in 1,711 copies and wrote back 67 MB a frame, and late-page waits hit 7 to 11% of captures.
  6. CPU reads of GPU results stall the game. Readback waits were 4.9 to 5.0 ms a frame on main against 0.017 before two correctness fixes (62.5 against 79 to 80 fps with both reverted), and 0.33 to 1.4 ms later. About 25 call sites block on the GPU; the "GPU-bound wait" counter measures one.
  7. Textures cost little in steady play and a lot in loads. 0.1 to 0.8 ms a frame in play; 45 to 150 ms of uploads in load frames, and #1268's 200 to 470 ms bursts. All of it runs on the replay thread, and 1 to 14 render targets are made a frame.
  8. Shaders are a first-visit and start-up cost. After a full prepare 0 draws are left out (8 runs; 346 of 404 NVIDIA sessions). Cold first prepare took 250 s (55.7 s warm) on an RTX 4090, 78% of it in the driver, and 884 s for programs on an RX 6600. A translator change re-translates 38,809 programs, and 88 to 94% of the programs the game creates are never drawn.
  9. RAM. In one start-mode run on 11 Nov a PC held 14.35 GB resident: 7.1 GB the game's window and 6.8 GB the port. It grows with the shipped list (13.3, 15.1 and 16.8 GB over three builds). The rule that would release a whole program unit has no caller (#1509). When the game frees memory under an import the host writes zeros instead of releasing it: 11.6 GB zeroed in one #388 tour.
  10. Field context. In a town scene (21 sessions, 1.12 h) the game's own part is 72.5% of the frame, the renderer's recording 24%, GPU wait 1.3% and pacing 2.2%. Renderer causes are 4.4% of the hitches the classifier can name.
  11. The measurements are blunt. Same-build repeats are 6.5 to 11% apart, and one profile's build_descriptors share is 18, 25, 27 or 35% depending on the denominator.

What it means for the plan

  • Slice c (descriptors) must be priced before it starts: RX_VK_PROF_FINE output is not in any report. Expect nothing on strong PCs and a gain on slow cores.
  • Step 0's always-on wait attribution and counters exist because the field classifier cannot see most of what these costs are (#1521).
  • Slices a and e own the copy-and-wait memory model and readbacks; #1509 and #1510 are the RAM and cache-key pieces.
  • The plan's track C measurements and the report agree that a faster replay alone buys at most a few ms on strong PCs.

What it could not establish

  • The numbers come from builds of 11 and 12 Nov, before #994, #1255, #1222, #1478 and #1122 landed; no run of the current main exists in the material.
  • A default start's RAM on a PC with 24 GB or more at today's main, and Windows RAM against VRAM commit.
  • What any driver returns when a shader module is destroyed.
  • Whether a one-frame replay repeats more tightly than live play, which a deterministic lane would need.

Corrections since it was written

  • The "5.2 of the port's 6.8 GB is shader and pipeline stock made before the title" was a start-mode measurement from 11 Nov, before load-at-create became the default on 12 Nov. It is not what a default start holds today. What stands is that nothing releases programs, modules or pipelines while the game runs; #388 measured 2.9 to 5.1 GB over eight areas. Releasing programs at the game's free call was tried and dropped (at most 8.5% of loaded units for over 2,000 reloads).
  • The re-decode of about 1 GB of textures per area load was measured before #1222 (a revisited area takes the finalized copies' images) and #1478 merged.
  • The report itself records a 9% error its author made (a whole-log median used instead of the measurement window); its tables use the window.
**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 1. **The replay is a serial per-draw interpreter.** On the RTX 4090 the replay thread is the busiest at 65 to 74% of a core. "Submit" is 6.8 to 8.9 ms a frame at 4.0 to 5.6 microseconds a draw, nearly the same in four scenes of 1,284 to 2,105 draws. 2. **Whether it decides the frame depends on the PC.** On slow cores it costs 9.5 to 12 microseconds a draw (Steam Deck, 5600X, an old Xeon) and limits the frame. On a strong desktop with the render thread on, the plan's measurements put the ceiling for any renderer change near 17% in a forest scene, and a town scene is limited by the game's own loop. 3. **No function is a hot spot.** In the replay's active samples `draw` is 52 to 61% inclusive, the NVIDIA driver 25 to 28%, `build_descriptors` 23 to 25%, `program_for` 8 to 11%. 100 `perf(...)` commits touched `gpu/vk` in 11 days, each recovering 0.1 to 0.5 ms. 4. **Descriptors are rebuilt for every draw.** 85 to 97% of draws cannot reuse their neighbour's set (kept: 2.9%, 11.3%, 15.4% and 9.1% in four scenes), and 26.8% of 134 million program picks revalidate against bound texture types. 5. **Guest memory is kept consistent by copying and waiting.** Capture of dirty pages takes 10 to 20% of the game thread's active samples (0.3 to 0.7 ms a frame). One run synced 13 MB in 1,711 copies and wrote back 67 MB a frame, and late-page waits hit 7 to 11% of captures. 6. **CPU reads of GPU results stall the game.** Readback waits were 4.9 to 5.0 ms a frame on main against 0.017 before two correctness fixes (62.5 against 79 to 80 fps with both reverted), and 0.33 to 1.4 ms later. About 25 call sites block on the GPU; the "GPU-bound wait" counter measures one. 7. **Textures cost little in steady play and a lot in loads.** 0.1 to 0.8 ms a frame in play; 45 to 150 ms of uploads in load frames, and #1268's 200 to 470 ms bursts. All of it runs on the replay thread, and 1 to 14 render targets are made a frame. 8. **Shaders are a first-visit and start-up cost.** After a full prepare 0 draws are left out (8 runs; 346 of 404 NVIDIA sessions). Cold first prepare took 250 s (55.7 s warm) on an RTX 4090, 78% of it in the driver, and 884 s for programs on an RX 6600. A translator change re-translates 38,809 programs, and 88 to 94% of the programs the game creates are never drawn. 9. **RAM.** In one start-mode run on 11 Nov a PC held 14.35 GB resident: 7.1 GB the game's window and 6.8 GB the port. It grows with the shipped list (13.3, 15.1 and 16.8 GB over three builds). The rule that would release a whole program unit has no caller (#1509). When the game frees memory under an import the host writes zeros instead of releasing it: 11.6 GB zeroed in one #388 tour. 10. **Field context.** In a town scene (21 sessions, 1.12 h) the game's own part is 72.5% of the frame, the renderer's recording 24%, GPU wait 1.3% and pacing 2.2%. Renderer causes are 4.4% of the hitches the classifier can name. 11. **The measurements are blunt.** Same-build repeats are 6.5 to 11% apart, and one profile's `build_descriptors` share is 18, 25, 27 or 35% depending on the denominator. ## What it means for the plan - Slice c (descriptors) must be priced before it starts: `RX_VK_PROF_FINE` output is not in any report. Expect nothing on strong PCs and a gain on slow cores. - Step 0's always-on wait attribution and counters exist because the field classifier cannot see most of what these costs are (#1521). - Slices a and e own the copy-and-wait memory model and readbacks; #1509 and #1510 are the RAM and cache-key pieces. - The plan's track C measurements and the report agree that a faster replay alone buys at most a few ms on strong PCs. ## What it could not establish - The numbers come from builds of 11 and 12 Nov, before #994, #1255, #1222, #1478 and #1122 landed; no run of the current main exists in the material. - A default start's RAM on a PC with 24 GB or more at today's main, and Windows RAM against VRAM commit. - What any driver returns when a shader module is destroyed. - Whether a one-frame replay repeats more tightly than live play, which a deterministic lane would need. ## Corrections since it was written - The "5.2 of the port's 6.8 GB is shader and pipeline stock made before the title" was a start-mode measurement from 11 Nov, before load-at-create became the default on 12 Nov. It is not what a default start holds today. What stands is that nothing releases programs, modules or pipelines while the game runs; #388 measured 2.9 to 5.1 GB over eight areas. Releasing programs at the game's free call was tried and dropped (at most 8.5% of loaded units for over 2,000 reloads). - The re-decode of about 1 GB of textures per area load was measured before #1222 (a revisited area takes the finalized copies' images) and #1478 merged. - The report itself records a 9% error its author made (a whole-log median used instead of the measurement window); its tables use the window.
Author
Member

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

  1. There is no scheduler. About 65 to 75 guest threads, 8 to 10 host threads and 10 to 20 renderer threads each run as one OS thread with a 64 MB stack reservation. The guest's priorities and core masks are kept but never applied to the OS; they only drive the virtual-core gate.
  2. Guest code never runs on more than six cores at once. The gate is one global lock over a wait queue. It costs 1.1 to 1.5 ms of CPU a frame and about 7,500 waits a second, and it does not bound the frame (the gate off showed no clear gain in one scene). On 8-thread CPUs it starves low-priority threads: 184 waits of 50 ms or more in a few minutes on a Steam Deck, longest 1,001 ms, none with a 20 ms starve limit (#1503).
  3. A frame is three chains joined by waits: the game's main thread and job graph, the renderer, and the GPU. Which one limits depends on the PC: the replay on a 7900X without the render thread, the game's loop on a 3900X, a mix on the 5700X3D, and replay plus GPU on the Deck.
  4. In the field the game's own loop is the largest term. Over 133 release sessions (19.2 h), frame time is 73% "game", 13.8% "render", 11.9% "pace", 1.3% "gpu_wait". "Game" is what is left after the renderer's own parts, so it is undifferentiated.
  5. The host layer is 20 to 23% of sampled CPU in the three published scenes (8.8 to 12.4 ms a frame), and its wait and wake machinery alone 13 to 16%. The game makes 9,900 to 13,300 mutex pairs, 543 to 575 light-event signals and 117 to 157 recordings a frame through it.
  6. Every guest sync object is a slim lock plus a condition variable found by guest address. Mutexes have a compare-and-swap path; events, queues and semaphores always lock and wake all waiters, and a second global lock is taken on every signal while any thread waits in a multi-wait (#1505).
  7. Linux pays for a Windows shim. The slim lock is a pthread rwlock that never spins, every condition-variable wake is a system call even with no waiter, priorities above normal are no-ops, and the profiler counts rwlock sleeps as running time (#1504).
  8. Polling. The game's idle job loops sleep 20 microseconds and look again: about 15,600 sleeps a second in one scene, about 11 ms of thread time a frame spent asleep in them (#1506).
  9. The Auto rule for threaded rendering is a proxy. It turns on at 12 usable processors: +17% on a 5600X, 6% less frame time on a 7900X, and 31% and 13% slower on a Steam Deck forced on. The recorder thread alone was +13% on the 5700X3D and 14% slower on the Deck. RX_VK_PARALLEL was slower in five tests (10 to 30%).
  10. The capture is paid on the serial threads: 5.9% of a core, 0.59 to 0.88 ms a frame.
  11. Thread lifecycle has no owner. 96 creation sites (47 in gpu/vk, 49 in host/) and about ten CPU-count rules in eight files; the policy header computes three values that nothing reads.

What it means for the plan

  • This is the parallel track beside the renderer: #1503 (virtual-core gate), #1504 (Linux lock shim), #1505 (event and queue signals, multi-wait) and #1506 (poll sleeps, measure first). Each has a game-free fixture first and none claims an fps gain.
  • Step 0's always-on wait attribution and a processor-class label in the field summary are what decide the next changes.
  • The Auto rule for threaded rendering belongs to slice b and is settled by the measure-first run across 4 to 24 processors.
  • One thread registry and budget is the host-side half of the plan's track C (fixed stages and named worker pools).

What it could not establish

  • Only one CPU profile exists in this form, and it is Windows, 5700X3D, synchronous mode. There is no threaded-mode profile, no Linux or Deck profile in the same form, and no processor-class label in the field data.
  • The cost of events, queues and the multi-wait: no profile row isolates the global locks. The 0.3 to 0.8 ms a frame in #1505 is an upper bound.
  • How much of the field's "game" time is waiting.
  • Several Linux figures are single reporters' numbers.

Corrections since it was written

  • The "1 to 2 ms" for polling was the whole sleep-and-timer category, which also holds condition-variable sleeps that a poll governor would not touch. The yield loop alone was 0.65 to 0.74 ms a frame on one older build, and later commits have cut it.
  • HOS_POLL_SLEEP_NS can 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).
  • The 1 to 2% fps gain for a Linux lock shim is a reporter's guess, and the 4% copy_lock share is one profile on one machine (#1504).
  • The host numbers are from an 11 Nov build; several costs have been cut since (the 5 microsecond spin for non-serial threads, the timer for short sleeps, a signal with no waiter, a shorter copy-lock hold, the vsync ticker on a timer).
**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 1. **There is no scheduler.** About 65 to 75 guest threads, 8 to 10 host threads and 10 to 20 renderer threads each run as one OS thread with a 64 MB stack reservation. The guest's priorities and core masks are kept but never applied to the OS; they only drive the virtual-core gate. 2. **Guest code never runs on more than six cores at once.** The gate is one global lock over a wait queue. It costs 1.1 to 1.5 ms of CPU a frame and about 7,500 waits a second, and it does not bound the frame (the gate off showed no clear gain in one scene). On 8-thread CPUs it starves low-priority threads: 184 waits of 50 ms or more in a few minutes on a Steam Deck, longest 1,001 ms, none with a 20 ms starve limit (#1503). 3. **A frame is three chains joined by waits:** the game's main thread and job graph, the renderer, and the GPU. Which one limits depends on the PC: the replay on a 7900X without the render thread, the game's loop on a 3900X, a mix on the 5700X3D, and replay plus GPU on the Deck. 4. **In the field the game's own loop is the largest term.** Over 133 release sessions (19.2 h), frame time is 73% "game", 13.8% "render", 11.9% "pace", 1.3% "gpu_wait". "Game" is what is left after the renderer's own parts, so it is undifferentiated. 5. **The host layer is 20 to 23% of sampled CPU** in the three published scenes (8.8 to 12.4 ms a frame), and its wait and wake machinery alone 13 to 16%. The game makes 9,900 to 13,300 mutex pairs, 543 to 575 light-event signals and 117 to 157 recordings a frame through it. 6. **Every guest sync object is a slim lock plus a condition variable found by guest address.** Mutexes have a compare-and-swap path; events, queues and semaphores always lock and wake all waiters, and a second global lock is taken on every signal while any thread waits in a multi-wait (#1505). 7. **Linux pays for a Windows shim.** The slim lock is a pthread rwlock that never spins, every condition-variable wake is a system call even with no waiter, priorities above normal are no-ops, and the profiler counts rwlock sleeps as running time (#1504). 8. **Polling.** The game's idle job loops sleep 20 microseconds and look again: about 15,600 sleeps a second in one scene, about 11 ms of thread time a frame spent asleep in them (#1506). 9. **The Auto rule for threaded rendering is a proxy.** It turns on at 12 usable processors: +17% on a 5600X, 6% less frame time on a 7900X, and 31% and 13% slower on a Steam Deck forced on. The recorder thread alone was +13% on the 5700X3D and 14% slower on the Deck. `RX_VK_PARALLEL` was slower in five tests (10 to 30%). 10. **The capture is paid on the serial threads:** 5.9% of a core, 0.59 to 0.88 ms a frame. 11. **Thread lifecycle has no owner.** 96 creation sites (47 in `gpu/vk`, 49 in `host/`) and about ten CPU-count rules in eight files; the policy header computes three values that nothing reads. ## What it means for the plan - This is the parallel track beside the renderer: #1503 (virtual-core gate), #1504 (Linux lock shim), #1505 (event and queue signals, multi-wait) and #1506 (poll sleeps, measure first). Each has a game-free fixture first and none claims an fps gain. - Step 0's always-on wait attribution and a processor-class label in the field summary are what decide the next changes. - The Auto rule for threaded rendering belongs to slice b and is settled by the measure-first run across 4 to 24 processors. - One thread registry and budget is the host-side half of the plan's track C (fixed stages and named worker pools). ## What it could not establish - Only one CPU profile exists in this form, and it is Windows, 5700X3D, synchronous mode. There is no threaded-mode profile, no Linux or Deck profile in the same form, and no processor-class label in the field data. - The cost of events, queues and the multi-wait: no profile row isolates the global locks. The 0.3 to 0.8 ms a frame in #1505 is an upper bound. - How much of the field's "game" time is waiting. - Several Linux figures are single reporters' numbers. ## Corrections since it was written - The "1 to 2 ms" for polling was the whole sleep-and-timer category, which also holds condition-variable sleeps that a poll governor would not touch. The yield loop alone was 0.65 to 0.74 ms a frame on one older build, and later commits have cut it. - `HOS_POLL_SLEEP_NS` can 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). - The 1 to 2% fps gain for a Linux lock shim is a reporter's guess, and the 4% `copy_lock` share is one profile on one machine (#1504). - The host numbers are from an 11 Nov build; several costs have been cut since (the 5 microsecond spin for non-serial threads, the timer for short sleeps, a signal with no waiter, a shorter copy-lock hold, the vsync ticker on a timer).
Author
Member

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

  1. VRAM policy is nine stacked rules in one 789-line function with no ledger. texture_frame combines 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 by min(). 322 of the repository's 2,558 commits touch the memory files.
  2. "Small card" is decided in several places with six cut-offs between 4.5 and 8.5 GiB. The report counted nine places; a later read found fifteen, on three different quantities (#1511). Comments and code already disagree in the same files.
  3. The budgets add up to the whole allowance. Texture plus mirror budgets are 97%, 96%, 93% and 95% of an assumed allowance on 4, 6, 8 and 16 GB cards, before render targets, shadows, upscaler images and streams. In the field 13% of the VRAM lines on 8 GB-class cards (83 logs) are past 97% of the allowance.
  4. About 1 GB is not attributed. About a fifth of the blocks the allocator holds is free space (median 18 to 26% from 4.6 GB cards up), and the driver counts a further 0.95 GB (median; 2.0 GB at p90) that no renderer allocation accounts for. There are about 70 raw allocation sites in 15 files.
  5. Render targets are the clearest structural miss. Each temporary target is its own address-keyed image: on an RTX 4090, 4,833 were made and 4,740 destroyed in 28,740 presents (about 8 minutes), and 22,000 were destroyed in 100 s in a town scene at night with a 256 MB pool bound.
  6. The address-keyed texture is the root of three bug families: the render-target leak (#1443: kept tiles are 84% of the images at the end, +211 an hour at the median), the re-decode of about 1 GB of ASTC at every area load (#1069), and the game's own heap relocation (#1478).
  7. The coherence layer is the biggest source of VRAM use and stalls. vk_memory.cpp is 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.
  8. Synchronization is one global barrier. Every full barrier is all-commands to all-commands; images are created undefined and kept in the general layout. A gameplay frame on an RTX 4090 records 501.5 full barriers and drops 237.8 as duplicates, against 167 the game asked for. The cost on AMD and Intel has not been measured.
  9. One queue carries everything, including the present: the Alt+Tab hang class on AMD's Windows driver, fixed in #1458. Device loss is fatal by design.
  10. Device loss is mostly an AMD and Intel matter, and rarely VRAM. 43 of 281 logs end in a lost or hung device: AMD 30 of 120, Intel 11 of 17, NVIDIA 2 of 144. At the last VRAM line only 4 of 41 were over 97%. Causes include the present wait, the native task and mesh path, one upload submission of about 2,000 dispatches that ran 4 to 6 s against a 2 s timeout (#1040), imports given back, and driver compiler faults. 29 of 38 device-fault lines are empty or say nothing.
  11. The mesh fallback is a first-class path: 69 of 281 logs run it, 57 of them AMD. Each fallback draw ends the render pass and records 3 or 4 full barriers.
  12. Colour images are made with no format list, which may switch off AMD's compression on RDNA 1 and 2 (#1512).

What it means for the plan

  • Slice a: a ledger and one budget controller, one small-card classifier, an aliasing arena for render targets (after the alignment measurement), a content-keyed texture cache with explicit per-image state, one retire queue. Plan track A; #1339 starts the ledger, #1511 and #1509 are filed pieces.
  • Slice b: a per-resource sync tracker for renderer-owned passes first, a present queue never shared with game work, bounded GPU work per submission, and a device-lost path that rebuilds from guest memory.
  • Slices c and e take descriptors and the classification of guest ranges.
  • Local fixes can go first and cost little: counters, one small-card function, streams and descriptor pools sized by use, frame generation's images freed when off (#1158).

What it could not establish

  • Barrier cost on AMD and Intel, how many mesh-fallback draws a frame run, and whether the GPU is the limit on small cards.
  • Whether render-target sizes and alignments the game uses can be matched in one arena.
  • The field's coverage of descriptor indexing, memory budget and pipeline libraries.
  • Rates from logs attached to bug reports are biased up; the vendor ratio is the finding.

Corrections since it was written

  • "Small card" is fifteen places, not nine, with the same six cut-offs and three quantities (#1511).
  • The unattributed VRAM is about 1 GB in field logs. On an RTX 3090 it fell from 426 to about 280 MB once every allocator buffer was counted (#1339).
  • Frame generation's images at 1440p and 2x are about 112 MiB for the built-in engine (the quoted 150 MB probably includes FSR 3.1's images) and about 823 MiB at 4K and 8x. They are kept after frame generation is turned off (#1158).
  • On the format list: Mesa's source needs it for DCC below RDNA 3, not on RDNA 3 and 4, and an image with an atomics-capable storage format loses DCC regardless. The gain is bounded and unmeasured (#1512).
**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 1. **VRAM policy is nine stacked rules in one 789-line function with no ledger.** `texture_frame` combines 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 by `min()`. 322 of the repository's 2,558 commits touch the memory files. 2. **"Small card" is decided in several places with six cut-offs** between 4.5 and 8.5 GiB. The report counted nine places; a later read found fifteen, on three different quantities (#1511). Comments and code already disagree in the same files. 3. **The budgets add up to the whole allowance.** Texture plus mirror budgets are 97%, 96%, 93% and 95% of an assumed allowance on 4, 6, 8 and 16 GB cards, before render targets, shadows, upscaler images and streams. In the field 13% of the VRAM lines on 8 GB-class cards (83 logs) are past 97% of the allowance. 4. **About 1 GB is not attributed.** About a fifth of the blocks the allocator holds is free space (median 18 to 26% from 4.6 GB cards up), and the driver counts a further 0.95 GB (median; 2.0 GB at p90) that no renderer allocation accounts for. There are about 70 raw allocation sites in 15 files. 5. **Render targets are the clearest structural miss.** Each temporary target is its own address-keyed image: on an RTX 4090, 4,833 were made and 4,740 destroyed in 28,740 presents (about 8 minutes), and 22,000 were destroyed in 100 s in a town scene at night with a 256 MB pool bound. 6. **The address-keyed texture is the root of three bug families:** the render-target leak (#1443: kept tiles are 84% of the images at the end, +211 an hour at the median), the re-decode of about 1 GB of ASTC at every area load (#1069), and the game's own heap relocation (#1478). 7. **The coherence layer is the biggest source of VRAM use and stalls.** `vk_memory.cpp` is 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. 8. **Synchronization is one global barrier.** Every full barrier is all-commands to all-commands; images are created undefined and kept in the general layout. A gameplay frame on an RTX 4090 records 501.5 full barriers and drops 237.8 as duplicates, against 167 the game asked for. The cost on AMD and Intel has not been measured. 9. **One queue carries everything,** including the present: the Alt+Tab hang class on AMD's Windows driver, fixed in #1458. Device loss is fatal by design. 10. **Device loss is mostly an AMD and Intel matter, and rarely VRAM.** 43 of 281 logs end in a lost or hung device: AMD 30 of 120, Intel 11 of 17, NVIDIA 2 of 144. At the last VRAM line only 4 of 41 were over 97%. Causes include the present wait, the native task and mesh path, one upload submission of about 2,000 dispatches that ran 4 to 6 s against a 2 s timeout (#1040), imports given back, and driver compiler faults. 29 of 38 device-fault lines are empty or say nothing. 11. **The mesh fallback is a first-class path:** 69 of 281 logs run it, 57 of them AMD. Each fallback draw ends the render pass and records 3 or 4 full barriers. 12. **Colour images are made with no format list,** which may switch off AMD's compression on RDNA 1 and 2 (#1512). ## What it means for the plan - Slice a: a ledger and one budget controller, one small-card classifier, an aliasing arena for render targets (after the alignment measurement), a content-keyed texture cache with explicit per-image state, one retire queue. Plan track A; #1339 starts the ledger, #1511 and #1509 are filed pieces. - Slice b: a per-resource sync tracker for renderer-owned passes first, a present queue never shared with game work, bounded GPU work per submission, and a device-lost path that rebuilds from guest memory. - Slices c and e take descriptors and the classification of guest ranges. - Local fixes can go first and cost little: counters, one small-card function, streams and descriptor pools sized by use, frame generation's images freed when off (#1158). ## What it could not establish - Barrier cost on AMD and Intel, how many mesh-fallback draws a frame run, and whether the GPU is the limit on small cards. - Whether render-target sizes and alignments the game uses can be matched in one arena. - The field's coverage of descriptor indexing, memory budget and pipeline libraries. - Rates from logs attached to bug reports are biased up; the vendor ratio is the finding. ## Corrections since it was written - "Small card" is fifteen places, not nine, with the same six cut-offs and three quantities (#1511). - The unattributed VRAM is about 1 GB in field logs. On an RTX 3090 it fell from 426 to about 280 MB once every allocator buffer was counted (#1339). - Frame generation's images at 1440p and 2x are about 112 MiB for the built-in engine (the quoted 150 MB probably includes FSR 3.1's images) and about 823 MiB at 4K and 8x. They are kept after frame generation is turned off (#1158). - On the format list: Mesa's source needs it for DCC below RDNA 3, not on RDNA 3 and 4, and an image with an atomics-capable storage format loses DCC regardless. The gain is bounded and unmeasured (#1512).
Author
Member

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

  1. The pipeline. A Python lifter (about 1,850 lines) on a C++ instruction translator (about 8,100 lines), plus about 4,000 lines of wrappers, turns 294,522 guest functions (17,646,355 instructions, all translated) into 1,545 MB of C, 87.6 bytes per instruction. A player's PC compiles it at -O1 into 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.
  2. The lifted code is the biggest CPU cost. In the three published scenes it is 53.9%, 58.5% and 54.1% of the process's on-CPU time (33.8, 30.2 and 20.8 ms of CPU a frame). The runtime helpers it needs are 2.4 to 2.5%, the host layer 20 to 23% and the renderer 16.5 to 22.6%. The frame is paced by the game's job chain, so these shares are an upper bound on what a faster lifter buys.
  3. The hot code is memory and float bound. In the shipped hot-pieces play profile (849 functions) the code did 5.18 billion guest loads and 2.85 billion stores. 33% of the stores carried their own page marks, and 3.51 billion 16-byte vector-register writes went into the context struct.
  4. The biggest unexamined lever is the compile-time split of giant functions. 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 a switch loop. 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.
  5. #1469 (registers and flags as C locals) has a confounder. It leaves 364 of 370 giants whole, and its gain is flat in the register count (4, 6 and 8 registers: +10.5, +10.4, +11.4%), which fits un-splitting. The evidence for the locals themselves conflicts: +14% and +11.8% on a Ryzen 9 3900X under Windows, +2 to +3% on two Linux farm machines, nothing on a 7900X, and game_ms went up on both PCs that reported it. Compile time rose 66% (298 to 494 s on 24 threads).
  6. Locals and the page-mark groups exclude each other today. With locals the lift has 1,220,976 individually marked store sites instead of 533,693 (+129%).
  7. Write tracking is a software table. One byte per 4 KB page (128 MiB), set by two byte stores per non-stack store. The renderer's collection of the marks is 5.5 to 5.9% of a core, 0.67 to 1.17 ms a frame, mostly on the main and presentation threads. Host code marks its own writes by hand, and the oracle in #1034 found four unmarked host writes (1,547 to 3,172 missed pages in runs that compared 10.9 to 35.7 million).
  8. Barriers. All 3,823 barrier instructions become one out-of-line sequentially consistent fence call. 919 of them (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).
  9. Several ideas were checked and are not worth doing. An identity memory mapping saves almost nothing (the base constant is loaded 353,164 times in 492.6 MB of code). Indirect calls cost 0.9 to 1.2% of a core and devirtualization measured 73.6 against 73.5 fps. Whole-game -O2 costs a 23:25 build against 3:29 for +2.7% fps.
  10. Floating point is the best-engineered part. Fast float regions (#38) took one scene from 41.5 to 45.7 fps, and fused multiply-add made FMA-bound kernels 22 to 45% faster. What is left is runtime/float at 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.
  11. Hooks and patches are text surgery on emitted C: 33 patch functions naming 77 functions, each matched against the exact emitted text. #1469 had to exclude 92 functions from locals.

What it means for the plan

  • This is the lifter half of the parallel track beside the renderer, not a renderer slice. The first step is the A/B in #1493's measure-first list: main, giants whole, and #1469, comparing the lifted code's own CPU time (not game_ms). It decides whether the lifter work starts with compiling hot giants whole or with locals as a proper pass.
  • #1507 is the filed piece: a game-free test of what the lifter writes for acquire and release accesses, atomics and barriers, then a compiler-only lowering for the load-only and store-only barriers, after a count of executed barriers.
  • Slice e and the plan's track B share the write-tracking cost: a typed host-write function that marks, and the oracle kept on, are the way to make a missed page impossible (#1339 and #1360 are on that path).
  • A new lifter with an intermediate form is a separate project, not part of the renderer work.

What it could not establish

  • Whether the giant split costs anything on a CPU-bound scene. That is a hypothesis built from structure, one profile comment and a flat register curve.
  • What any barrier costs: no measurement exists, and no executed-barrier count either.
  • The share of marks that execute, the cost of the polls, and the real instruction mix. Each needs a counting build.
  • The unexplained crash in #1469's local-register builds (one heap-corruption exception in about 41 runs against none in about 30 of main). No ordering explanation was found, and the test of the Unicorn-based checks with locals on has not been run.
  • The CPU shares come from a Windows profile of an older build.

Corrections since it was written

  • The report said LDAR and STLR become 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.py replaces the translator's text for them, so they are sequentially consistent atomics (the store followed by its page mark), acquire loads for LDAPR, 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.
  • The 5.5 to 5.9% mark-collection figure and the CPU shares come from the 11 Nov profile; some host costs have been cut since.
**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 1. **The pipeline.** A Python lifter (about 1,850 lines) on a C++ instruction translator (about 8,100 lines), plus about 4,000 lines of wrappers, turns 294,522 guest functions (17,646,355 instructions, all translated) into 1,545 MB of C, 87.6 bytes per instruction. A player's PC compiles it at `-O1` into 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. 2. **The lifted code is the biggest CPU cost.** In the three published scenes it is 53.9%, 58.5% and 54.1% of the process's on-CPU time (33.8, 30.2 and 20.8 ms of CPU a frame). The runtime helpers it needs are 2.4 to 2.5%, the host layer 20 to 23% and the renderer 16.5 to 22.6%. The frame is paced by the game's job chain, so these shares are an upper bound on what a faster lifter buys. 3. **The hot code is memory and float bound.** In the shipped hot-pieces play profile (849 functions) the code did 5.18 billion guest loads and 2.85 billion stores. 33% of the stores carried their own page marks, and 3.51 billion 16-byte vector-register writes went into the context struct. 4. **The biggest unexamined lever is the compile-time split of giant functions.** `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 a `switch` loop. 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. 5. **#1469 (registers and flags as C locals) has a confounder.** It leaves 364 of 370 giants whole, and its gain is flat in the register count (4, 6 and 8 registers: +10.5, +10.4, +11.4%), which fits un-splitting. The evidence for the locals themselves conflicts: +14% and +11.8% on a Ryzen 9 3900X under Windows, +2 to +3% on two Linux farm machines, nothing on a 7900X, and `game_ms` went up on both PCs that reported it. Compile time rose 66% (298 to 494 s on 24 threads). 6. **Locals and the page-mark groups exclude each other today.** With locals the lift has 1,220,976 individually marked store sites instead of 533,693 (+129%). 7. **Write tracking is a software table.** One byte per 4 KB page (128 MiB), set by two byte stores per non-stack store. The renderer's collection of the marks is 5.5 to 5.9% of a core, 0.67 to 1.17 ms a frame, mostly on the main and presentation threads. Host code marks its own writes by hand, and the oracle in #1034 found four unmarked host writes (1,547 to 3,172 missed pages in runs that compared 10.9 to 35.7 million). 8. **Barriers.** All 3,823 barrier instructions become one out-of-line sequentially consistent fence call. 919 of them (`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). 9. **Several ideas were checked and are not worth doing.** An identity memory mapping saves almost nothing (the base constant is loaded 353,164 times in 492.6 MB of code). Indirect calls cost 0.9 to 1.2% of a core and devirtualization measured 73.6 against 73.5 fps. Whole-game `-O2` costs a 23:25 build against 3:29 for +2.7% fps. 10. **Floating point is the best-engineered part.** Fast float regions (#38) took one scene from 41.5 to 45.7 fps, and fused multiply-add made FMA-bound kernels 22 to 45% faster. What is left is `runtime/float` at 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. 11. **Hooks and patches are text surgery on emitted C:** 33 patch functions naming 77 functions, each matched against the exact emitted text. #1469 had to exclude 92 functions from locals. ## What it means for the plan - This is the lifter half of the parallel track beside the renderer, not a renderer slice. The first step is the A/B in #1493's measure-first list: main, giants whole, and #1469, comparing the lifted code's own CPU time (not `game_ms`). It decides whether the lifter work starts with compiling hot giants whole or with locals as a proper pass. - #1507 is the filed piece: a game-free test of what the lifter writes for acquire and release accesses, atomics and barriers, then a compiler-only lowering for the load-only and store-only barriers, after a count of executed barriers. - Slice e and the plan's track B share the write-tracking cost: a typed host-write function that marks, and the oracle kept on, are the way to make a missed page impossible (#1339 and #1360 are on that path). - A new lifter with an intermediate form is a separate project, not part of the renderer work. ## What it could not establish - Whether the giant split costs anything on a CPU-bound scene. That is a hypothesis built from structure, one profile comment and a flat register curve. - What any barrier costs: no measurement exists, and no executed-barrier count either. - The share of marks that execute, the cost of the polls, and the real instruction mix. Each needs a counting build. - The unexplained crash in #1469's local-register builds (one heap-corruption exception in about 41 runs against none in about 30 of main). No ordering explanation was found, and the test of the Unicorn-based checks with locals on has not been run. - The CPU shares come from a Windows profile of an older build. ## Corrections since it was written - The report said `LDAR` and `STLR` become 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.py` replaces the translator's text for them, so they are sequentially consistent atomics (the store followed by its page mark), acquire loads for `LDAPR`, 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. - The 5.5 to 5.9% mark-collection figure and the CPU shares come from the 11 Nov profile; some host costs have been cut since.
Author
Member

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

  1. One frame has six clocks. (0) the host's clock when the game's present call returns, which also drives the game's own time step; (1) the renderer's present entry on the presenting thread, which feeds the FPS counter and the field summary; (2) the render thread's present job, which feeds the frame trace; (3) after the present call returns, which feeds the frame log and so the farm's frame-time probe; (4) the screen, visible only to PresentMon; (5) the driver's Reflex timings. None of the first four is scan-out. The host and the renderer also read different clock sources, so matching a log row to a trace row means guessing an offset (#1518).
  2. The host, not the renderer, decides game time and the cap. The game's step is the average of the last five present-call intervals. The cap is enforced three times (the game's own limiter raised to the cap, an acquire sleep with a model of the console's display queue, and a vsync ticker at the cap rate), and the game is told the display cannot do variable refresh. The renderer changes game speed only by changing when present returns (#1519).
  3. The present path is not one path. V-Sync Auto is mailbox where the driver has it, immediate on Windows AMD (no mailbox), FIFO under DLSS frame generation, and FIFO on Linux without mailbox. The Frame pacing row does nothing with frame generation off.
  4. The farm's p99 is a 13th-slowest-frame statistic. At a 60 cap, 20 s is 1,200 frames. In a simulation with steady 17.4 ms frames, 12 frames of 25 ms leave p99 at 17.5 ms and a 13th makes it 25.0 (+43%); with 33.3 ms frames it jumps to 33.3 (+90%). The mean of the slowest 1% moves smoothly: 17.4, 21.2, 24.4, 25.0 over the same range (#1517).
  5. Same-build noise sits at the gate. In one farm report on an RX 9070 XT, main against main differed by up to +11.3% in p99 and +12.2% in the 1% low in one cell, and by +28.8% in the 1% low, +98% in the maximum and 0 against 5 stutters in another, against a 15% gate. #1462 failed at +26.9% p99 on one run a side on an RTX 4070 (18.27 against 23.19 ms) while its other two PCs read +3.5% and 0%. Resampling the real histograms, a 10% p99 gate fails with no change 4.0%, 0.0% and 13.9% of the time on the three PCs; the 1% low fails 0.3%, 27.6% and 6.4%. Real windows are less steady than independent frames, so these are floors.
  6. A capped scene hides cost and maybe frame generation. All four cells of one report have a median of 16.63 to 16.72 ms and the render thread idle about 9 ms of 16.67, so a cheaper renderer would move none of them. The log it keeps has no frame-interpolation line, and by the code a running 2x or 4x would write two to four frame-log rows per game frame, so frame generation probably did not run [INFERENCE].
  7. The same mean fps can hide very different pacing. Every window reads 60.0 fps. The share of present intervals outside 15.5 to 17.8 ms is 1.3 to 2.7% in one cell and 28 to 61% in the tails of #1462's logs on three PCs.
  8. A present call is not the screen. On 16 Nov, with DLSS frame generation and PresentMon on an RTX 5090, the frame log showed no late frame while PresentMon showed 32% (3x) and 45% (4x) of frames on screen less than 2 ms apart. In #1362, #1442 and #1476 that share fell from 33% to 0.0% and the spread of displayed time from 4.7 ms to about 1 ms.
  9. The dashboard's 1% low cannot show a perfect 60 fps. It is one over the 99th percentile of a histogram with 12 buckets and an edge at 16.7 ms, just above the 16.667 ms period. Maps whose frames are 99% within 20 ms read 49 to 50 fps; a synthetic 60 fps stream reads 50.4 to 50.2 through today's edges and 59.2 to 57.2 with seven more edges near 60 Hz (#1520).
  10. Field averages mix in movies. 39.5% of the 13.4 million frames at the 60 cap are the title and intro, which lifts the average to 64.4 fps.
  11. Hitch causes are mostly "other". Of 80,270 hitches in 89 hours, 52.4% are "other", 41.7% "game_cpu", and every renderer cause together is under 6%. At 901 hitches an hour (one every 4 s), loads are included (#1521).

What it means for the plan

  • Step 0 starts with one frame record and one clock (#1518), then moves each reader onto it and adds shown time where the platform gives it.
  • No gate is used before its null pair on that rig and scene; the threshold is the spread of the same build against itself, not a fixed 10 or 20% (#1517, with the farm's side in Beanstalk #88). The proposed gates (frame time, slowest-1% mean, pacing share, shown cadence, latency, game-clock speed, present-path stability, cold-cache stalls, a soak) stay advisory until then.
  • One pacer with a policy table for the present mode keeps game time stable above 60 fps; any slice that changes when present returns has to keep that behaviour (#1519).
  • Field statistics need finer buckets, queries without the title, and honest hitch causes (#1520, #1521).
  • Old and new renderers can run on one host and one lifted game, so the pacer and game clock are identical by construction.

What it could not establish

  • How far apart the six moments are in each present mode (PresentMon alongside the logs was not run), and which GPUs and drivers expose present timing.
  • Whether the farm's frame-generation cells made any frames, and which engine.
  • How often the farm's rule fails with no change on real runs: only a null pair of about 10 same-build pairs can say.
  • The field's frame generation, V-Sync and present-mode mix, which no label records, and any input-to-screen latency.
  • The field data is about two days of consented sessions, short ones; rows with fewer than about ten sessions are anecdotes.

Corrections since it was written

  • The field helper's sessions column counts map visits (1,241 against 515 real sessions). The dashboard has no session ids by design; the relay counts real sessions. Hours and averages are unaffected.
  • The farm's frame log counts every present, made frames included, so a running frame generation writes more than one row per game frame.
  • The dashboard's own panel queries were not read for #1520; that is its first step. The hitch rule's "game" is the remainder of the frame, and four of the seven parts the counter's Breakdown measures can never win a hitch (#1521).
**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 1. **One frame has six clocks.** (0) the host's clock when the game's present call returns, which also drives the game's own time step; (1) the renderer's present entry on the presenting thread, which feeds the FPS counter and the field summary; (2) the render thread's present job, which feeds the frame trace; (3) after the present call returns, which feeds the frame log and so the farm's frame-time probe; (4) the screen, visible only to PresentMon; (5) the driver's Reflex timings. None of the first four is scan-out. The host and the renderer also read different clock sources, so matching a log row to a trace row means guessing an offset (#1518). 2. **The host, not the renderer, decides game time and the cap.** The game's step is the average of the last five present-call intervals. The cap is enforced three times (the game's own limiter raised to the cap, an acquire sleep with a model of the console's display queue, and a vsync ticker at the cap rate), and the game is told the display cannot do variable refresh. The renderer changes game speed only by changing when `present` returns (#1519). 3. **The present path is not one path.** V-Sync Auto is mailbox where the driver has it, immediate on Windows AMD (no mailbox), FIFO under DLSS frame generation, and FIFO on Linux without mailbox. The Frame pacing row does nothing with frame generation off. 4. **The farm's p99 is a 13th-slowest-frame statistic.** At a 60 cap, 20 s is 1,200 frames. In a simulation with steady 17.4 ms frames, 12 frames of 25 ms leave p99 at 17.5 ms and a 13th makes it 25.0 (+43%); with 33.3 ms frames it jumps to 33.3 (+90%). The mean of the slowest 1% moves smoothly: 17.4, 21.2, 24.4, 25.0 over the same range (#1517). 5. **Same-build noise sits at the gate.** In one farm report on an RX 9070 XT, main against main differed by up to +11.3% in p99 and +12.2% in the 1% low in one cell, and by +28.8% in the 1% low, +98% in the maximum and 0 against 5 stutters in another, against a 15% gate. #1462 failed at +26.9% p99 on one run a side on an RTX 4070 (18.27 against 23.19 ms) while its other two PCs read +3.5% and 0%. Resampling the real histograms, a 10% p99 gate fails with no change 4.0%, 0.0% and 13.9% of the time on the three PCs; the 1% low fails 0.3%, 27.6% and 6.4%. Real windows are less steady than independent frames, so these are floors. 6. **A capped scene hides cost and maybe frame generation.** All four cells of one report have a median of 16.63 to 16.72 ms and the render thread idle about 9 ms of 16.67, so a cheaper renderer would move none of them. The log it keeps has no frame-interpolation line, and by the code a running 2x or 4x would write two to four frame-log rows per game frame, so frame generation probably did not run [INFERENCE]. 7. **The same mean fps can hide very different pacing.** Every window reads 60.0 fps. The share of present intervals outside 15.5 to 17.8 ms is 1.3 to 2.7% in one cell and 28 to 61% in the tails of #1462's logs on three PCs. 8. **A present call is not the screen.** On 16 Nov, with DLSS frame generation and PresentMon on an RTX 5090, the frame log showed no late frame while PresentMon showed 32% (3x) and 45% (4x) of frames on screen less than 2 ms apart. In #1362, #1442 and #1476 that share fell from 33% to 0.0% and the spread of displayed time from 4.7 ms to about 1 ms. 9. **The dashboard's 1% low cannot show a perfect 60 fps.** It is one over the 99th percentile of a histogram with 12 buckets and an edge at 16.7 ms, just above the 16.667 ms period. Maps whose frames are 99% within 20 ms read 49 to 50 fps; a synthetic 60 fps stream reads 50.4 to 50.2 through today's edges and 59.2 to 57.2 with seven more edges near 60 Hz (#1520). 10. **Field averages mix in movies.** 39.5% of the 13.4 million frames at the 60 cap are the title and intro, which lifts the average to 64.4 fps. 11. **Hitch causes are mostly "other".** Of 80,270 hitches in 89 hours, 52.4% are "other", 41.7% "game_cpu", and every renderer cause together is under 6%. At 901 hitches an hour (one every 4 s), loads are included (#1521). ## What it means for the plan - Step 0 starts with one frame record and one clock (#1518), then moves each reader onto it and adds shown time where the platform gives it. - No gate is used before its null pair on that rig and scene; the threshold is the spread of the same build against itself, not a fixed 10 or 20% (#1517, with the farm's side in Beanstalk #88). The proposed gates (frame time, slowest-1% mean, pacing share, shown cadence, latency, game-clock speed, present-path stability, cold-cache stalls, a soak) stay advisory until then. - One pacer with a policy table for the present mode keeps game time stable above 60 fps; any slice that changes when `present` returns has to keep that behaviour (#1519). - Field statistics need finer buckets, queries without the title, and honest hitch causes (#1520, #1521). - Old and new renderers can run on one host and one lifted game, so the pacer and game clock are identical by construction. ## What it could not establish - How far apart the six moments are in each present mode (PresentMon alongside the logs was not run), and which GPUs and drivers expose present timing. - Whether the farm's frame-generation cells made any frames, and which engine. - How often the farm's rule fails with no change on real runs: only a null pair of about 10 same-build pairs can say. - The field's frame generation, V-Sync and present-mode mix, which no label records, and any input-to-screen latency. - The field data is about two days of consented sessions, short ones; rows with fewer than about ten sessions are anecdotes. ## Corrections since it was written - The field helper's sessions column counts map visits (1,241 against 515 real sessions). The dashboard has no session ids by design; the relay counts real sessions. Hours and averages are unaffected. - The farm's frame log counts every present, made frames included, so a running frame generation writes more than one row per game frame. - The dashboard's own panel queries were not read for #1520; that is its first step. The hitch rule's "game" is the remainder of the frame, and four of the seven parts the counter's Breakdown measures can never win a hitch (#1521).
Author
Member

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

  1. No comparable multi-contributor project replaced its whole renderer in one cut. yuzu replaced its texture cache, buffer cache and shader recompiler one after the other (Nov 2020 to Jul 2021). Dolphin unified its back ends over Feb 2018 to Apr 2019. Ryujinx built an abstraction in 2019 and merged Vulkan behind it in 2022. Citra added Vulkan in 2023. RPCS3 tracked a four-tier split from Apr 2024 to Oct 2026. Each worked behind a seam while shipping.
  2. The big replacements were long. yuzu's shader rewrite was 770 commits over 6.5 months, merged as one pull request (428 files); its scope grew and every player's shader cache was invalidated. Its texture cache rewrite spent 38 days in an early-access channel first. RPCS3's redesign was 88 commits and 138 files, "around 2 years of work", merged on 29 Oct 2026.
  3. Only one project tied bugs to conflict resolution in a long-lived branch. RPCS3's author wrote that bugs "had crept in as conflicts got resolved" and used an AI review of a 13,000-line diff to find them. The other pains were different: Ryujinx's year-long Vulkan pull request had softlocks on Intel, and Dolphin's first D3D12 back end died because it carried features that belonged in the shared layer.
  4. RT64 is not a comparable case: written from scratch by mostly one author for a tiny fixed GPU, with no earlier renderer.
  5. Every comparable project cut the seam at the guest GPU's meaning, with a thin host-API layer below. Dolphin's shared layer is 62,009 lines against 10,012 for its Vulkan back end; Ryujinx's GPU layer is 50,537 against 25,764, with a 6,923-line interface between. Longshot's gpu/vk has 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.
  6. About 30% of Longshot's .cpp lines 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.
  7. A tiny interface with default no-ops makes CPU-only tests possible. Dolphin's back-end interface is about 35 virtual methods and its null back end 559 lines; Xenia's null GPU is 194, RPCS3's 62. Longshot's interface is 106 function pointers and mixes renderer calls with host option ids.
  8. Texture and guest-memory coherence is where the others spent their rewrites. The patterns: an explicit state per image (yuzu's flags for CPU-modified, GPU-modified, tracked, alias), a CPU write that marks an image dirty instead of deleting it, and tiered eviction with a delayed-destruction ring. Write tracking is at page level with word-sized bitmaps. Longshot's compiler-inserted write marks avoid faults, so the producer stays and the consumer side is what to borrow.
  9. Flush prediction exists in two projects (Ryujinx, RPCS3). It is the same idea as Longshot's write-back learner; the lesson is a small named policy with a unit test.
  10. Pipeline stalls moved on. "Skip the draw until the pipeline is ready" existed in yuzu and Dolphin, and both moved on. yuzu builds pipelines in parallel without skipping, and DXVK 2.0 compiles at shader creation with pipeline libraries, which shrank its state cache to a few dozen to a few hundred pipelines.
  11. Synchronization has two proven shapes: a render graph for a chain whose pass list is known (Granite, Frostbite), and a central barrier batcher with per-resource last-write tracking for passes the guest orders (Ryujinx's is 465 lines). A render graph cannot own the guest's passes.
  12. Regression nets. Dolphin's FifoCI replays recorded command logs per back end per commit and stores per-frame hashes linked to the parent version; Xenia has trace writing and image diffing; Mesa CI replays public and restricted trace lists against expected checksums. A game-derived corpus should take that shape: corpus private, only hashes and metrics in the repository.

What it means for the plan

  • It supports #1493 and the rework plan: trace replay with image-hash goldens first (plan track T), leaves moved out behind struct contracts (Step 1), and the core rebuilt as a second implementation behind the existing interface, selected at run time. Ryujinx's abstraction-first path and Citra's stack of small pull requests are the models; yuzu's early-access channel is the analogue of our nightly channel.
  • Slice a takes the per-image state machine and dirty-not-delete rule; slice b the barrier batcher and a render graph for the upscale chain only; slice d build-at-creation pipelines; slice e the page-bitmap consumer and a named flush predictor.
  • Two rules from the failures: new features land in shared modules that both cores use, with the old core bug-fix only once a slice starts; and every slice has a written delete condition (Ryujinx kept OpenGL for 15 months after Vulkan merged and still has it).
  • Hardware floors move when you rewrite (yuzu's texture cache needed an extension that excluded older AMD and every Intel iGPU of the time), so the lowest card and system is decided before slice c.

What it could not establish

  • RPCS3's texture-cache internals, Xenia's and shadPS4's caches and Dolphin's eviction were not read in depth.
  • Two sites could not be fetched (RPCS3's blog and fifo.ci). yuzu, Ryujinx and Citra are gone from GitHub and were read through Eden, the Ryubing fork and Azahar.
  • Durations are anchors from the cases, not estimates for Longshot's velocity.
  • The field's support for descriptor indexing, memory budget, pipeline libraries and present timing: no report has it.

Corrections since it was written

  • The report said Longshot skips a draw until its pipeline is ready. More exactly, a draw may be left out only if its targets hold an earlier frame's picture and its stages write no memory; every other draw blocks the replay thread, which runs the compile itself, and a dispatch waits 50 ms and is then dropped for good. The plan's target is that a draw is never dropped.
  • It found no way to record the op stream to a file. #1334 now records one frame and plays it with no game.
  • Its summary said the long branches were where the reported pain was; only RPCS3's author tied bugs to conflict resolution.
  • Longshot's line count here was 84,939 top-level lines; the 85,766 above adds the 827-line switch table.
**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 1. **No comparable multi-contributor project replaced its whole renderer in one cut.** yuzu replaced its texture cache, buffer cache and shader recompiler one after the other (Nov 2020 to Jul 2021). Dolphin unified its back ends over Feb 2018 to Apr 2019. Ryujinx built an abstraction in 2019 and merged Vulkan behind it in 2022. Citra added Vulkan in 2023. RPCS3 tracked a four-tier split from Apr 2024 to Oct 2026. Each worked behind a seam while shipping. 2. **The big replacements were long.** yuzu's shader rewrite was 770 commits over 6.5 months, merged as one pull request (428 files); its scope grew and every player's shader cache was invalidated. Its texture cache rewrite spent 38 days in an early-access channel first. RPCS3's redesign was 88 commits and 138 files, "around 2 years of work", merged on 29 Oct 2026. 3. **Only one project tied bugs to conflict resolution in a long-lived branch.** RPCS3's author wrote that bugs "had crept in as conflicts got resolved" and used an AI review of a 13,000-line diff to find them. The other pains were different: Ryujinx's year-long Vulkan pull request had softlocks on Intel, and Dolphin's first D3D12 back end died because it carried features that belonged in the shared layer. 4. **RT64 is not a comparable case:** written from scratch by mostly one author for a tiny fixed GPU, with no earlier renderer. 5. **Every comparable project cut the seam at the guest GPU's meaning, with a thin host-API layer below.** Dolphin's shared layer is 62,009 lines against 10,012 for its Vulkan back end; Ryujinx's GPU layer is 50,537 against 25,764, with a 6,923-line interface between. Longshot's `gpu/vk` has 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. 6. **About 30% of Longshot's `.cpp` lines 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. 7. **A tiny interface with default no-ops makes CPU-only tests possible.** Dolphin's back-end interface is about 35 virtual methods and its null back end 559 lines; Xenia's null GPU is 194, RPCS3's 62. Longshot's interface is 106 function pointers and mixes renderer calls with host option ids. 8. **Texture and guest-memory coherence is where the others spent their rewrites.** The patterns: an explicit state per image (yuzu's flags for CPU-modified, GPU-modified, tracked, alias), a CPU write that marks an image dirty instead of deleting it, and tiered eviction with a delayed-destruction ring. Write tracking is at page level with word-sized bitmaps. Longshot's compiler-inserted write marks avoid faults, so the producer stays and the consumer side is what to borrow. 9. **Flush prediction exists in two projects** (Ryujinx, RPCS3). It is the same idea as Longshot's write-back learner; the lesson is a small named policy with a unit test. 10. **Pipeline stalls moved on.** "Skip the draw until the pipeline is ready" existed in yuzu and Dolphin, and both moved on. yuzu builds pipelines in parallel without skipping, and DXVK 2.0 compiles at shader creation with pipeline libraries, which shrank its state cache to a few dozen to a few hundred pipelines. 11. **Synchronization has two proven shapes:** a render graph for a chain whose pass list is known (Granite, Frostbite), and a central barrier batcher with per-resource last-write tracking for passes the guest orders (Ryujinx's is 465 lines). A render graph cannot own the guest's passes. 12. **Regression nets.** Dolphin's FifoCI replays recorded command logs per back end per commit and stores per-frame hashes linked to the parent version; Xenia has trace writing and image diffing; Mesa CI replays public and restricted trace lists against expected checksums. A game-derived corpus should take that shape: corpus private, only hashes and metrics in the repository. ## What it means for the plan - It supports #1493 and the rework plan: trace replay with image-hash goldens first (plan track T), leaves moved out behind struct contracts (Step 1), and the core rebuilt as a second implementation behind the existing interface, selected at run time. Ryujinx's abstraction-first path and Citra's stack of small pull requests are the models; yuzu's early-access channel is the analogue of our nightly channel. - Slice a takes the per-image state machine and dirty-not-delete rule; slice b the barrier batcher and a render graph for the upscale chain only; slice d build-at-creation pipelines; slice e the page-bitmap consumer and a named flush predictor. - Two rules from the failures: new features land in shared modules that both cores use, with the old core bug-fix only once a slice starts; and every slice has a written delete condition (Ryujinx kept OpenGL for 15 months after Vulkan merged and still has it). - Hardware floors move when you rewrite (yuzu's texture cache needed an extension that excluded older AMD and every Intel iGPU of the time), so the lowest card and system is decided before slice c. ## What it could not establish - RPCS3's texture-cache internals, Xenia's and shadPS4's caches and Dolphin's eviction were not read in depth. - Two sites could not be fetched (RPCS3's blog and fifo.ci). yuzu, Ryujinx and Citra are gone from GitHub and were read through Eden, the Ryubing fork and Azahar. - Durations are anchors from the cases, not estimates for Longshot's velocity. - The field's support for descriptor indexing, memory budget, pipeline libraries and present timing: no report has it. ## Corrections since it was written - The report said Longshot skips a draw until its pipeline is ready. More exactly, a draw may be left out only if its targets hold an earlier frame's picture and its stages write no memory; every other draw blocks the replay thread, which runs the compile itself, and a dispatch waits 50 ms and is then dropped for good. The plan's target is that a draw is never dropped. - It found no way to record the op stream to a file. #1334 now records one frame and plays it with no game. - Its summary said the long branches were where the reported pain was; only RPCS3's author tied bugs to conflict resolution. - Longshot's line count here was 84,939 top-level lines; the 85,766 above adds the 827-line switch table.
Author
Member

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.

  • Texture identity and the upscalers (budgets, slice a, and the upscaler leaf). The renderer keeps one global counter that moves whenever any texture is destroyed, and the upscaler inputs give up the frame on every move. Fifteen places read the counter. A per-texture record of which ones went would let a frame keep its inputs when an unrelated texture died. This is a new issue.
  • The capture and the re-upload (memory sync, slice e). Two gaps: nothing compares the bytes of a re-upload with what the image already holds, and nothing notices a capture taken while the game was still writing the texture. Another open pull request, #1576, stops the host from writing identical texture data, which may remove most of the first gap, so that issue starts with a count after #1576. The second is a new issue.
  • Pipelines and shaders (pipeline preparation, slice d). The program pick reads and decodes every new program's stage code under the shader lock, and the shader cache key hashes source comments and blank lines. Both are new issues with a counter or a fixture first. The second sits next to #1510 and its fix in #1542.
  • Host layer (parallel track). A race in how the guest's address regions are freed, where the pages can be discarded after another thread was handed the same range. It is read from the code, not reproduced. A new issue.
  • Budgets. The upscaler's feature is never created again after one out-of-memory failure until a setting changes. A new 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

  • Saves written as a transaction with backups: #607 and #1428.
  • A failed texture upload being tried again: #944 and #1162.
  • Opaque ASTC textures kept as BC1: #521.
  • Moving floors above 100 fps: merged in #1528. The report for other platforms in #1550 is still open and #1528 does not cover it.
  • The virtual-core hand-off: main has had a yield fast path for an empty wait queue since #1553. #1503 covers the rest (a lock-free take and give-up of a free core, a per-core waiter count, waits that sleep until the next deadline), and one of its evidence lines about the yield needs a correction, which we will make.
  • Water ripples above 60 fps: #1498.
  • Descriptors kept across draws: #794.
  • Mods' resource sizes inside packs: #942.

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:

  1. Nobody implements from the fork's text. Read the idea, write it against our own code, with the fork's files closed.
  2. Nothing is copied or closely paraphrased, including constants and rules.
  3. Where a change looks like it came from yet another project, it waits for the maintainers to say how it may be used. None of the seven issues depends on one.
  4. Each issue states its evidence from our own code and marks the audit's figures as the fork's claim.

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.

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. - **Texture identity and the upscalers (budgets, slice a, and the upscaler leaf).** The renderer keeps one global counter that moves whenever any texture is destroyed, and the upscaler inputs give up the frame on every move. Fifteen places read the counter. A per-texture record of which ones went would let a frame keep its inputs when an unrelated texture died. This is a new issue. - **The capture and the re-upload (memory sync, slice e).** Two gaps: nothing compares the bytes of a re-upload with what the image already holds, and nothing notices a capture taken while the game was still writing the texture. Another open pull request, #1576, stops the host from writing identical texture data, which may remove most of the first gap, so that issue starts with a count after #1576. The second is a new issue. - **Pipelines and shaders (pipeline preparation, slice d).** The program pick reads and decodes every new program's stage code under the shader lock, and the shader cache key hashes source comments and blank lines. Both are new issues with a counter or a fixture first. The second sits next to #1510 and its fix in #1542. - **Host layer (parallel track).** A race in how the guest's address regions are freed, where the pages can be discarded after another thread was handed the same range. It is read from the code, not reproduced. A new issue. - **Budgets.** The upscaler's feature is never created again after one out-of-memory failure until a setting changes. A new 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 - Saves written as a transaction with backups: #607 and #1428. - A failed texture upload being tried again: #944 and #1162. - Opaque ASTC textures kept as BC1: #521. - Moving floors above 100 fps: merged in #1528. The report for other platforms in #1550 is still open and #1528 does not cover it. - The virtual-core hand-off: main has had a yield fast path for an empty wait queue since #1553. #1503 covers the rest (a lock-free take and give-up of a free core, a per-core waiter count, waits that sleep until the next deadline), and one of its evidence lines about the yield needs a correction, which we will make. - Water ripples above 60 fps: #1498. - Descriptors kept across draws: #794. - Mods' resource sizes inside packs: #942. ## 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: 1. Nobody implements from the fork's text. Read the idea, write it against our own code, with the fork's files closed. 2. Nothing is copied or closely paraphrased, including constants and rules. 3. Where a change looks like it came from yet another project, it waits for the maintainers to say how it may be used. None of the seven issues depends on one. 4. Each issue states its evidence from our own code and marks the audit's figures as the fork's claim. ## 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.
Contributor

🔬 Windows numbers for the CPU track: all lifted chunks at -O2 were +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 -O3 entry in "Tried and ruled out": (Linux, RTX 3090. On Windows with an RTX 4070, all chunks at -O2 gave +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 310e7c9d base, 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 -O1 with 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:

fps, median of 6 (range) -O1 all -O2 Change
Market (child) 69.8 (67.9-70.7) 77.0 (69.9-79.1) +10.3%
Hyrule Field (adult) 95.0 (93.3-97.7) 101.6 (94.6-103.1) +6.9%
Zora's Domain arrival (child) 91.5 (88.7-92.2) 93.3 (89.9-95.6) within the spread

In the Market and Hyrule Field 5 of the 6 -O2 runs are above the best -O1 run; 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 -O3 on 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 with RX_VK_FRAME_TRACE yet.

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_fma32 alone 8.6%, the slow exact recomp_fpe_fma32 3.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 -O2 to 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), and LONGSHOT_SPLIT_GIANTS off for the cloth's hot routine.

🔬 Windows numbers for the CPU track: all lifted chunks at `-O2` were +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](https://git.magicbean.dev/MagicBeanDev/Longshot/wiki/Performance%3A-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 `-O3` entry in "Tried and ruled out": *(Linux, RTX 3090. On Windows with an RTX 4070, all chunks at `-O2` gave +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](https://git.magicbean.dev/MagicBeanDev/Longshot/issues/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 310e7c9d base, 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 `-O1` with 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: | fps, median of 6 (range) | `-O1` | all `-O2` | Change | |---|---|---|---| | Market (child) | 69.8 (67.9-70.7) | 77.0 (69.9-79.1) | +10.3% | | Hyrule Field (adult) | 95.0 (93.3-97.7) | 101.6 (94.6-103.1) | +6.9% | | Zora's Domain arrival (child) | 91.5 (88.7-92.2) | 93.3 (89.9-95.6) | within the spread | In the Market and Hyrule Field 5 of the 6 `-O2` runs are above the best `-O1` run; 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](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1630)). This differs from the Linux result above ("all game code at `-O3` on 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 with `RX_VK_FRAME_TRACE` yet. **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_fma32` alone 8.6%, the slow exact `recomp_fpe_fma32` 3.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 `-O2` to about 72. **These stairs numbers are hand readings** (the bridge can't walk Link there), not timed pairs. **The cloth gate** ([#1628](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/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), and `LONGSHOT_SPLIT_GIANTS` off for the cloth's hot routine.
Member

@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.

@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.
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot#1493
No description provided.