fix(vk): the renderer links on Linux again: radv_import_headroom is defined in the anonymous namespace it is declared in #1961

Merged
HumanBean merged 1 commit from HumanBean/Longshot:fix/radv-headroom-link into main 2026-11-21 01:48:14 +00:00
Owner

Summary

On Linux, main does not build since #1933: the renderer, longshot_vk.so, links with an unresolved symbol and the build refuses it (longshot_vk.so has 1 unresolved symbol(s); it would not load: mkwvk::(anonymous namespace)::radv_import_headroom(unsigned long)).

gpu/vk/vk_memory.cpp declares radv_import_headroom in mkwvk's anonymous namespace, above import_dma_buf, its one caller, but #1933 defined it at mkwvk scope, further down. That is a different function, so the call is left unresolved. Windows never compiles the function (#ifdef __linux__), so only Linux builds break.

This puts the definition in an anonymous namespace too, so it is the function that was declared. Nothing else changes. Read gpu/vk/vk_memory.cpp at radv_import_headroom.

To see it on main: python -I scripts/dev.py pack (or any Linux build of the renderer) on Linux stops with the error above.

Testing

Tested: CachyOS (Linux 7.3.3), NVIDIA GeForce RTX 3090, driver 620.70. Built as a pack over a shared base with dev.py pack: on main @ 00e0dc93 the renderer build stops with the unresolved symbol, and here it links in 27 s (nm on the object: the call and the definition are now the same mkwvk::(anonymous namespace)::radv_import_headroom). Ran the game: the renderer loads, DLSS starts (NVIDIA DLSS: NGX started, Auto: DLSS Quality) and start-up's pipeline preparation runs.

No game-free test is added: the renderer build's own check (every symbol of longshot_vk.so resolves, or it refuses to finish) is the test. It fails on main and passes here.

Still to test:

  • Linux RADV (Steam Deck or another AMD GPU): play an area with large imports under memory pressure, expecting the vk: RADV system heap ... released ... MB of capture spares line when it releases spares, as #1933 meant (@Beanstalk on the Steam Deck)

Measurements

Nothing to measure: this fixes the link. The function's behaviour is #1933's, unchanged.

Risks

