umem: run on NVIDIA's driver #168

Open
github-bot wants to merge 2 commits from github-bot/gh-168 into main AGit
Owner

@⁠360900 on GitHub · 2026-12-01 23:12 UTC · original
360900:feat/umem-nvidia → main · +636 −110 · 16 files · 2 commits · open

What

umem runs on NVIDIA's proprietary driver. What differs per driver is one struct chosen at device creation (umem/src/driver.rs Driver); RADV's values are the ones in use today.

  • Chunks are memfd pages imported with VK_EXT_external_memory_host: the driver's dma-bufs map at file offset 0 only, and without Resizable BAR 246 MiB of its VRAM is CPU-visible. Every kind is system RAM there (Memory::placed).
  • Windows start at device address 2^37: vertex and index fetch read below 2^40 only.
  • Sparse binds are multiples of 64 KiB (Memory::bind_grain).
  • The windows and the images over a chunk declare the chunks' handle type (Memory::chunk_handle).
  • UMEM_HOST_CHUNKS=1 chooses the chunk source and the 64 KiB on another driver, so the path can be run on the reference card (rule 38).

vkback needs more to run the title on this driver; those are pull requests of their own. Issue #3.

The reference

No counterpart: vkd3d-proton has no title memory at fixed addresses. The driver's behaviour is measured by tests/host_probe.rs (docs/learnings/nvidia.md, docs/tools.md).

Evidence

  • RTX 5080, NVIDIA 620.73.04, Linux 7.3. umem's tests pass on the card (cargo test -p umem --release -- --test-threads=1): 22 unit, gpu 12, sparse_mode 14, the probes.
  • In game with the other changes: start, menus and the first minutes in the world, 10 runs of 300 to 530 s; 53 linear textures in place in a run.
  • Validation run (layer 1.4.363, core, thread safety and shader checks; start to the first minutes in the world, 480 s). Distinct errors, none from this change: the descriptor counts over this driver's limits (VUID-VkPipelineLayoutCreateInfo-descriptorType-03017 and its family, #159), a colour target in a format the card cannot render to (VUID-VkGraphicsPipelineCreateInfo-renderPass-06582 and its family, #158), VUID-vkCmdCopyBuffer-pRegions-12482 in one of two runs (#160). One of the 10 runs lost the device without a driver account (#161).
  • Not shown: RADV. There is no AMD card here; Driver::of gives RADV the constants it had, and UMEM_HOST_CHUNKS=1 is not run there.
  • Known and logged: a sparse window on this driver reports the device-local memory type only and binds the imported pages all the same (docs/learnings/nvidia.md "Memory"; umem says so at the first window).

Checklist (docs/AGENTS.md)

  • One topic (rule 31); docs/TASKS.md not edited (rule 29)
  • "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen
  • No fallback or second path for a case that can't happen (rule 33); unexpected input fails loudly (rule 9): an unknown UMEM_HOST_CHUNKS value and a driver without the handle type for sparse buffers stop the start
  • Constants come from the console, the hardware or the title's data (rule 9b): the driver's limits, measured by the probe
  • Every switch is listed, read in one place, and a bad value stops the start (rule 2): UMEM_HOST_CHUNKS (test)
  • Queues and other externally synchronized Vulkan objects are used under their lock (rule 35): the bind queue as before
  • Every unsafe block has a // SAFETY: comment (rule 36): the new blocks have it
  • Clippy clean; tests call the production code; TRANSLATOR_VERSION: the translator is not touched (rule 27)
  • Comments say what is true now and name functions, not line numbers (rule 3)
  • Nothing from the title, and no pointers to where non-free data can be found
