WIP: perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=0 to disable) #2026

Draft
siantm wants to merge 6 commits from siantm/Longshot:perf/nvn-tex-copy-cache into main
Contributor

Summary

A recording keeps the textures it refers to by pointer to an immutable copy (tex_copy in host/nvn_native.c),
because the game may finalize or reuse a texture object after recording, before the submit; the copies are kept in a
table, one per content. Every texture a recording refers to (SetRenderTargets, the texture copies, the blits) went
through that table: FNV-1a a byte at a time over the whole texture object, then pin_lock taken exclusively, by every
recording thread, for a texture bound the same way pass after pass.

With HOS_NVN_TEX_COPY_CACHE on (the default), each recording thread keeps, for 64 slots of object addresses, the copy
it last got there. When the object at that address still holds what the copy holds, that copy is returned without the
hash or the lock. It is the copy the table would give: a copy is told apart by the object's bytes before its serial (the last
member, which a _Static_assert keeps so), read as they are by the table's hash, the table's comparison and the
cache alike (pin_hash, pin_same), and made byte for byte; the table keeps one copy per content, and copies are
never freed or moved (pins_grow moves the table's slots, not the copies), so a kept pointer stays good. A texture
initialized again at the same address with the same content (TOTK's transient targets: a new serial each frame) still
hits; anything else goes to the table. The result expected: fewer hashes of texture objects and fewer exclusive
pin_lock sections on the recording threads; the same copies.

Both ways: the table's hash and comparison read the object's bytes before its serial directly instead of a struct
copy of the object (whose padding need not be kept), a new copy is made byte for byte, and the recordings' log line
(every 50,000 recordings) counts the lookups and those a thread's kept copy answered; each recording thread counts its
own and adds them to the shared totals every 1,024 lookups, so no shared count is touched per lookup (a thread's last
fewer than 1,024 are not added: a short run's low "kept" count is not misses).

The switch: HOS_NVN_TEX_COPY_CACHE (new, a kill switch, bool, its row in gpu/vk/switches.def), on by default,
the value this change proposes, as docs/dev/standards.md (Switches) asks: the Test Farm, testers and the A/B run the
change itself, and it is turned off (or the change dropped) only if a measurement goes against it. =0 (or false,
off, no, empty) is main's lookup, every texture through the table. It is read once, at the first texture a
recording refers to; threads recording together may each read the variable, and all keep the first answer stored. An
empty value in longshot_env.txt on Windows removes the variable (on, as unset). With dyst's review (65645): on by
default again, the row shorter, and the counts' comment says what they leave out.

From the local integration commit d1e33769 on exp/x86-asm-sync, where it had no switch and was not measured. Prior
work: a forge search (tex_copy, pin_hash) finds no pull request on it; #1812 (GummiNaomi, closed unmerged by its author
with no change at 4 or 16 cores) worked on the recordings' copies, not on the texture copies.

Read first: pin_hash, pin_same, tex_copy_cache_on and tex_copy in host/nvn_native.c, then
tests/test_nvn_tex_copy_cache.py.

Testing

Tested: Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head 28c8042e on main 9dd41326. Light job dy-2026-1 of this PC's job queue, every check in a hidden console: tests/test_nvn_tex_copy_cache.py at the test commit 3301d7f7 fails as expected (a removed variable answers off: "HOS_NVN_TEX_COPY_CACHE answers 0 at its first read, 1 expected") and passes at the head; at the head, tests/run_all.py --strict --exact tests/test_nvn_tex_copy_cache.py tests/test_switch_table.py tests/test_recording_log_handoff.py tests/test_host_alloc_wait.py: 4 passed; host/nvn_native.c compiles with the game build's own compile command (syntax only), and, syntax only, for a 64-bit Linux-like target (the Android NDK's clang for x86_64 bionic, host/posix first on the include path), which is not a Linux build: a syntax-only compile (-fsyntax-only, no object) of the game build's command without its profile (PGO) flags (-fprofile-*: the Windows build's profile, which the NDK's clang cannot read), so not the build as shipped. The previous round, at ec5c6569 on main 7c23d2be (job fb-2023-5): the fixture failed on the earlier code and passed at the head, also with no --cc and no CC; tests/run_all.py --strict --changed 7c23d2be: the 9 failures fail on main @ 7c23d2be too (tests/test_crash_dialog.py, tests/test_dev_ab.py, tests/test_dev_packs.py, tests/test_frame_overlap.py, tests/test_host_guest_writes.py, tests/test_linux_pressure.py, tests/test_present_queue_default.py, tests/test_target_reuse_memory.py, tests/test_vk_occlusion_queries.py). The whole suite (mise run test) and lint did not run here (Still to test).

It has NOT run in the game on this PC yet.

Still to test:

  • Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest turning the camera and walking into Link's house and out, and
    Castle Town Market walking through the crowd, on main @ 9dd41326, this PR unset (on) and this PR with
    HOS_NVN_TEX_COPY_CACHE=0, each warmed a minute, then at least three interleaved three-minute runs of each (ABC ABC
    ABC), expecting the same picture, the same texture copies count in the recordings' log line, most lookups answered by
    a kept copy unset, and average fps, 1% lows, median and p99 frame times and peak host memory of this PR unset at
    least those of the other two; a difference beyond the runs' spread is a gain or a loss, one within it is no
    difference measured (by hand)
  • Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest and Castle Town Market, three minutes each on
    main, on this PR unset and on this PR with HOS_NVN_TEX_COPY_CACHE=0, warmed and interleaved, expecting the same
    picture and no FATAL (the test farm: linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest
    and Castle Town Market three minutes, main, this PR unset and HOS_NVN_TEX_COPY_CACHE=0, warmed and interleaved, the
    log, frame times and a screenshot)
  • Linux: build the host (_Thread_local here has been compiled only with Windows clang and, syntax only, for x86_64
    bionic; the fixture's pthread path not at all) and run python3 -I -B tests/test_nvn_tex_copy_cache.py --cc gcc,
    expecting PASS (by hand)
  • A PC with pre-commit and ruff installed: mise run test and mise run lint at this head, expecting every failure to
    fail on main too and lint to pass (by hand; neither tool is installed on this PC)

Measurements

Verdict: not measured in play yet. HOS_NVN_TEX_COPY_CACHE ships on (=0 gives main's lookup); no
micro-benchmark of this port and no run in the game on this PC yet (the branch did not measure it either); the in-game
A/B is in Still to test. The texture copies count alone cannot show it (it counts contents, not lookups); the log
line's lookup counts can.

Risks

What could break: with it on, a recording given a copy of another texture's content would draw with the wrong texture
or target; the cache returns a kept copy only when pin_same finds it equal to the object, the table's own
comparison, and the test checks every copy against its object over 20,000 lookups with objects rewritten in between,
one copy per content, a serial-only change, two threads, and a table grown while full, on and off. Memory with it on:
1 KiB of thread-local slots on each thread that records. With =0, what changes from main: the table hashes and
compares the object's bytes before its serial without copying the object first, makes a copy byte for byte, and the
log line has two more counts. Turn it off: HOS_NVN_TEX_COPY_CACHE=0. Overlaps: no other pull request touches
tex_copy or the copies' table; #1994, #1995, #2022, #2023 and #2025 edit the recordings' log line in
nvnCommandBufferEndRecording near this one's counts: whichever lands second keeps both. Host code: the runtime is
rebuilt; nothing changes for players' saves, options or caches.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.
## Summary A recording keeps the textures it refers to by pointer to an immutable copy (`tex_copy` in `host/nvn_native.c`), because the game may finalize or reuse a texture object after recording, before the submit; the copies are kept in a table, one per content. Every texture a recording refers to (SetRenderTargets, the texture copies, the blits) went through that table: FNV-1a a byte at a time over the whole texture object, then `pin_lock` taken exclusively, by every recording thread, for a texture bound the same way pass after pass. With `HOS_NVN_TEX_COPY_CACHE` on (the default), each recording thread keeps, for 64 slots of object addresses, the copy it last got there. When the object at that address still holds what the copy holds, that copy is returned without the hash or the lock. It is the copy the table would give: a copy is told apart by the object's bytes before its serial (the last member, which a `_Static_assert` keeps so), read as they are by the table's hash, the table's comparison and the cache alike (`pin_hash`, `pin_same`), and made byte for byte; the table keeps one copy per content, and copies are never freed or moved (`pins_grow` moves the table's slots, not the copies), so a kept pointer stays good. A texture initialized again at the same address with the same content (TOTK's transient targets: a new serial each frame) still hits; anything else goes to the table. The result expected: fewer hashes of texture objects and fewer exclusive `pin_lock` sections on the recording threads; the same copies. Both ways: the table's hash and comparison read the object's bytes before its serial directly instead of a struct copy of the object (whose padding need not be kept), a new copy is made byte for byte, and the recordings' log line (every 50,000 recordings) counts the lookups and those a thread's kept copy answered; each recording thread counts its own and adds them to the shared totals every 1,024 lookups, so no shared count is touched per lookup (a thread's last fewer than 1,024 are not added: a short run's low "kept" count is not misses). The switch: `HOS_NVN_TEX_COPY_CACHE` (new, a kill switch, bool, its row in `gpu/vk/switches.def`), **on by default**, the value this change proposes, as docs/dev/standards.md (Switches) asks: the Test Farm, testers and the A/B run the change itself, and it is turned off (or the change dropped) only if a measurement goes against it. `=0` (or `false`, `off`, `no`, empty) is main's lookup, every texture through the table. It is read once, at the first texture a recording refers to; threads recording together may each read the variable, and all keep the first answer stored. An empty value in `longshot_env.txt` on Windows removes the variable (on, as unset). With dyst's review (65645): on by default again, the row shorter, and the counts' comment says what they leave out. From the local integration commit d1e33769 on `exp/x86-asm-sync`, where it had no switch and was not measured. Prior work: a forge search (tex_copy, pin_hash) finds no pull request on it; #1812 (GummiNaomi, closed unmerged by its author with no change at 4 or 16 cores) worked on the recordings' copies, not on the texture copies. Read first: `pin_hash`, `pin_same`, `tex_copy_cache_on` and `tex_copy` in `host/nvn_native.c`, then `tests/test_nvn_tex_copy_cache.py`. ## Testing **Tested:** Windows 11, i7-9700, RTX 4060, the builder's llvm-mingw clang 23; head `28c8042e` on main `9dd41326`. Light job `dy-2026-1` of this PC's job queue, every check in a hidden console: `tests/test_nvn_tex_copy_cache.py` at the test commit `3301d7f7` fails as expected (a removed variable answers off: "HOS_NVN_TEX_COPY_CACHE answers 0 at its first read, 1 expected") and passes at the head; at the head, `tests/run_all.py --strict --exact tests/test_nvn_tex_copy_cache.py tests/test_switch_table.py tests/test_recording_log_handoff.py tests/test_host_alloc_wait.py`: 4 passed; `host/nvn_native.c` compiles with the game build's own compile command (syntax only), and, syntax only, for a 64-bit Linux-like target (the Android NDK's clang for x86_64 bionic, `host/posix` first on the include path), which is not a Linux build: a syntax-only compile (`-fsyntax-only`, no object) of the game build's command without its profile (PGO) flags (`-fprofile-*`: the Windows build's profile, which the NDK's clang cannot read), so not the build as shipped. The previous round, at `ec5c6569` on main `7c23d2be` (job `fb-2023-5`): the fixture failed on the earlier code and passed at the head, also with no `--cc` and no `CC`; `tests/run_all.py --strict --changed 7c23d2be`: the 9 failures fail on main @ 7c23d2be too (`tests/test_crash_dialog.py`, `tests/test_dev_ab.py`, `tests/test_dev_packs.py`, `tests/test_frame_overlap.py`, `tests/test_host_guest_writes.py`, `tests/test_linux_pressure.py`, `tests/test_present_queue_default.py`, `tests/test_target_reuse_memory.py`, `tests/test_vk_occlusion_queries.py`). The whole suite (`mise run test`) and lint did not run here (Still to test). **It has NOT run in the game on this PC yet.** **Still to test:** - Windows 11, i7-9700, RTX 4060 (this PC): Kokiri Forest turning the camera and walking into Link's house and out, and Castle Town Market walking through the crowd, on main @ 9dd41326, this PR unset (on) and this PR with `HOS_NVN_TEX_COPY_CACHE=0`, each warmed a minute, then at least three interleaved three-minute runs of each (ABC ABC ABC), expecting the same picture, the same texture copies count in the recordings' log line, most lookups answered by a kept copy unset, and average fps, 1% lows, median and p99 frame times and peak host memory of this PR unset at least those of the other two; a difference beyond the runs' spread is a gain or a loss, one within it is no difference measured (by hand) - Linux NVIDIA and AMD, Windows AMD and Intel, Steam Deck: Kokiri Forest and Castle Town Market, three minutes each on main, on this PR unset and on this PR with `HOS_NVN_TEX_COPY_CACHE=0`, warmed and interleaved, expecting the same picture and no FATAL (the test farm: linux+nvidia, linux+amd, windows+amd, windows+intel, steamdeck: Kokiri Forest and Castle Town Market three minutes, main, this PR unset and HOS_NVN_TEX_COPY_CACHE=0, warmed and interleaved, the log, frame times and a screenshot) - Linux: build the host (`_Thread_local` here has been compiled only with Windows clang and, syntax only, for x86_64 bionic; the fixture's pthread path not at all) and run `python3 -I -B tests/test_nvn_tex_copy_cache.py --cc gcc`, expecting PASS (by hand) - A PC with pre-commit and ruff installed: `mise run test` and `mise run lint` at this head, expecting every failure to fail on main too and lint to pass (by hand; neither tool is installed on this PC) ## Measurements **Verdict:** not measured in play yet. `HOS_NVN_TEX_COPY_CACHE` ships on (`=0` gives main's lookup); no micro-benchmark of this port and no run in the game on this PC yet (the branch did not measure it either); the in-game A/B is in Still to test. The texture copies count alone cannot show it (it counts contents, not lookups); the log line's lookup counts can. ## Risks What could break: with it on, a recording given a copy of another texture's content would draw with the wrong texture or target; the cache returns a kept copy only when `pin_same` finds it equal to the object, the table's own comparison, and the test checks every copy against its object over 20,000 lookups with objects rewritten in between, one copy per content, a serial-only change, two threads, and a table grown while full, on and off. Memory with it on: 1 KiB of thread-local slots on each thread that records. With `=0`, what changes from main: the table hashes and compares the object's bytes before its serial without copying the object first, makes a copy byte for byte, and the log line has two more counts. Turn it off: `HOS_NVN_TEX_COPY_CACHE=0`. Overlaps: no other pull request touches `tex_copy` or the copies' table; #1994, #1995, #2022, #2023 and #2025 edit the recordings' log line in `nvnCommandBufferEndRecording` near this one's counts: whichever lands second keeps both. Host code: the runtime is rebuilt; nothing changes for players' saves, options or caches. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [ ] Tested on my own PC, in the game for a change the game runs, as Testing says. - [ ] `mise run test` passes (any failure that also fails on `main` is named). - [ ] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [ ] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [ ] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold.
perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=0 to disable)
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
ca876a1056
Every texture a recording refers to (SetRenderTargets, the texture copies, the blits) went through tex_copy's table of
immutable copies: FNV-1a a byte at a time over the whole texture object, then pin_lock taken exclusively, by every
recording thread, for a texture bound the same way pass after pass.

Each thread now keeps, for 64 slots of object addresses, the copy it last got there; when the object at that address
still holds what the copy holds (the bytes before the serial, which a _Static_assert keeps as the last member), that
copy is returned without the hash or the lock. It is the copy the table would give: the table keeps one copy per
content (pin_same: the object with its serial left out), and copies are never freed or moved (pins_grow moves the
table's slots, not the copies they point at), so a kept pointer stays good. A texture initialized again at the address
with the same content (TOTK's transient targets, a new serial each frame) still hits; anything else goes to the table.

From the branch's local integration commit d1e33769 on exp/x86-asm-sync, which had it with no switch and no
measurement ("Not measured yet"). HOS_NVN_TEX_COPY_CACHE (new, kill switch, its row in gpu/vk/switches.def): on by
default, as the branch shipped it; =0 looks every texture up in the table, as before. Read once, published atomically (threads that come first together keep one answer). Not measured.

Test: tests/test_nvn_tex_copy_cache.py compiles the real tex_copy, its switch's reader and the copies' table cut from
the source, and runs 20,000 lookups over 300 object addresses rewritten in between (a new serial with the same content,
another content, another texture's content), on and off, then a second thread: one copy per content, every copy holding
its object's content, the same copies either way; on, a repeated look takes no lock; off, every look takes it.

The test sets the switch in each run's own process (unset, 0, off, No, 1, yes, 2, and 0 again) and sets it the
other way after its first read, which must not change the answer. The C compiler is --cc, $CC, LONGSHOT_MINGW's clang
on Windows, then clang, gcc or cc.

Assisted-by: Claude Code
BeanBot left a comment

Recommendation: Request changes. The cache and the table can disagree about texture bytes because they compare different representations. The fixture also misses the serial-only and thread-local cases that justify the cache, and the default-on speedup remains unproven.

Recording threads can skip the texture hash and exclusive lock when they reuse a texture at the same address. The change adds a 1 KiB thread-local array and a probe on the active path. The replay still receives immutable texture copies, but the two lookup paths need a shared definition of equality.

@fix will do (10)

  1. L1 host/nvn_native.c:2318: The cache compares the stored bytes directly, while pin_same and pin_hash first assign the texture to temporary structs. (more on the line)
  2. L2 (minor) gpu/vk/switches.def:131: The entry says an empty value disables the cache. (more on the line)
  3. L3 tests/test_nvn_tex_copy_cache.py:139: The fixture only checks lock avoidance on an immediate repeat with no intervening write. (more on the line)
  4. L4 tests/test_nvn_tex_copy_cache.py:148: The worker starts after the main thread finishes lookups and only checks the returned pointers. (more on the line)
  5. L5 (minor) tests/test_nvn_tex_copy_cache.py:112: The main thread settles the switch before the worker starts. (more on the line)
  6. L6 (minor) tests/test_nvn_tex_copy_cache.py:80: The fixture creates at most 40 pins, so it never grows a populated table. (more on the line)
  7. L7 tests/test_nvn_tex_copy_cache.py:43: The fixture requires pthreads even on Windows. (more on the line)
  8. L8 (minor) tests/test_nvn_tex_copy_cache.py:174: A compiler command such as CC='ccache gcc' is passed as one executable name, so the test fails before compiling. (more on the line)
  9. L9 (its part an edit can do) host/nvn_native.c:2316: Add profiling-only per-thread hit and miss counters or use lock-wait profiling. Keep shared counters out of the timed hot path.
  10. L10 (minor): The checklist marks current main as verified. The checkout's main is 40bfceb0, seven commits past the stated base 75317e1f. Clear the box until the branch is current, then update the tested commits and rerun the comparison or explain why the results still apply.

For the author (1) (a run, a measurement or a decision)

  • L9 (minor) host/nvn_native.c:2316: The planned texture-copy count measures unique pins, so it can stay the same even if every cache lookup misses. (more on the line)

Checks: Still running: CI / Conventional Commit title (pull_request), CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request), CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request), CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request), CI / Workflow lint (actionlint) (pull_request), CI / Website build and checks (pull_request), Guide screenshots / Guide images and local UI source review (pull_request), Third-party parts / As their notes say (pull_request), Third-party parts / The same as upstream (pull_request).

More: does it help, other systems, switches, what was read

Does it help: Unproven. The PR reports 38 of 47 selected Windows checks passing at ca876a10, including the new fixture and switch-table check. It reports the other nine failures on base 75317e1f as well. The fixture demonstrates that an immediate repeated lookup can avoid the lock. There are no in-game FPS, frame-time, hit-rate or lock-wait measurements.

Other systems: The same host path serves color and depth attachments, buffer-to-texture and texture-to-buffer transfers, texture blits, and texture clears on every Vulkan device. Replay consumes the copies through const pointers, and table growth only moves the slots. Descriptor registration, submit ordering, GPU allocation, save, audio, input and runtime file formats are outside the diff. Windows, Linux and Steam Deck all need gameplay coverage because the host-side change precedes device selection.

Switches: Adds HOS_NVN_TEX_COPY_CACHE, a developer kill switch that defaults to on and has a sorted entry in gpu/vk/switches.def. Setting it to 0 forces table lookups while retaining the switch check. Measurements have yet to establish the right default. The table's empty-value promise disagrees with Windows config-file loading.

Reviewed: ca876a1056 against 75317e1f31: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the developer standards, the full commit and diff, the full new fixture, and all changed host and switch-table lines. Read the relevant texture writers, guest-range and environment helpers, table and recording callers, and Vulkan replay consumers. Skimmed unchanged portions of host/nvn_native.c and the switch table, plus test-runner and build integration. The named Windows logs were absent from the checkout, so the run evidence came from the PR description. docs/review-checklist.md was absent. No generated files or translations changed.; nothing run (a code review).

Checked and fine:

  • The cache index is bounded to 0–63. A zero guest address returns before indexing or dereferencing a slot.
  • The switch cache uses atomic accesses throughout. Relaxed ordering suffices for publishing a standalone boolean, and a losing caller returns the winning value.
  • Pins are initialized under the table lock and remain allocated for the session. Thread-local slots own no heap allocation, and replay gets no new live guest pointer.
  • The diff is one topic. The fixture constructs its own texture values and its subprocesses match the description. No game-derived artifacts, generated files, third-party files or renderer API changes appear. The commit has an Assisted-by trailer.

Testing: Static review only. No build, test or project script was run. The author reports selected Windows checks. The required author-PC gameplay run had yet to happen when the PR opened, and a full suite run, Linux host and GCC verification, Tier 1 gameplay runs and CI results are still outstanding.

Overlaps and merge order: No overlapping open PR identified in the supplied material or checkout history. The description identifies #1812 as closed and covering recording copies.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The cache and the table can disagree about texture bytes because they compare different representations. The fixture also misses the serial-only and thread-local cases that justify the cache, and the default-on speedup remains unproven. Recording threads can skip the texture hash and exclusive lock when they reuse a texture at the same address. The change adds a 1 KiB thread-local array and a probe on the active path. The replay still receives immutable texture copies, but the two lookup paths need a shared definition of equality. **`@fix` will do (10)** 1. **L1** `host/nvn_native.c:2318`: The cache compares the stored bytes directly, while pin_same and pin_hash first assign the texture to temporary structs. (more on the line) 2. **L2** (minor) `gpu/vk/switches.def:131`: The entry says an empty value disables the cache. (more on the line) 3. **L3** `tests/test_nvn_tex_copy_cache.py:139`: The fixture only checks lock avoidance on an immediate repeat with no intervening write. (more on the line) 4. **L4** `tests/test_nvn_tex_copy_cache.py:148`: The worker starts after the main thread finishes lookups and only checks the returned pointers. (more on the line) 5. **L5** (minor) `tests/test_nvn_tex_copy_cache.py:112`: The main thread settles the switch before the worker starts. (more on the line) 6. **L6** (minor) `tests/test_nvn_tex_copy_cache.py:80`: The fixture creates at most 40 pins, so it never grows a populated table. (more on the line) 7. **L7** `tests/test_nvn_tex_copy_cache.py:43`: The fixture requires pthreads even on Windows. (more on the line) 8. **L8** (minor) `tests/test_nvn_tex_copy_cache.py:174`: A compiler command such as CC='ccache gcc' is passed as one executable name, so the test fails before compiling. (more on the line) 9. **L9** (its part an edit can do) `host/nvn_native.c:2316`: Add profiling-only per-thread hit and miss counters or use lock-wait profiling. Keep shared counters out of the timed hot path. 10. **L10** (minor): The checklist marks current main as verified. The checkout's main is 40bfceb0, seven commits past the stated base 75317e1f. Clear the box until the branch is current, then update the tested commits and rerun the comparison or explain why the results still apply. **For the author (1)** (a run, a measurement or a decision) - **L9** (minor) `host/nvn_native.c:2316`: The planned texture-copy count measures unique pins, so it can stay the same even if every cache lookup misses. (more on the line) **Checks:** Still running: `CI / Conventional Commit title (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request)`, `CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request)`, `CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request)`, `CI / Workflow lint (actionlint) (pull_request)`, `CI / Website build and checks (pull_request)`, `Guide screenshots / Guide images and local UI source review (pull_request)`, `Third-party parts / As their notes say (pull_request)`, `Third-party parts / The same as upstream (pull_request)`. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The PR reports 38 of 47 selected Windows checks passing at ca876a10, including the new fixture and switch-table check. It reports the other nine failures on base 75317e1f as well. The fixture demonstrates that an immediate repeated lookup can avoid the lock. There are no in-game FPS, frame-time, hit-rate or lock-wait measurements. **Other systems:** The same host path serves color and depth attachments, buffer-to-texture and texture-to-buffer transfers, texture blits, and texture clears on every Vulkan device. Replay consumes the copies through const pointers, and table growth only moves the slots. Descriptor registration, submit ordering, GPU allocation, save, audio, input and runtime file formats are outside the diff. Windows, Linux and Steam Deck all need gameplay coverage because the host-side change precedes device selection. **Switches:** Adds HOS_NVN_TEX_COPY_CACHE, a developer kill switch that defaults to on and has a sorted entry in gpu/vk/switches.def. Setting it to 0 forces table lookups while retaining the switch check. Measurements have yet to establish the right default. The table's empty-value promise disagrees with Windows config-file loading. **Reviewed:** ca876a105698 against 75317e1f31ff: Read AGENTS.md, CONTRIBUTING.md, the Forgejo template, the developer standards, the full commit and diff, the full new fixture, and all changed host and switch-table lines. Read the relevant texture writers, guest-range and environment helpers, table and recording callers, and Vulkan replay consumers. Skimmed unchanged portions of host/nvn_native.c and the switch table, plus test-runner and build integration. The named Windows logs were absent from the checkout, so the run evidence came from the PR description. docs/review-checklist.md was absent. No generated files or translations changed.; nothing run (a code review). **Checked and fine:** - The cache index is bounded to 0–63. A zero guest address returns before indexing or dereferencing a slot. - The switch cache uses atomic accesses throughout. Relaxed ordering suffices for publishing a standalone boolean, and a losing caller returns the winning value. - Pins are initialized under the table lock and remain allocated for the session. Thread-local slots own no heap allocation, and replay gets no new live guest pointer. - The diff is one topic. The fixture constructs its own texture values and its subprocesses match the description. No game-derived artifacts, generated files, third-party files or renderer API changes appear. The commit has an Assisted-by trailer. **Testing:** Static review only. No build, test or project script was run. The author reports selected Windows checks. The required author-PC gameplay run had yet to happen when the PR opened, and a full suite run, Linux host and GCC verification, Tier 1 gameplay runs and CI results are still outstanding. **Overlaps and merge order:** No overlapping open PR identified in the supplied material or checkout history. The description identifies #1812 as closed and covering recording copies. </details> --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -128,6 +128,7 @@ SW(HOS_NVN_REC_SHIFT, tune, int, "16", "The page shift (12-24) the command recor
SW(HOS_NVN_STRICT, diag, bool, "off: an unimplemented NVN call is logged once and answered 0", "Stops the game at the first NVN call that is not implemented.")
SW(HOS_NVN_SYNC_BLOCK, attempt, bool, "off: nvnSyncWait honours the game's timeout", "An nvnSyncWait poll waits for the GPU without a timeout.")
SW(HOS_NVN_SYNC_LOG, diag, int, "off", "Logs fences, sync waits and event reads with the caller: first 30000, or 400 from the n-th present.")
SW(HOS_NVN_TEX_COPY_CACHE, kill, bool, "on: a recording thread keeps the texture copy it last got for each of 64 object addresses and reuses it while the object holds the same", "=0 (or false, off, no, empty; any other value is on) looks every texture up in the copies' table under its lock, as before. Read once, at the first texture a recording refers to.")
Member

L2 (minor): The entry says an empty value disables the cache. On Windows, putting HOS_NVN_TEX_COPY_CACHE= in longshot_env.txt goes through host/hos_main.c's _putenv, which removes the variable and leaves the cache on. Document 0 as the portable file override and state the empty-value exception, or preserve empty boolean values through file loading and test that path.

**L2** (minor): The entry says an empty value disables the cache. On Windows, putting HOS_NVN_TEX_COPY_CACHE= in longshot_env.txt goes through host/hos_main.c's _putenv, which removes the variable and leaves the cache on. Document 0 as the portable file override and state the empty-value exception, or preserve empty boolean values through file loading and test that path.
@ -2292,0 +2313,4 @@
kept here stays good; a texture initialized again at the address (TOTK's transient targets: a new serial, the
same content) still compares equal, anything else goes to the table. Not measured yet */
static _Thread_local struct { uint64_t at; const nvn_tex *pin; } last[64];
const int cache = tex_copy_cache_on();
Member

L9 (minor): The planned texture-copy count measures unique pins, so it can stay the same even if every cache lookup misses. Interleave base, head off and head unset on matched hardware, builds and player settings in Kokiri Forest and a heavier scene such as Castle Town Market. Report average FPS, 1% lows, median and p99 frame times, cache hits or lock waits, and host memory. Cover the affected Tier 1 configurations before choosing the shipping default.

**L9** (minor): The planned texture-copy count measures unique pins, so it can stay the same even if every cache lookup misses. Interleave base, head off and head unset on matched hardware, builds and player settings in Kokiri Forest and a heavier scene such as Castle Town Market. Report average FPS, 1% lows, median and p99 frame times, cache hits or lock waits, and host memory. Cover the affected Tier 1 configurations before choosing the shipping default.
@ -2292,0 +2315,4 @@
static _Thread_local struct { uint64_t at; const nvn_tex *pin; } last[64];
const int cache = tex_copy_cache_on();
const unsigned k = (unsigned)((t >> 4) ^ (t >> 10)) & 63;
if (cache && last[k].at == t && !memcmp(last[k].pin, o, offsetof(nvn_tex, serial))) {
Member

L1: The cache compares the stored bytes directly, while pin_same and pin_hash first assign the texture to temporary structs. nvn_tex has padding before L and within L, and C struct assignment can change padding. If the copy into the pin leaves different padding from the guest object, an unchanged texture can keep missing the cache even when the table finds the same pin. Use one key for hashing and both comparisons, and preserve its bytes when creating a pin. If padding should be ignored, canonicalize it consistently for all three operations.

**L1**: The cache compares the stored bytes directly, while pin_same and pin_hash first assign the texture to temporary structs. nvn_tex has padding before L and within L, and C struct assignment can change padding. If the copy into the pin leaves different padding from the guest object, an unchanged texture can keep missing the cache even when the table finds the same pin. Use one key for hashing and both comparisons, and preserve its bytes when creating a pin. If padding should be ignored, canonicalize it consistently for all three operations.
@ -0,0 +40,4 @@
ROOT = Path(__file__).resolve().parents[1]
FIXTURE = r"""
#include <pthread.h>
Member

L7: The fixture requires pthreads even on Windows. A checkout using the documented Clang and Visual Studio SDK route can select clang from PATH and then fail on pthread.h. A MinGW fixture linked to a shared pthread runtime also needs that DLL discoverable when launched from the temp directory. Use native Windows threads and a Windows lock in the fixture, and keep pthreads for Linux.

**L7**: The fixture requires pthreads even on Windows. A checkout using the documented Clang and Visual Studio SDK route can select clang from PATH and then fail on pthread.h. A MinGW fixture linked to a shared pthread runtime also needs that DLL discoverable when launched from the temp directory. Use native Windows threads and a Windows lock in the fixture, and keep pthreads for Linux.
@ -0,0 +77,4 @@
@CODE@
#define NOBJ 300
#define NCONTENT 40
Member

L6 (minor): The fixture creates at most 40 pins, so it never grows a populated table. The cache relies on a pin staying valid through that operation. Force a populated resize in the fixture and check that a previously cached address still returns its original pin with the expected lock count.

**L6** (minor): The fixture creates at most 40 pins, so it never grows a populated table. The cache relies on a pin staying valid through that operation. Force a populated resize in the fixture and check that a previously cached address still returns its original pin with the expected lock count.
@ -0,0 +109,4 @@
int main(int argc, char **argv) {
if (argc != 2) return 2;
test_on = atoi(argv[1]);
read_once(tex_copy_cache_on, "HOS_NVN_TEX_COPY_CACHE", test_on);
Member

L5 (minor): The main thread settles the switch before the worker starts. The fixture would pass if the first-use atomic publication were replaced with a racy plain static. Add a concurrent cold-start case that exercises publication, for example using a controlled environment-reader stub and checking that all callers return the same winning value.

**L5** (minor): The main thread settles the switch before the worker starts. The fixture would pass if the first-use atomic publication were replaced with a racy plain static. Add a concurrent cold-start case that exercises publication, for example using a controlled environment-reader stub and checking that all callers return the same winning value.
@ -0,0 +136,4 @@
tex_copy(&pin, (uint64_t)(uintptr_t)&objs[i]);
check(i, pin);
calls++;
if (!changed) { /* (the same lookup again at once: on, this thread's cache has it whatever came before) */
Member

L3: The fixture only checks lock avoidance on an immediate repeat with no intervening write. A cache that also compares serial would pass those checks and miss the transient-target case. Add a deterministic sequence that primes one address, rewrites only its serial, then checks pointer identity and the lock-count delta with the switch on and off.

**L3**: The fixture only checks lock avoidance on an immediate repeat with no intervening write. A cache that also compares serial would pass those checks and miss the transient-target case. Add a deterministic sequence that primes one address, rewrites only its serial, then checks pointer identity and the lock-count delta with the switch on and off.
@ -0,0 +145,4 @@
}
}
pthread_t t;
if (pthread_create(&t, NULL, other, NULL) || pthread_join(t, NULL)) return 35;
Member

L4: The worker starts after the main thread finishes lookups and only checks the returned pointers. Removing _Thread_local would still pass and would let concurrent recorders race on the slot address and pointer. Prime one address on the main thread, assert that the worker's first lookup takes the lock and its repeat hits, then verify the main thread's entry survived the worker replacing its own slot.

**L4**: The worker starts after the main thread finishes lookups and only checks the returned pointers. Removing _Thread_local would still pass and would let concurrent recorders race on the slot address and pointer. Prime one address on the main thread, assert that the worker's first lookup takes the lock and its repeat hits, then verify the main thread's entry survived the worker replacing its own slot.
@ -0,0 +171,4 @@
clone's folder), else clang, gcc or cc on PATH"""
for c in (given, os.environ.get("CC")):
if c:
return shutil.which(c) or c
Member

L8 (minor): A compiler command such as CC='ccache gcc' is passed as one executable name, so the test fails before compiling. Accept a compiler argument vector for CC while preserving literal executable paths, including Windows paths with spaces.

**L8** (minor): A compiler command such as CC='ccache gcc' is passed as one executable name, so the test fails before compiling. Accept a compiler argument vector for CC while preserving literal executable paths, including Windows paths with spaces.
siantm force-pushed perf/nvn-tex-copy-cache from ca876a1056
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 8s
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
to ec5c656995
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
2026-11-21 08:21:49 +00:00
Compare
siantm changed title from WIP: perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=0 to disable) to WIP: perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=1 to try it) 2026-11-21 08:21:59 +00:00
Author
Contributor

Thank you for the review (#issuecomment-64262). Pushed ec5c6569, rebased on main @ 7c23d2be (main has since added only pipeline-state lists, #2041) (the branch's own commit unchanged by the rebase, git range-diff); test commit 9a19cb1f (it fails on the branch's earlier code: queue jobs fb-2026-1 and fb-2023-5), fix ec5c6569. All checks named below ran in queue jobs on this PC (fb-2026-1, fb-2023-5); nothing has run in the game.

Default: there is no measurement in play, so HOS_NVN_TEX_COPY_CACHE is now off by default (kind attempt): unset is main's lookup through the table, =1 turns the kept copies on. The in-game A/B that could turn it on is in Still to test. The title says so.

  • L1 (#issuecomment-64249), two representations: fixed in ec5c6569 with one key, the object's bytes before its serial as they are: pin_hash hashes them and pin_same compares them directly (no struct copy, whose padding need not be kept), the cache compares with pin_same, and a new copy is made with memcpy, so its bytes are the object's. A kept copy is then returned exactly when the table's own comparison finds it equal. The fixture checks every copy the cache returns is the table's copy of that content; with this compiler the struct copies kept the padding, so there is no case that failed before.
  • L2 (#issuecomment-64250), the empty value: fixed in ec5c6569: the row says off unless set, =0 off everywhere, and an empty value in longshot_env.txt on Windows removes the variable (off, as unset); with the default off, an empty value no longer turns anything on or off differently.
  • L3 (#issuecomment-64251), the serial-only case: added in 9a19cb1f: an object looked up, initialized again with only its serial new, then looked up: the same copy, no lock with it on and the lock off; then another content takes the lock and gives that content's copy.
  • L4 (#issuecomment-64252), the thread-local cache: added in 9a19cb1f: the main thread caches an object; a second thread's first look takes the lock and its second does not (on); that thread then looks up every other object (one of them shares the slot); the main thread's next look still takes no lock. The lock count is per thread, so a shared cache fails both checks.
  • L5 (#issuecomment-64253), the cold start: added in 9a19cb1f: a separate build of tex_copy_cache_on with its variable reader replaced by one that waits until eight threads have come in and answers each differently; all eight keep one answer, five runs. The main fixture's first read is a lookup's.
  • L6 (#issuecomment-64254), a populated resize: added in 9a19cb1f: the main thread caches an object, another thread makes 33,000 more copies (the table grows from 65,536 slots while full of copies), and the main thread's next look gives the copy it had, without the lock on and through the grown table off.
  • L7 (#issuecomment-64256), pthreads on Windows: fixed in 9a19cb1f: Windows threads (CreateThread) on Windows, pthreads elsewhere, and the lock is a counting spin lock of the fixture's own, so no pthread header or DLL is needed on Windows.
  • L8 (#issuecomment-64258), the compiler command: fixed in 9a19cb1f: --cc and CC go through tests/compiler_command.py's parse_compiler (a path with spaces kept, a command with arguments split), then LONGSHOT_MINGW's clang, then the clone's llvm-mingw, then clang, gcc or cc. It ran with no --cc and no CC in fb-2023-5.
  • L9 (in 64262, and #issuecomment-64260), hits and the measurement: the edit part is fixed in ec5c6569: each recording thread counts its lookups and those its kept copy answered, and adds them to shared totals every 1,024 lookups (no shared count per lookup); the recordings' log line prints them, off and on. The fixture checks a new thread's 2,048 lookups add 2,048 and 2,047 (on) or 0 (off). The A/B is pending, for the owner: main, this PR unset and with =1 on matched builds and settings in Kokiri Forest and Castle Town Market, with average fps, 1% lows, median and p99 frame times, the log line's lookup counts and host memory, and the Tier 1 runs before a default is chosen; Still to test lists them.
  • L10 (in 64262), the current-main box: the branch is now on main @ 7c23d2be, which Tested names; main has since added only contributed pipeline-state lists (#2041), so the current-main box stays unticked; the checks were run again at the new head (Tested). The whole suite and lint did not run on this PC (pre-commit and ruff are not installed here); they are in Still to test, and the mise run test box stays unticked.
Thank you for the review (#issuecomment-64262). Pushed ec5c6569, rebased on main @ 7c23d2be (main has since added only pipeline-state lists, #2041) (the branch's own commit unchanged by the rebase, `git range-diff`); test commit 9a19cb1f (it fails on the branch's earlier code: queue jobs fb-2026-1 and fb-2023-5), fix ec5c6569. All checks named below ran in queue jobs on this PC (fb-2026-1, fb-2023-5); nothing has run in the game. **Default:** there is no measurement in play, so `HOS_NVN_TEX_COPY_CACHE` is now off by default (kind attempt): unset is main's lookup through the table, `=1` turns the kept copies on. The in-game A/B that could turn it on is in Still to test. The title says so. - **L1** ([#issuecomment-64249](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64249)), two representations: fixed in ec5c6569 with one key, the object's bytes before its serial as they are: `pin_hash` hashes them and `pin_same` compares them directly (no struct copy, whose padding need not be kept), the cache compares with `pin_same`, and a new copy is made with `memcpy`, so its bytes are the object's. A kept copy is then returned exactly when the table's own comparison finds it equal. The fixture checks every copy the cache returns is the table's copy of that content; with this compiler the struct copies kept the padding, so there is no case that failed before. - **L2** ([#issuecomment-64250](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64250)), the empty value: fixed in ec5c6569: the row says off unless set, `=0` off everywhere, and an empty value in `longshot_env.txt` on Windows removes the variable (off, as unset); with the default off, an empty value no longer turns anything on or off differently. - **L3** ([#issuecomment-64251](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64251)), the serial-only case: added in 9a19cb1f: an object looked up, initialized again with only its serial new, then looked up: the same copy, no lock with it on and the lock off; then another content takes the lock and gives that content's copy. - **L4** ([#issuecomment-64252](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64252)), the thread-local cache: added in 9a19cb1f: the main thread caches an object; a second thread's first look takes the lock and its second does not (on); that thread then looks up every other object (one of them shares the slot); the main thread's next look still takes no lock. The lock count is per thread, so a shared cache fails both checks. - **L5** ([#issuecomment-64253](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64253)), the cold start: added in 9a19cb1f: a separate build of `tex_copy_cache_on` with its variable reader replaced by one that waits until eight threads have come in and answers each differently; all eight keep one answer, five runs. The main fixture's first read is a lookup's. - **L6** ([#issuecomment-64254](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64254)), a populated resize: added in 9a19cb1f: the main thread caches an object, another thread makes 33,000 more copies (the table grows from 65,536 slots while full of copies), and the main thread's next look gives the copy it had, without the lock on and through the grown table off. - **L7** ([#issuecomment-64256](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64256)), pthreads on Windows: fixed in 9a19cb1f: Windows threads (`CreateThread`) on Windows, pthreads elsewhere, and the lock is a counting spin lock of the fixture's own, so no pthread header or DLL is needed on Windows. - **L8** ([#issuecomment-64258](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64258)), the compiler command: fixed in 9a19cb1f: `--cc` and `CC` go through `tests/compiler_command.py`'s `parse_compiler` (a path with spaces kept, a command with arguments split), then `LONGSHOT_MINGW`'s clang, then the clone's `llvm-mingw`, then clang, gcc or cc. It ran with no `--cc` and no `CC` in fb-2023-5. - **L9** (in 64262, and [#issuecomment-64260](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-64260)), hits and the measurement: the edit part is fixed in ec5c6569: each recording thread counts its lookups and those its kept copy answered, and adds them to shared totals every 1,024 lookups (no shared count per lookup); the recordings' log line prints them, off and on. The fixture checks a new thread's 2,048 lookups add 2,048 and 2,047 (on) or 0 (off). The A/B is pending, for the owner: main, this PR unset and with `=1` on matched builds and settings in Kokiri Forest and Castle Town Market, with average fps, 1% lows, median and p99 frame times, the log line's lookup counts and host memory, and the Tier 1 runs before a default is chosen; Still to test lists them. - **L10** (in 64262), the current-main box: the branch is now on main @ 7c23d2be, which Tested names; main has since added only contributed pipeline-state lists (#2041), so the current-main box stays unticked; the checks were run again at the new head (Tested). The whole suite and lint did not run on this PC (pre-commit and ruff are not installed here); they are in Still to test, and the `mise run test` box stays unticked.
Author
Contributor

@Beanstalk This adds HOS_NVN_TEX_COPY_CACHE, off by default: with HOS_NVN_TEX_COPY_CACHE=1 the textures NVN recordings refer to (render targets, copies, blits) keep their looked-up copy (host/nvn_native.c); unset, main's way. It has not run in the game on these PCs yet. Please play Kokiri Forest and Hyrule Field, two minutes each, the PR against main on the same PC, on the PR's side with HOS_NVN_TEX_COPY_CACHE=1 and with it unset, with a picture in each compared with main's, on Linux with NVIDIA, Linux with AMD (RADV) and the Steam Deck. The same picture (no wrong or missing textures) and the same texture copies count either way, no crash or FATAL line; set, most lookups answered by a kept copy in the log line and frame time p99 equal to unset or better. Please report that line's counts.

@Beanstalk This adds HOS_NVN_TEX_COPY_CACHE, off by default: with HOS_NVN_TEX_COPY_CACHE=1 the textures NVN recordings refer to (render targets, copies, blits) keep their looked-up copy (host/nvn_native.c); unset, main's way. It has not run in the game on these PCs yet. Please play Kokiri Forest and Hyrule Field, two minutes each, the PR against main on the same PC, on the PR's side with HOS_NVN_TEX_COPY_CACHE=1 and with it unset, with a picture in each compared with main's, on Linux with NVIDIA, Linux with AMD (RADV) and the Steam Deck. The same picture (no wrong or missing textures) and the same texture copies count either way, no crash or FATAL line; set, most lookups answered by a kept copy in the log line and frame time p99 equal to unset or better. Please report that line's counts.
Member

@siantm only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for ec5c656, and the PR has changed since (28c8042), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@siantm only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `ec5c656`, and the PR has changed since (`28c8042`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
dyst left a comment

Verdict: Request changes. The code is right: a kept copy is returned only when the table's own comparison would find it, so the copies are the same either way. Every BeanBot point is fixed in the code. One rule is broken: the switch was turned off because it is unmeasured, and docs/dev/standards.md says a switch ships at its intended default from the first push, "never off just because it is new or unmeasured".

For a player: recording threads skip a byte-at-a-time hash and an exclusive lock for a texture bound the same way pass after pass, so there could be less CPU time on the recording threads. Nothing has measured it yet. The cost is 1 KiB of thread-local slots per recording thread and a memcmp of the object on each lookup, and it changes no picture by design.

Reviewed: ec5c6569 against 7c23d2be (the merge base with main; main is 2 commits further on and merges with no conflict). Read in full: the diff of host/nvn_native.c (pin_hash, pin_same, pins_grow, tex_copy_cache_on, tex_counted, tex_copy and the recordings' log line), the gpu/vk/switches.def row, tests/test_nvn_tex_copy_cache.py and the tests/test_recording_log_handoff.py stub. Also read the code these rely on: nvn_tex in gpu/render/rx_nvn.h, nvnTextureInitialize/Finalize, tex_copy's callers (SetRenderTargets, the B2T/T2B copies, the texture copy, the clear) and env_on. Compared against BeanBot's review at ca876a10 and siantm's reply. Nothing run (a code review).
Fixed in this review: nothing.
Checked and fine:

  • L1 is fixed. The hash, the table's comparison and the cache all read the same key, the bytes before serial, and a copy is now made with memcpy. The _Static_assert keeps serial last with no trailing padding. nvnTextureInitialize memsets the object before filling it, so the padding inside the key is zero and the same at every initialization. A re-initialized transient target therefore compares equal.
  • The cache is the table's answer. The table keeps one copy per content (pin_same ignores the serial), and copies are never freed or moved: only pins_grow touches the slots, and no code frees a pin. So a kept pointer whose bytes match the object is exactly the copy the table would return, and its serial is the first one, as before. A stale slot (another content, or a finalized object with magic 0) fails pin_same and goes to the table.
  • Thread identity doesn't matter for correctness. Each hit checks the content, so a guest thread moving between host threads only costs misses. The slot index is bounded (& 63), and t == 0 returns before it.
  • tex_copy_cache_on publishes with a CAS, so a racing caller returns the winning value.
  • The off path differs from main only in the key reads (no struct copy, 8 fewer bytes hashed) and a thread-local counter. That counter makes one shared atomic add per 1,024 lookups.
  • L2: the row now describes env_on and the Windows _putenv empty-value removal correctly.
  • L3 to L8 are fixed in the fixture:
    • L3, the serial-only case: on, a re-initialization with only a new serial takes no lock.
    • L4, the caches are per thread: a shared cache would fail the other thread's "first look takes the lock".
    • L5, the cold start: the race build fails with a plain racy static.
    • L6, growth: 33,000 copies grow the 65,536-slot table while it is full.
    • L7: Windows threads on Windows.
    • L8: parse_compiler.
  • The fixture fails if the pin_same check on a hit is dropped (the 20,000-lookup loop rewrites objects and checks every copy against them).
  • L9: there are lookup and hit counts in the log line, with no shared write per lookup. L10: the branch is rebased and the box stays unticked.
  • The switches.def row is sorted. The test_recording_log_handoff.py stub is extended, not weakened. One topic, nothing GPL-incompatible.

Blocking (to change before merge)

  1. gpu/vk/switches.def:131 and host/nvn_native.c:2295: the default is off "since nothing of it is measured in the game" (the description and the row). docs/dev/standards.md, Switches: "It ships at that value from the branch's first push, WIP or not ... Never off just because it is new or unmeasured." The value this change is meant to ship at is on, so the Test Farm, testers and the A/B should test the branch with it on by default. As it stands, a tester who doesn't set the variable is testing main's lookup. Fix: make it default on (env_on_or("HOS_NVN_TEX_COPY_CACHE", 1), from longshot_env.h) with =0 as the way back, update the row, the test's CASES (unset is on) and the title. If the A/B then goes against it, turn it off or drop it before leaving WIP, and say which. The code itself is as safe on as off: the copies are the table's.

Suggestions (the author may take or leave)

  • host/nvn_native.c:2309: tex_counted drops the last fewer-than-1,024 counts of a thread that exits, or that records less than that between reports. That is fine for a log line, but say so in the comment, so a low "kept" count on a short run isn't read as misses.
  • The switches.def row reads as a process note ("Read at the first texture ... Not measured in the game"). Once the default is settled, a shorter row is enough: what it does, =0 to turn it off, and where the counts are logged.

Questions

  • None that change the verdict.

Testing: By the author, on Windows 11 with an i7-9700, an RTX 4060 and llvm-mingw clang: the new fixture plus the switch-table, log-handoff and host-alloc checks pass. The fixture fails on the earlier code. run_all --changed has 9 failures, which also fail on main. nvn_native.c compiles (syntax only). It has not run in the game anywhere yet. No in-game A/B, no Linux build, no mise run test and no lint. CI is still pending on the head. A perf change needs its Measurements before leaving WIP. The Linux host build matters here (_Thread_local and the fixture's pthread path have only been built with Windows clang).
Overlaps and merge order: No PR touches tex_copy or the copies' table. Textual only, all in the recordings' log line in nvnCommandBufferEndRecording, which this PR also edits:

  • #1994 and #1995 (both carry the same nvn_native.c change) extend the same hos_log call.
  • #2022, #2023 and #2025 edit nvnCommandBufferEndRecording near it.

Whichever merges second keeps both sets of counts. There is no order between them.

**Verdict: Request changes.** The code is right: a kept copy is returned only when the table's own comparison would find it, so the copies are the same either way. Every BeanBot point is fixed in the code. One rule is broken: the switch was turned off because it is unmeasured, and docs/dev/standards.md says a switch ships at its intended default from the first push, "never off just because it is new or unmeasured". For a player: recording threads skip a byte-at-a-time hash and an exclusive lock for a texture bound the same way pass after pass, so there could be less CPU time on the recording threads. Nothing has measured it yet. The cost is 1 KiB of thread-local slots per recording thread and a memcmp of the object on each lookup, and it changes no picture by design. **Reviewed:** ec5c6569 against 7c23d2be (the merge base with main; main is 2 commits further on and merges with no conflict). Read in full: the diff of `host/nvn_native.c` (`pin_hash`, `pin_same`, `pins_grow`, `tex_copy_cache_on`, `tex_counted`, `tex_copy` and the recordings' log line), the `gpu/vk/switches.def` row, `tests/test_nvn_tex_copy_cache.py` and the `tests/test_recording_log_handoff.py` stub. Also read the code these rely on: `nvn_tex` in `gpu/render/rx_nvn.h`, `nvnTextureInitialize`/`Finalize`, `tex_copy`'s callers (SetRenderTargets, the B2T/T2B copies, the texture copy, the clear) and `env_on`. Compared against BeanBot's review at ca876a10 and siantm's reply. Nothing run (a code review). **Fixed in this review:** nothing. **Checked and fine:** - L1 is fixed. The hash, the table's comparison and the cache all read the same key, the bytes before `serial`, and a copy is now made with `memcpy`. The `_Static_assert` keeps `serial` last with no trailing padding. `nvnTextureInitialize` memsets the object before filling it, so the padding inside the key is zero and the same at every initialization. A re-initialized transient target therefore compares equal. - The cache is the table's answer. The table keeps one copy per content (`pin_same` ignores the serial), and copies are never freed or moved: only `pins_grow` touches the slots, and no code frees a pin. So a kept pointer whose bytes match the object is exactly the copy the table would return, and its serial is the first one, as before. A stale slot (another content, or a finalized object with `magic` 0) fails `pin_same` and goes to the table. - Thread identity doesn't matter for correctness. Each hit checks the content, so a guest thread moving between host threads only costs misses. The slot index is bounded (`& 63`), and `t == 0` returns before it. - `tex_copy_cache_on` publishes with a CAS, so a racing caller returns the winning value. - The off path differs from main only in the key reads (no struct copy, 8 fewer bytes hashed) and a thread-local counter. That counter makes one shared atomic add per 1,024 lookups. - L2: the row now describes `env_on` and the Windows `_putenv` empty-value removal correctly. - L3 to L8 are fixed in the fixture: - L3, the serial-only case: on, a re-initialization with only a new serial takes no lock. - L4, the caches are per thread: a shared cache would fail the other thread's "first look takes the lock". - L5, the cold start: the race build fails with a plain racy static. - L6, growth: 33,000 copies grow the 65,536-slot table while it is full. - L7: Windows threads on Windows. - L8: `parse_compiler`. - The fixture fails if the `pin_same` check on a hit is dropped (the 20,000-lookup loop rewrites objects and checks every copy against them). - L9: there are lookup and hit counts in the log line, with no shared write per lookup. L10: the branch is rebased and the box stays unticked. - The `switches.def` row is sorted. The `test_recording_log_handoff.py` stub is extended, not weakened. One topic, nothing GPL-incompatible. **Blocking** (to change before merge) 1. `gpu/vk/switches.def:131` and `host/nvn_native.c:2295`: the default is off "since nothing of it is measured in the game" (the description and the row). docs/dev/standards.md, Switches: "It ships at that value from the branch's first push, WIP or not ... Never off just because it is new or unmeasured." The value this change is meant to ship at is on, so the Test Farm, testers and the A/B should test the branch with it on by default. As it stands, a tester who doesn't set the variable is testing main's lookup. Fix: make it default on (`env_on_or("HOS_NVN_TEX_COPY_CACHE", 1)`, from `longshot_env.h`) with `=0` as the way back, update the row, the test's CASES (unset is on) and the title. If the A/B then goes against it, turn it off or drop it before leaving WIP, and say which. The code itself is as safe on as off: the copies are the table's. **Suggestions** (the author may take or leave) - `host/nvn_native.c:2309`: `tex_counted` drops the last fewer-than-1,024 counts of a thread that exits, or that records less than that between reports. That is fine for a log line, but say so in the comment, so a low "kept" count on a short run isn't read as misses. - The `switches.def` row reads as a process note ("Read at the first texture ... Not measured in the game"). Once the default is settled, a shorter row is enough: what it does, `=0` to turn it off, and where the counts are logged. **Questions** - None that change the verdict. **Testing:** By the author, on Windows 11 with an i7-9700, an RTX 4060 and llvm-mingw clang: the new fixture plus the switch-table, log-handoff and host-alloc checks pass. The fixture fails on the earlier code. `run_all --changed` has 9 failures, which also fail on main. `nvn_native.c` compiles (syntax only). It has not run in the game anywhere yet. No in-game A/B, no Linux build, no `mise run test` and no lint. CI is still pending on the head. A perf change needs its Measurements before leaving WIP. The Linux host build matters here (`_Thread_local` and the fixture's pthread path have only been built with Windows clang). **Overlaps and merge order:** No PR touches `tex_copy` or the copies' table. Textual only, all in the recordings' log line in `nvnCommandBufferEndRecording`, which this PR also edits: - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1994 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/1995 (both carry the same `nvn_native.c` change) extend the same `hos_log` call. - https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2022, https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2023 and https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2025 edit `nvnCommandBufferEndRecording` near it. Whichever merges second keeps both sets of counts. There is no order between them.
@ -128,6 +128,7 @@ SW(HOS_NVN_REC_SHIFT, tune, int, "16", "The page shift (12-24) the command recor
SW(HOS_NVN_STRICT, diag, bool, "off: an unimplemented NVN call is logged once and answered 0", "Stops the game at the first NVN call that is not implemented.")
SW(HOS_NVN_SYNC_BLOCK, attempt, bool, "off: nvnSyncWait honours the game's timeout", "An nvnSyncWait poll waits for the GPU without a timeout.")
SW(HOS_NVN_SYNC_LOG, diag, int, "off", "Logs fences, sync waits and event reads with the caller: first 30000, or 400 from the n-th present.")
SW(HOS_NVN_TEX_COPY_CACHE, attempt, bool, "off: every texture a recording refers to is looked up in the copies' table under its lock", "=1 (any value but 0, false, off, no or empty): a recording thread keeps the texture copy it last got for each of 64 object addresses and reuses it while the object's bytes before its serial are the copy's. Read at the first texture a recording refers to and cached: threads recording together may each read the variable, and all keep the first answer stored. An empty value in longshot_env.txt on Windows removes the variable: off, as unset; =0 is off everywhere. The recordings' log line counts the lookups and those a kept copy answered. Not measured in the game.")
Member

Off "since nothing of it is measured" is the reason docs/dev/standards.md (Switches) rules out: a switch ships at its intended default from the first push, never off just because it is unmeasured. Default on, =0 the way back; the A/B decides before WIP ends.

Off "since nothing of it is measured" is the reason docs/dev/standards.md (Switches) rules out: a switch ships at its intended default from the first push, never off just because it is unmeasured. Default on, =0 the way back; the A/B decides before WIP ends.
@ -2291,1 +2294,4 @@
}
/* (longshot) Off unless HOS_NVN_TEX_COPY_CACHE is set on: every texture a recording refers to goes through the table, as
before. Not measured in the game */
static int tex_copy_cache_on(void) {
Member

With the default on: env_on_or("HOS_NVN_TEX_COPY_CACHE", 1), and the comment above and the test's CASES (unset: on) to match.

With the default on: env_on_or("HOS_NVN_TEX_COPY_CACHE", 1), and the comment above and the test's CASES (unset: on) to match.
@ -2292,0 +2306,4 @@
}
return on;
}
static void tex_counted(int kept) { /* (this thread's counts, added to tex_looked and tex_kept every 1024 lookups) */
Member

Nit: a thread's last fewer than 1,024 counts are never added (a thread that exits, or a report before its next 1,024). Fine for a log line; worth a word in the comment so a short run's low kept count isn't read as misses.

Nit: a thread's last fewer than 1,024 counts are never added (a thread that exits, or a report before its next 1,024). Fine for a log line; worth a word in the comment so a short run's low kept count isn't read as misses.
siantm force-pushed perf/nvn-tex-copy-cache from ec5c656995
Some checks failed
PR description / Description follows the template (pull_request_target) Successful in 7s
beanstalk/approval waiting for a BigBean's 👍 on the request
Website / Website on Cloudflare (pull_request_target) Has been skipped
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to 28c8042ef1
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
beanstalk/approval waiting for a BigBean's 👍 on the request
2026-11-21 10:57:18 +00:00
Compare
siantm changed title from WIP: perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=1 to try it) to WIP: perf(nvn): a recording thread reuses the texture copy it last got at an address (HOS_NVN_TEX_COPY_CACHE=0 to disable) 2026-11-21 11:01:29 +00:00
Author
Contributor

Thanks for the review, dyst. The branch is rebased on main @ 9dd41326 (its three commits unchanged, now 7803015d, bc7224c1 and a6b83b8c, git range-diff), with three commits on top; head 28c8042e. The checks below ran in light job dy-2026-1 of this PC's job queue (Windows 11, llvm-mingw clang 23).

  • Blocking 1 (#issuecomment-65642, #issuecomment-65643), the default: the default is restored to on per docs/dev/standards.md (Switches), in commit 0f302dd7 (env_on_or("HOS_NVN_TEX_COPY_CACHE", 1), the comment above it, the row's kind kill and =0 to disable, and the title). 3301d7f7 first changed the test's CASES so that a removed variable means on; it fails there ("answers 0 at its first read, 1 expected") and passes at the head, with 0, off, No, false and empty off and 1, yes and 2 on.
  • The row (suggestion): taken in 0f302dd7. It is shorter now: what it does, =0 to turn it off, the Windows empty-value case, when it is read, and where the counts are logged.
  • tex_counted (#issuecomment-65644): the comment in 28c8042e now says that the fewer than 1,024 lookups a thread made since its last addition are not in the log line, so a short run's low "kept" count is not misses. The description says it too.
  • Testing: at the head, tests/run_all.py --strict --exact with test_nvn_tex_copy_cache.py, test_switch_table.py, test_recording_log_handoff.py and test_host_alloc_wait.py: 4 passed; host/nvn_native.c compiles with the game build's command. For the Linux point I also did a syntax-only compile for x86_64 bionic with the Android NDK's clang (host/posix first on the include path). That is not a Linux build, and the fixture's pthread path did not build, so the Linux host build and the GCC run stay in Still to test, with the in-game A/B (unset against =0 and main), mise run test and lint. The PR stays WIP until they exist.
Thanks for the review, dyst. The branch is rebased on main @ 9dd41326 (its three commits unchanged, now 7803015d, bc7224c1 and a6b83b8c, `git range-diff`), with three commits on top; head 28c8042e. The checks below ran in light job `dy-2026-1` of this PC's job queue (Windows 11, llvm-mingw clang 23). - **Blocking 1** ([#issuecomment-65642](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-65642), [#issuecomment-65643](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-65643)), the default: the default is restored to on per docs/dev/standards.md (Switches), in commit 0f302dd7 (`env_on_or("HOS_NVN_TEX_COPY_CACHE", 1)`, the comment above it, the row's kind `kill` and `=0` to disable, and the title). 3301d7f7 first changed the test's CASES so that a removed variable means on; it fails there ("answers 0 at its first read, 1 expected") and passes at the head, with 0, off, No, false and empty off and 1, yes and 2 on. - **The row** (suggestion): taken in 0f302dd7. It is shorter now: what it does, `=0` to turn it off, the Windows empty-value case, when it is read, and where the counts are logged. - **`tex_counted`** ([#issuecomment-65644](https://git.magicbean.dev/MagicBeanDev/Longshot/pulls/2026#issuecomment-65644)): the comment in 28c8042e now says that the fewer than 1,024 lookups a thread made since its last addition are not in the log line, so a short run's low "kept" count is not misses. The description says it too. - **Testing**: at the head, `tests/run_all.py --strict --exact` with `test_nvn_tex_copy_cache.py`, `test_switch_table.py`, `test_recording_log_handoff.py` and `test_host_alloc_wait.py`: 4 passed; `host/nvn_native.c` compiles with the game build's command. For the Linux point I also did a syntax-only compile for x86_64 bionic with the Android NDK's clang (`host/posix` first on the include path). That is not a Linux build, and the fixture's pthread path did not build, so the Linux host build and the GCC run stay in Still to test, with the in-game A/B (unset against `=0` and main), `mise run test` and lint. The PR stays WIP until they exist.
Author
Contributor

@Beanstalk This makes the recording threads reuse NVN texture copies (render targets, copies, blits; host/nvn_native.c), on by default (HOS_NVN_TEX_COPY_CACHE); HOS_NVN_TEX_COPY_CACHE=0 turns it off. This head is on main 9dd41326: please compare with main at that merge base. Please play Kokiri Forest, then Castle Town Market started from the market-entrance save, two minutes each, the PR against main on the same PC, on the PR's side with the switch unset and with HOS_NVN_TEX_COPY_CACHE=0, with a picture in each scene compared with main's, on Windows with AMD, Linux with NVIDIA, Linux with AMD (RADV) and the Steam Deck. The same picture (no wrong or missing textures), no crash or FATAL line; unset, most lookups answered by a kept copy in the 50,000-recording log line, and frame time p99 equal to main's or better and to the switch off. Please report that line.

@Beanstalk This makes the recording threads reuse NVN texture copies (render targets, copies, blits; host/nvn_native.c), on by default (HOS_NVN_TEX_COPY_CACHE); HOS_NVN_TEX_COPY_CACHE=0 turns it off. This head is on main 9dd41326: please compare with main at that merge base. Please play Kokiri Forest, then Castle Town Market started from the market-entrance save, two minutes each, the PR against main on the same PC, on the PR's side with the switch unset and with HOS_NVN_TEX_COPY_CACHE=0, with a picture in each scene compared with main's, on Windows with AMD, Linux with NVIDIA, Linux with AMD (RADV) and the Steam Deck. The same picture (no wrong or missing textures), no crash or FATAL line; unset, most lookups answered by a kept copy in the 50,000-recording log line, and frame time p99 equal to main's or better and to the switch off. Please report that line.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

Tested: the Linux-like target compile (Android NDK clang) was syntax-only and left out the game build's profile (PGO) flags, which that compiler cannot read; the description now says so.

Tested: the Linux-like target compile (Android NDK clang) was syntax-only and left out the game build's profile (PGO) flags, which that compiler cannot read; the description now says so.
Author
Contributor

@Beanstalk One correction to my request 66172 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.

@Beanstalk One correction to my request 66172 above, for its picture point: please take each picture 5 s (300 frames at 60 fps) after the first frame whose picture is not a single uniform colour, with no input in between, and take the main-against-itself picture from the same point. A picture taken during the load's fade-in from black is not comparable: run 70269 on #2156 caught the fade in 3 of 4 starts.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Author
Contributor

@Beanstalk This replaces my request 66172 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This makes the recording threads reuse NVN texture copies (render targets, copies, blits; host/nvn_native.c). Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes; then start again from the market-entrance save, take that picture the same way and play Castle Town Market for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with HOS_NVN_TEX_COPY_CACHE=0 (off), on Windows with an RX 9070 XT, Linux with an RTX 3080 Ti, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to HOS_NVN_TEX_COPY_CACHE=0 or better. The log must have no FATAL line, and no run may crash. No wrong or missing textures. Unset, the 50,000-recording log line must show most lookups answered by a kept copy; please report that line.

@Beanstalk This replaces my request 66172 on this head and the corrections under it, in a form the farm can run: it cannot time a picture from the first frame that is not a uniform colour (its answer on #2131), so each picture here follows a fixed wait after the map event. This makes the recording threads reuse NVN texture copies (render targets, copies, blits; host/nvn_native.c). Please start from the kokiri-start save and take the picture 10 s (600 frames at 60 fps) after the map event that ends the load, a fixed wait with no input in between (the farm cannot time it from the first frame that is not a uniform colour), with a main-against-itself picture on the same PC from the same point; then, for frame times only, play Kokiri Forest for two minutes; then start again from the market-entrance save, take that picture the same way and play Castle Town Market for two minutes; at least two starts a side, interleaved, the PR against main on the same PC, on the PR's side unset (the default, on) and with HOS_NVN_TEX_COPY_CACHE=0 (off), on Windows with an RX 9070 XT, Linux with an RTX 3080 Ti, Linux with an RX 6600 (RADV) and the Steam Deck. The same picture as main within main's own difference from itself; with it unset, frame time p99 equal to main's or better, within the run-to-run spread, and equal to HOS_NVN_TEX_COPY_CACHE=0 or better. The log must have no FATAL line, and no run may crash. No wrong or missing textures. Unset, the 50,000-recording log line must show most lookups answered by a kept copy; please report that line.
Member

@siantm only members of BigBeans can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.

@siantm only members of `BigBeans` can start the farm. One of them can approve this request by reacting 👍 to it or to this comment.
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request) Blocked by required conditions
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 8s
beanstalk/approval waiting for a BigBean's 👍 on the request
This pull request is marked as a work in progress.
Some workflows are waiting to be reviewed.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'perf/nvn-tex-copy-cache:siantm-perf/nvn-tex-copy-cache'
git switch 'siantm-perf/nvn-tex-copy-cache'
Sign in to join this conversation.
No reviewers
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!2026
No description provided.