Builder memory: key a dword by every bit of its address (addresses 8 GiB apart shared one, #202) #243

Closed
github-bot wants to merge 1 commit from gh-pr/243/head into gh-pr/243/base
Owner

@⁠sharan104 on GitHub · 2026-11-26 12:29 UTC · original
sharan104:fix/202-bvh-key-alias → main · +27 −2 · 1 files · 1 commits · closed without merging

Fixes #202.

memory::ready asks a list's first_use once per dword a builder dispatch writes (kind 4), and once per small buffer whose results come back (kind 5). Both keys kept 31 bits of the dword (at >> 2 & 0x7FFF_FFFF). So within one recording, two title addresses 8 GiB apart shared a key, and the second was left closed, got VIEW pages instead of BUILT ones, or never came back. The console's GPU addresses have 40 bits, and ours start at 4 GiB.

dword_key(kind, at) = usize::MAX - (kind << 40) - (at >> 2) gives each address below 4 TiB a key of its own. The two kinds stay apart, and the keys stay clear of every other first_use key in the crate:

  • the (k << 33) keys and named's (k << 26) keys in memory.rs
  • the usize::MAX - 0x5e…0x7a constants
  • texture.rs's 1 << 63 | …
  • raw addresses and resource pointers

The bytes of one dword still share one key. The keys live in the list's set until it is reset, and nothing is kept on disk.

New test: addresses_8_gib_apart_have_keys_of_their_own.

Tests: cargo test -p victory-gpu --locked: 375 passed, 0 failed, 34 ignored. Clippy has no new warnings. The crate's one -D warnings failure is the watch.rs:3205 lint already on main, which #241 fixes.

Not covered: the kind-3 key (3 << 33) - (at >> 8) is exact only below 2^41. I left it as it was.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 12:29 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/243) `sharan104:fix/202-bvh-key-alias` → `main` · +27 −2 · 1 files · 1 commits · closed without merging Fixes #202. `memory::ready` asks a list's `first_use` once per dword a builder dispatch writes (kind 4), and once per small buffer whose results come back (kind 5). Both keys kept 31 bits of the dword (`at >> 2 & 0x7FFF_FFFF`). So within one recording, two title addresses 8 GiB apart shared a key, and the second was left closed, got VIEW pages instead of BUILT ones, or never came back. The console's GPU addresses have 40 bits, and ours start at 4 GiB. `dword_key(kind, at)` = `usize::MAX - (kind << 40) - (at >> 2)` gives each address below 4 TiB a key of its own. The two kinds stay apart, and the keys stay clear of every other `first_use` key in the crate: - the `(k << 33)` keys and `named`'s `(k << 26)` keys in `memory.rs` - the `usize::MAX - 0x5e…0x7a` constants - `texture.rs`'s `1 << 63 | …` - raw addresses and resource pointers The bytes of one dword still share one key. The keys live in the list's set until it is reset, and nothing is kept on disk. New test: `addresses_8_gib_apart_have_keys_of_their_own`. Tests: `cargo test -p victory-gpu --locked`: 375 passed, 0 failed, 34 ignored. Clippy has no new warnings. The crate's one `-D warnings` failure is the `watch.rs:3205` lint already on `main`, which #241 fixes. Not covered: the kind-3 key `(3 << 33) - (at >> 8)` is exact only below 2^41. I left it as it was. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
ready() asks a list's first_use once per dword a builder dispatch writes
(opens, BUILT pages, small) and once per small buffer whose results come
back. Both keys kept 31 bits of the dword, at >> 2 & 0x7FFF_FFFF, so two
title addresses 8 GiB apart had the same key in one recording: the second
was left closed, got VIEW pages in place of BUILT, or did not come back.
The console's GPU addresses have 40 bits, ours start at 4 GiB.

dword_key gives kinds 4 and 5 regions of 2^40 keys, 2^38 of them used,
below the regions of 2^33 the other kinds use (3, 6, 9): every address
below 4 TiB has a key of its own, the kinds stay apart, and the bytes of
one dword are one key as before. The keys live in the list's set until it
is reset; nothing is kept on disk.

Fixes #202

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 12:31:00 +00:00
github-bot closed this pull request 2026-11-26 12:31:00 +00:00
Author
Owner

@⁠sharan104 on GitHub · 2026-11-26 12:29 UTC · original

Closing: #236 by @⁠feanorsun fixes #202 the same way and was opened first. Sorry for the noise.

**@⁠sharan104** on GitHub · 2026-11-26 12:29 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/243#issuecomment-7192069405) Closing: #236 by @⁠feanorsun fixes #202 the same way and was opened first. Sorry for the noise.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.