**@⁠360900** on GitHub · 2026-12-01 23:12 UTC · [original](https://github.com/vktory6/VKtory/pull/168) `360900:feat/umem-nvidia` → `main` · +636 −110 · 16 files · 2 commits · open ## What umem runs on NVIDIA's proprietary driver. What differs per driver is one struct chosen at device creation (`umem/src/driver.rs` `Driver`); RADV's values are the ones in use today. - Chunks are memfd pages imported with `VK_EXT_external_memory_host`: the driver's dma-bufs map at file offset 0 only, and without Resizable BAR 246 MiB of its VRAM is CPU-visible. Every kind is system RAM there (`Memory::placed`). - Windows start at device address 2^37: vertex and index fetch read below 2^40 only. - Sparse binds are multiples of 64 KiB (`Memory::bind_grain`). - The windows and the images over a chunk declare the chunks' handle type (`Memory::chunk_handle`). - `UMEM_HOST_CHUNKS=1` chooses the chunk source and the 64 KiB on another driver, so the path can be run on the reference card (rule 38). vkback needs more to run the title on this driver; those are pull requests of their own. Issue #3. ## The reference No counterpart: vkd3d-proton has no title memory at fixed addresses. The driver's behaviour is measured by `tests/host_probe.rs` (docs/learnings/nvidia.md, docs/tools.md). ## Evidence - RTX 5080, NVIDIA 620.73.04, Linux 7.3. umem's tests pass on the card (`cargo test -p umem --release -- --test-threads=1`): 22 unit, gpu 12, sparse_mode 14, the probes. - In game with the other changes: start, menus and the first minutes in the world, 10 runs of 300 to 530 s; 53 linear textures in place in a run. - Validation run (layer 1.4.363, core, thread safety and shader checks; start to the first minutes in the world, 480 s). Distinct errors, none from this change: the descriptor counts over this driver's limits (`VUID-VkPipelineLayoutCreateInfo-descriptorType-03017` and its family, #159), a colour target in a format the card cannot render to (`VUID-VkGraphicsPipelineCreateInfo-renderPass-06582` and its family, #158), `VUID-vkCmdCopyBuffer-pRegions-12482` in one of two runs (#160). One of the 10 runs lost the device without a driver account (#161). - Not shown: RADV. There is no AMD card here; `Driver::of` gives RADV the constants it had, and `UMEM_HOST_CHUNKS=1` is not run there. - Known and logged: a sparse window on this driver reports the device-local memory type only and binds the imported pages all the same (docs/learnings/nvidia.md "Memory"; umem says so at the first window). ## Checklist (docs/AGENTS.md) - [x] One topic (rule 31); `docs/TASKS.md` not edited (rule 29) - [x] "Allow edits by maintainers" on; after review, no force-push and no close-and-reopen - [x] No fallback or second path for a case that can't happen (rule 33); unexpected input fails loudly (rule 9): an unknown `UMEM_HOST_CHUNKS` value and a driver without the handle type for sparse buffers stop the start - [x] Constants come from the console, the hardware or the title's data (rule 9b): the driver's limits, measured by the probe - [x] Every switch is listed, read in one place, and a bad value stops the start (rule 2): `UMEM_HOST_CHUNKS` (test) - [x] Queues and other externally synchronized Vulkan objects are used under their lock (rule 35): the bind queue as before - [x] Every `unsafe` block has a `// SAFETY:` comment (rule 36): the new blocks have it - [x] Clippy clean; tests call the production code; `TRANSLATOR_VERSION`: the translator is not touched (rule 27) - [x] Comments say what is true now and name functions, not line numbers (rule 3) - [x] Nothing from the title, and no pointers to where non-free data can be found
Chunks are memfd pages imported with VK_EXT_external_memory_host where the driver's dma-bufs map at offset 0 only; windows from 2^37, mappings in multiples of 64 KiB (docs/learnings/nvidia.md).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 23:16:43 +00:00
Author
Owner

@⁠tylerstraub on GitHub · 2026-12-01 23:37 UTC · original

A second NVIDIA card for this: RTX 5090 (32 GB), driver 620.73.04, Linux 7.0, Proton Experimental. The machine also has an AMD iGPU. Built from d59b4f8 with #162–#170 merged (all nine merge cleanly).

The probe (cargo test -p umem --release --test host_probe -- --ignored --nocapture) passes and agrees with docs/learnings/nvidia.md:

RTX 5090
window memoryTypeBits 0x2, also when it declares the host handle type
memfd pages as type 2 / type 3 through the window bind ok; 44.5 / 45.6 GB/s stream; one dependent read 404 / 403 µs
VRAM (type 1) through the window bind ok; 214.9 GB/s; one dependent read 6.0 µs
GPU fill seen through a 4 KiB-offset CPU alias, CPU write seen by the GPU, second window view true, true, true (both types)
64 KiB bind + wait 357–361 µs
1,024 scattered 64 KiB binds in one call 11.8–12.0 ms

One correction to the notes. "CPU-visible VRAM: a heap of its own, 246 MiB" is that machine, not the driver. Here the device-local, host-visible, host-coherent type (type 4) lives in the 31.84 GiB heap (resizable BAR on), and VK_EXT_map_memory_placed maps it at a requested address (memoryMapPlaced yes, memoryMapRangePlaced no, so a placed range is a whole allocation). The comment on Driver::host and the "Memory" table could say "246 MiB without resizable BAR". It matters for where this goes next: Memory::placed puts every kind in system RAM by driver, and on a card with the BAR the write-combined kinds could be VRAM bound into the same window (the probe above binds VRAM and imported pages side by side). In our own NVIDIA port of umem, moving the title's write-combined graphics heap into BAR VRAM at its own address took the house scene from 345 to 219 ms a frame (interleaved, 3 runs an arm, no loss). Happy to bring that as a pull request on top of this one once it is in.

umem's tests. Unit 22/22, bench, identity_probe, sparse_probe, sparse_speed, sparse_wait_probe pass. gpu is 11/12 and sparse_mode 10/14 when the binary runs whole (--test-threads=1): the last tests of each fail with Memory::new: Setup("no discrete GPU") (vram_full_spills_to_gtt_write_combined; sparse_pool_views_two_addresses, sparse_span_crosses_runs_up_to_a_hole, sparse_timings, the_title_window_holds_every_title_address_at_its_own_offset). Each passes alone. The same in four runs. It looks as if the NVIDIA device stops being listed after about ten devices in one process, and with an iGPU present the enumeration still succeeds without it. Not traced further; I can run whatever helps.

In game: see my comment on #3 (the stack loses the device on this card while the world loads; one translator change fixes it here).

**@⁠tylerstraub** on GitHub · 2026-12-01 23:37 UTC · [original](https://github.com/vktory6/VKtory/pull/168#issuecomment-7329585154) A second NVIDIA card for this: RTX 5090 (32 GB), driver 620.73.04, Linux 7.0, Proton Experimental. The machine also has an AMD iGPU. Built from `d59b4f8` with #162–#170 merged (all nine merge cleanly). **The probe** (`cargo test -p umem --release --test host_probe -- --ignored --nocapture`) passes and agrees with `docs/learnings/nvidia.md`: | | RTX 5090 | |---|---| | window `memoryTypeBits` | 0x2, also when it declares the host handle type | | memfd pages as type 2 / type 3 through the window | bind ok; 44.5 / 45.6 GB/s stream; one dependent read 404 / 403 µs | | VRAM (type 1) through the window | bind ok; 214.9 GB/s; one dependent read 6.0 µs | | GPU fill seen through a 4 KiB-offset CPU alias, CPU write seen by the GPU, second window view | true, true, true (both types) | | 64 KiB bind + wait | 357–361 µs | | 1,024 scattered 64 KiB binds in one call | 11.8–12.0 ms | **One correction to the notes.** "CPU-visible VRAM: a heap of its own, 246 MiB" is that machine, not the driver. Here the device-local, host-visible, host-coherent type (type 4) lives in the 31.84 GiB heap (resizable BAR on), and `VK_EXT_map_memory_placed` maps it at a requested address (`memoryMapPlaced` yes, `memoryMapRangePlaced` no, so a placed range is a whole allocation). The comment on `Driver::host` and the "Memory" table could say "246 MiB without resizable BAR". It matters for where this goes next: `Memory::placed` puts every kind in system RAM by driver, and on a card with the BAR the write-combined kinds could be VRAM bound into the same window (the probe above binds VRAM and imported pages side by side). In our own NVIDIA port of umem, moving the title's write-combined graphics heap into BAR VRAM at its own address took the house scene from 345 to 219 ms a frame (interleaved, 3 runs an arm, no loss). Happy to bring that as a pull request on top of this one once it is in. **umem's tests.** Unit 22/22, `bench`, `identity_probe`, `sparse_probe`, `sparse_speed`, `sparse_wait_probe` pass. `gpu` is 11/12 and `sparse_mode` 10/14 when the binary runs whole (`--test-threads=1`): the last tests of each fail with `Memory::new: Setup("no discrete GPU")` (`vram_full_spills_to_gtt_write_combined`; `sparse_pool_views_two_addresses`, `sparse_span_crosses_runs_up_to_a_hole`, `sparse_timings`, `the_title_window_holds_every_title_address_at_its_own_offset`). Each passes alone. The same in four runs. It looks as if the NVIDIA device stops being listed after about ten devices in one process, and with an iGPU present the enumeration still succeeds without it. Not traced further; I can run whatever helps. **In game:** see my comment on #3 (the stack loses the device on this card while the world loads; one translator change fixes it here).
Author
Owner

@⁠tylerstraub on GitHub · 2026-12-02 00:25 UTC · original

Split the driver-independent half of this out as #178 so it can go in on its own (your names kept, so this rebases onto it by taking your side in each conflict). Not trying to step on it; happy to adjust if you'd rather shape it differently.

**@⁠tylerstraub** on GitHub · 2026-12-02 00:25 UTC · [original](https://github.com/vktory6/VKtory/pull/168#issuecomment-7330537452) Split the driver-independent half of this out as #178 so it can go in on its own (your names kept, so this rebases onto it by taking your side in each conflict). Not trying to step on it; happy to adjust if you'd rather shape it differently.
Author
Owner

@⁠360900 on GitHub · 2026-12-02 12:08 UTC · original

The 246 MiB is this machine without Resizable BAR; corrected in 1572563. No objection to #178: if it lands first, I merge main into this. Yes to the BAR VRAM pull request on top of this. The "no discrete GPU" failures do not show here with one GPU.

**@⁠360900** on GitHub · 2026-12-02 12:08 UTC · [original](https://github.com/vktory6/VKtory/pull/168#issuecomment-7344896841) The 246 MiB is this machine without Resizable BAR; corrected in 1572563. No objection to #178: if it lands first, I merge main into this. Yes to the BAR VRAM pull request on top of this. The "no discrete GPU" failures do not show here with one GPU.
Author
Owner

@⁠360900 on GitHub · 2026-12-02 14:28 UTC · original

@⁠tylerstraub is the branch with the write-combined heaps in BAR VRAM public anywhere? A draft pull request on top of this one works too. I can run it on the 5080 with Resizable BAR on and off.

**@⁠360900** on GitHub · 2026-12-02 14:28 UTC · [original](https://github.com/vktory6/VKtory/pull/168#issuecomment-7348616322) @⁠tylerstraub is the branch with the write-combined heaps in BAR VRAM public anywhere? A draft pull request on top of this one works too. I can run it on the 5080 with Resizable BAR on and off.
This pull request has changes conflicting with the target branch.
  • greenfield/umem/src/driver.rs
  • greenfield/umem/src/lib.rs
  • greenfield/vkback/src/imgmake.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/168/head:github-bot/gh-168'
git switch 'github-bot/gh-168'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-168'
git switch 'github-bot/gh-168'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-168'
git switch 'github-bot/gh-168'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-168'
git switch 'main'
git merge --squash 'github-bot/gh-168'
git switch 'main'
git merge --ff-only 'github-bot/gh-168'
git switch 'main'
git merge 'github-bot/gh-168'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.