None beyond #1933's own: the same function now links. A revert brings back the broken Linux build. Players notice nothing after updating except that Linux builds work again.

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). (not run on this PC; for CI)
  • 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 fix: a game-free test that fails on main and passes here. (the renderer build's symbol check is the test, see Testing; no new test file)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

## Summary On Linux, `main` does not build since #1933: the renderer, `longshot_vk.so`, links with an unresolved symbol and the build refuses it (`longshot_vk.so has 1 unresolved symbol(s); it would not load: mkwvk::(anonymous namespace)::radv_import_headroom(unsigned long)`). `gpu/vk/vk_memory.cpp` declares `radv_import_headroom` in `mkwvk`'s anonymous namespace, above `import_dma_buf`, its one caller, but #1933 defined it at `mkwvk` scope, further down. That is a different function, so the call is left unresolved. Windows never compiles the function (`#ifdef __linux__`), so only Linux builds break. This puts the definition in an anonymous namespace too, so it is the function that was declared. Nothing else changes. Read `gpu/vk/vk_memory.cpp` at `radv_import_headroom`. To see it on `main`: `python -I scripts/dev.py pack` (or any Linux build of the renderer) on Linux stops with the error above. ## Testing **Tested:** CachyOS (Linux 7.3.3), NVIDIA GeForce RTX 3090, driver 620.70. Built as a pack over a shared base with `dev.py pack`: on `main` @ 00e0dc93 the renderer build stops with the unresolved symbol, and here it links in 27 s (`nm` on the object: the call and the definition are now the same `mkwvk::(anonymous namespace)::radv_import_headroom`). Ran the game: the renderer loads, DLSS starts (`NVIDIA DLSS: NGX started`, Auto: DLSS Quality) and start-up's pipeline preparation runs. No game-free test is added: the renderer build's own check (every symbol of `longshot_vk.so` resolves, or it refuses to finish) is the test. It fails on `main` and passes here. **Still to test:** - Linux RADV (Steam Deck or another AMD GPU): play an area with large imports under memory pressure, expecting the `vk: RADV system heap ... released ... MB of capture spares` line when it releases spares, as #1933 meant (@Beanstalk on the Steam Deck) ## Measurements Nothing to measure: this fixes the link. The function's behaviour is #1933's, unchanged. ## Risks None beyond #1933's own: the same function now links. A revert brings back the broken Linux build. Players notice nothing after updating except that Linux builds work again. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] 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). (not run on this PC; for CI) - [x] 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 fix: a game-free test that fails on `main` and passes here. (the renderer build's symbol check is the test, see Testing; no new test file) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(vk): the renderer links on Linux again: radv_import_headroom is defined in the anonymous namespace it is declared in (#1933)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 14s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 20s
CI / Workflow lint (actionlint) (pull_request) Successful in 21s
Third-party parts / As their notes say (pull_request) Successful in 23s
PR description / Description follows the template (pull_request_target) Failing after 8s
CI / Website build and checks (pull_request) Failing after 13s
368930361b
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Tested in game: CachyOS (Linux 7.3.3), RTX 3090, NVIDIA 620.70: latest main + this fix built as a pack; the renderer loads, DLSS starts (NGX started, Auto picked DLSS Quality), start-up pipeline preparation runs. On main the renderer build stops with the unresolved radv_import_headroom.

Tested in game: CachyOS (Linux 7.3.3), RTX 3090, NVIDIA 620.70: latest main + this fix built as a pack; the renderer loads, DLSS starts (NGX started, Auto picked DLSS Quality), start-up pipeline preparation runs. On main the renderer build stops with the unresolved radv_import_headroom.
HumanBean changed title from WIP: fix(vk): the renderer links on Linux again: radv_import_headroom is defined in the anonymous namespace it is declared in to fix(vk): the renderer links on Linux again: radv_import_headroom is defined in the anonymous namespace it is declared in 2026-11-21 01:48:08 +00:00
HumanBean deleted branch fix/radv-headroom-link 2026-11-21 01:48:15 +00:00
BeanBot left a comment

Recommendation: Request changes. The namespace fix restores Linux builds. Add game-free coverage that catches this link failure before merge, and shorten the capture-spare lock hold before validating the newly reachable path on RADV.

Linux players can build and load the renderer again. The two-line namespace change correctly matches the existing declaration to its definition. On RADV, that also makes #1933's synchronous spare reclaim reachable when a large DMA-BUF import approaches the system-heap budget.

Does it help: Yes for the link fix. On the author's CachyOS RTX 3090 setup with driver 620.70, the shared-base pack at 00e0dc93 stopped on one unresolved renderer symbol. The pack at 368930361b linked in 27 seconds and loaded in game. That is a build result, with no performance comparison. RADV memory-pressure behavior and transition timing remain unproven.
Other systems: Windows preprocesses out the declaration, caller and definition. Linux source, Launcher and AppImage builds share the renderer build path. NVIDIA skips DMA-BUF imports, and other non-RADV drivers return before taking the spare lock. The NVIDIA run reached DLSS and startup pipeline preparation. RADV on desktop AMD and Steam Deck still needs coverage. The diff leaves renderer ABI, save and cache formats, replay ordering, audio and input untouched.
Switches: None.

Reviewed: 368930361b against 00e0dc93a9: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, docs/dev/standards.md, the fix-with-test guidance, the complete diff and commit, the PR description and the test comment. Read the changed region of gpu/vk/vk_memory.cpp in full and traced the declaration, import callers, spare ownership and allocator calls. Read the relevant game-free fixtures, symbol guard, PR checker and CI routing. Unrelated parts of vk_memory.cpp and its callers, and the rest of the build and CI files, were outside those reads. No docs/review-checklist.md was present and no recorded run files were supplied.; nothing run (a code review).
Checked and fine:

  • Both anonymous namespace blocks are in mkwvk in the same translation unit. system_heap_usage stays at mkwvk scope and still resolves to vk_vma.cpp.
  • The caller validates the positive import length before calling the helper. The spare copy, removal and byte accounting are protected by cap_free_mu, and the free list owns the selected buffers after GPU completion.
  • The diff changes one renderer source file, adds no external actions or game-derived material, and touches no generated files, shaders, vendor code or public API. The title and AI co-author trailer meet the repository rules.

Blocking (to change before merge)

  1. gpu/vk/vk_memory.cpp:5397: Removing these namespace braces leaves both focused fixtures green. The headroom fixture extracts the body without its enclosing scope, and the import fixture stubs the helper. The default GPU-only PR routing also skips the Linux AppImage job that links the real renderer. Make the existing game-free Linux renderer link and symbol check run for renderer-source PRs, or add an equivalent game-free link check that preserves the real scopes. Record the unresolved symbol on base and the passing result on head.
  2. gpu/vk/vk_memory.cpp:5400: Once this call links, a background RADV import near budget can hold cap_free_mu across the driver budget query and several Vulkan frees. A recording thread trying to take a spare then waits for that driver work. Move the budget query outside the spare-list critical section, then remove and account for the selected spares under the mutex. Release the mutex before destroying them synchronously, so the importing thread still frees them before allocating.

Waiting on the author (a run, a measurement or a decision; no edit does it)

  • The RTX 3090 startup run cannot exercise RADV reclaim. Run the planned Steam Deck test and the #1933 pressure case on discrete RADV. Confirm the import and subsequent submission succeed, record the available budget and bytes reclaimed, and compare transition frame times and replacement capture allocations against a buildable baseline with reclaim disabled. Even after shortening the lock hold, the importing thread still pays for synchronous frees.
  • The required checks have no result for 368930361b and the test checklist box is open. Report lint and the full game-free suite or equivalent CI results on head, confirm any failures against 00e0dc93, and update the checklist. In particular, #1933 already reported the missing pool_pressed marker in test_linux_pressure.py, which is still absent from vk_texture.cpp.

Testing: The author's Linux pack comparison and NVIDIA startup smoke demonstrate the link fix. The game-free Linux renderer build can exercise the existing symbol guard without the game. The supplied evidence has no standalone before-and-after check, full-suite or head CI result, or RADV run. This review was read-only.
Overlaps and merge order: #1933 is already in the base and introduced the mismatch. No competing fix was found in the available Git history.


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 namespace fix restores Linux builds. Add game-free coverage that catches this link failure before merge, and shorten the capture-spare lock hold before validating the newly reachable path on RADV. Linux players can build and load the renderer again. The two-line namespace change correctly matches the existing declaration to its definition. On RADV, that also makes #1933's synchronous spare reclaim reachable when a large DMA-BUF import approaches the system-heap budget. **Does it help:** Yes for the link fix. On the author's CachyOS RTX 3090 setup with driver 620.70, the shared-base pack at 00e0dc93 stopped on one unresolved renderer symbol. The pack at 368930361b72 linked in 27 seconds and loaded in game. That is a build result, with no performance comparison. RADV memory-pressure behavior and transition timing remain unproven. **Other systems:** Windows preprocesses out the declaration, caller and definition. Linux source, Launcher and AppImage builds share the renderer build path. NVIDIA skips DMA-BUF imports, and other non-RADV drivers return before taking the spare lock. The NVIDIA run reached DLSS and startup pipeline preparation. RADV on desktop AMD and Steam Deck still needs coverage. The diff leaves renderer ABI, save and cache formats, replay ordering, audio and input untouched. **Switches:** None. **Reviewed:** 368930361b72 against 00e0dc93a9f8: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, docs/dev/standards.md, the fix-with-test guidance, the complete diff and commit, the PR description and the test comment. Read the changed region of gpu/vk/vk_memory.cpp in full and traced the declaration, import callers, spare ownership and allocator calls. Read the relevant game-free fixtures, symbol guard, PR checker and CI routing. Unrelated parts of vk_memory.cpp and its callers, and the rest of the build and CI files, were outside those reads. No docs/review-checklist.md was present and no recorded run files were supplied.; nothing run (a code review). **Checked and fine:** - Both anonymous namespace blocks are in mkwvk in the same translation unit. system_heap_usage stays at mkwvk scope and still resolves to vk_vma.cpp. - The caller validates the positive import length before calling the helper. The spare copy, removal and byte accounting are protected by cap_free_mu, and the free list owns the selected buffers after GPU completion. - The diff changes one renderer source file, adds no external actions or game-derived material, and touches no generated files, shaders, vendor code or public API. The title and AI co-author trailer meet the repository rules. **Blocking** (to change before merge) 1. gpu/vk/vk_memory.cpp:5397: Removing these namespace braces leaves both focused fixtures green. The headroom fixture extracts the body without its enclosing scope, and the import fixture stubs the helper. The default GPU-only PR routing also skips the Linux AppImage job that links the real renderer. Make the existing game-free Linux renderer link and symbol check run for renderer-source PRs, or add an equivalent game-free link check that preserves the real scopes. Record the unresolved symbol on base and the passing result on head. 2. gpu/vk/vk_memory.cpp:5400: Once this call links, a background RADV import near budget can hold cap_free_mu across the driver budget query and several Vulkan frees. A recording thread trying to take a spare then waits for that driver work. Move the budget query outside the spare-list critical section, then remove and account for the selected spares under the mutex. Release the mutex before destroying them synchronously, so the importing thread still frees them before allocating. **Waiting on the author** (a run, a measurement or a decision; no edit does it) - The RTX 3090 startup run cannot exercise RADV reclaim. Run the planned Steam Deck test and the #1933 pressure case on discrete RADV. Confirm the import and subsequent submission succeed, record the available budget and bytes reclaimed, and compare transition frame times and replacement capture allocations against a buildable baseline with reclaim disabled. Even after shortening the lock hold, the importing thread still pays for synchronous frees. - The required checks have no result for 368930361b72 and the test checklist box is open. Report lint and the full game-free suite or equivalent CI results on head, confirm any failures against 00e0dc93, and update the checklist. In particular, #1933 already reported the missing pool_pressed marker in test_linux_pressure.py, which is still absent from vk_texture.cpp. **Testing:** The author's Linux pack comparison and NVIDIA startup smoke demonstrate the link fix. The game-free Linux renderer build can exercise the existing symbol guard without the game. The supplied evidence has no standalone before-and-after check, full-suite or head CI result, or RADV run. This review was read-only. **Overlaps and merge order:** #1933 is already in the base and introduced the mismatch. No competing fix was found in the available Git history. --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -5394,6 +5394,7 @@ bool system_heap_usage(uint64_t* used, uint64_t* budget); // (vk_vma.cpp; said
// Near RADV's system-heap budget, make room before importing. Only completed capture spares
// can be destroyed here. The budget and spare sizes are estimates, so leave the ordinary
// import and fallback in charge when there is too little reclaimable memory.
namespace { // (declared in the anonymous namespace above import_dma_buf, its one caller)
Member

Undoing these braces leaves both focused fixtures green. Default GPU-only PR CI skips the Linux renderer link. Gate renderer PRs on the existing game-free Linux link and symbol check, or add a scope-preserving link fixture.

Undoing these braces leaves both focused fixtures green. Default GPU-only PR CI skips the Linux renderer link. Gate renderer PRs on the existing game-free Linux link and symbol check, or add a scope-preserving link fixture.
@ -5397,3 +5397,4 @@
namespace { // (declared in the anonymous namespace above import_dma_buf, its one caller)
void radv_import_headroom(uint64_t bytes) {
constexpr uint64_t large_import = 64ull << 20, submit_reserve = 64ull << 20;
if (dev.driver_id != VK_DRIVER_ID_MESA_RADV || bytes < large_import) return;
Member

A background import can block capture-spare reuse while the driver queries the budget and frees buffers under cap_free_mu. Remove and account for selected spares under the lock, then do the synchronous frees after unlocking and before the import.

A background import can block capture-spare reuse while the driver queries the budget and frees buffers under cap_free_mu. Remove and account for selected spares under the lock, then do the synchronous frees after unlocking and before the import.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!1961
No description provided.