umem: what it asks of the driver in one struct (driver.rs) #178
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/vktory6--VKtory!178
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-178"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tylerstraub on GitHub · 2026-12-02 00:24 UTC · original
tylerstraub:umem-driver-seam→main· +81 −55 · 6 files · 1 commits · merged 2026-12-02 17:35 UTCWhat
Why: so that forks for drivers VKtory does not support can carry their differences in their own files, instead of patching umem's call sites and re-doing that after every merge from here. This is not a request to support another driver: nothing but RADV's values is added, and every line can be checked on the reference card.
What umem asks of the driver is read from one struct,
Driver(umem/src/driver.rs), chosen once inMemory::new, instead of from constants at each call site:bias: the device address asked for title address 0 (BIAS_REQUEST,Memory::window;Memory::bias_request, whichtests/sparse_probe.rsnow reads instead of its own copy of the constant).handle()/ext(): the chunks' handle type (EXPORT) and its device extension, used at setup, inmake_chunkand on the windows. vkback's in-place linear images take it fromMemory::chunk_handleinstead ofumem::EXPORT.placed(kind): the kind a request is placed in (the kind asked for), incommit_prot,create_poolandpool_view_with.Also driver-independent: a buried chunk keeps its
RawChunk, soreap,reap_allandfree_raw_chunkfree it through one function. Before, the same code was in three places (rule 33), andreap_all's SAFETY comment namedmemfd_create, which none of them uses.Credit: this is the driver-independent half of #168 by @360900, split out so it can be reviewed and merged on its own. It keeps #168's names and signatures (
Driver,bias,handle,ext,placed,bias_request,chunk_handle, theRawChunkinDead), so #168 rebases onto it: merged onto this branch, #168 has 8 conflict hunks (driver.rs 1, lib.rs 6, imgmake.rs 1), each resolved by taking #168's side, and the result is #168's tree exactly. Its change toumem/srcandvkback/srcgoes from 261 changed lines in 5 files to 171 in 3. Left for #168: the sparse bind grain (NVIDIA binds in 64 KiB), which is a new check and not a moved value.I keep a local NVIDIA fork (RTX 5090, results on #3). With this in, a fork for another driver changes
driver.rsand its chunk source, and no other call site.Related: the
docs/TASKS.mditem "umem's lib.rs holds six separable responsibilities". This does not split anything, but per-driver facts no longer live inlib.rs.lib.rsgrows by 10 lines, to 1,463.The reference
No counterpart: vkd3d-proton has no title memory at fixed addresses.
Evidence
Driver::of()returnsBIAS_REQUEST,handle()isEXPORT,ext()isVK_KHR_external_memory_fdandplacedis the identity. Every replaced use took exactly that constant before. The only visible difference is the text of one setup error ("no OPAQUE_FD memory for sparse buffers" instead of "no opaque-fd export"). So under rule 30 no validation run was done: the Vulkan calls and their arguments stay the same.cargo test -p umem --release -- --test-threads=1gives the same onmainand on this branch: 22 unit tests, bench 1, gpu 12, identity_probe 2, sparse_mode 14 (1 ignored), sparse_probe 1, sparse_speed 1. The loud errors are the same set on both, and the device bias is the same (0xffffa00000000000).sparse_wait_probefails on both: it looks for a discrete GPU itself.-D warningsingreenfieldandgreenfield/wine(both depend on umem).cargo test -p umem -p frame -p vkback --lib,cargo test -p vkback --test policy,cargo xtask policy.Checklist (docs/AGENTS.md)
docs/TASKS.mdnot edited (rule 29)unsafeblock has a// SAFETY:comment (rule 36): the changed blocks inreapandreap_allhave itTRANSLATOR_VERSION: the translator is not touched (rule 27)Written with Claude Code; I reviewed it and ran the checks above on my machine.
🤖 Generated with Claude Code
@vktory6 on GitHub · 2026-12-02 17:37 UTC · original
Merged, thanks: the driver-specific constants are in one struct, and the three copies of the chunk-freeing code are one. #168 can merge main now, as its author offered.