shadow: by_address limits the card bytes alive, not all ever placed #333
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/readmet3xt-lab--foxhound!333
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-333"
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?
@Bushyon on GitHub · 2026-12-01 14:17 UTC · original
Bushyon:by-address-card-budget→main· +65 −6 · 1 files · 72 commits · closed without mergingshadow: by_address limits the card bytes alive, not all ever placed
The bug
shadow::by_addressmakes the copies programs find memory by address through: the structures rays are traced through, read with every step of every ray. It puts a copy's shader side in the card's own memory up toVICTORY_MEMORY_CARD_MB(4096 by default). The bytes were counted in a function-localstatic USED, which:fetch_addhappened before the limit check, so a copy refused for being over the limit was added anyway, and so was one whoseuav_bufferfailed.So after 4 GiB had passed through it over a session (not 4 GiB alive at once), every later copy by address went to the PC's memory, however much room the card had. It is a long-session slowdown, and only for ray tracing.
The fix
BY_ADDRESS_CARD.reserve_cardreserves a copy's bytes, and undoes the reservation when the limit is passed or the buffer isn't made.Shadow::by_address_card) and gives them back inDrop.Tests
the_count_is_of_copies_alive, against a counter of its own so parallel tests can't disturb it. It covers a copy within the limit, one refused over it, one whose buffer wasn't made, and room coming back once a copy goes.cargo clippy -p victory-gpu --all-targetswith and without--all-features,-D warnings: clean.cargo test -p victory-gpu: 476 passed. One run hitwatch::tests::what_the_kernel_writes_through_is_not_guarded_for_another_view, which passes alone; thewatchtests are timing-sensitive under the parallel run onmaintoo.cargo xtask policy --staged: ok.Measured in the game
Two hands-off runs,
VICTORY_BVH_BUILDER=1(ray tracing on) andVICTORY_MEMORY_CARD_MB=64, so that the limit is reached within minutes. The same build ran both ways: one with a temporary switch that brought back the old counting, one with the fix. A temporary log recorded where each copy went (neither switch nor log is in this PR).With the old count, every refused copy was added, so the 64 KiB copies were turned away too while the card held 16 MB. With the fix, the count matches what is on the card, and only the copies that are alone over the 64 MB limit go to the PC's memory. Copies being freed (bytes given back) didn't happen in these short runs; the unit test covers it.
Independent of #331 (small buffers placed together); this one touches only
shadow.rs.🤖 Generated with Claude Code
@Aniseto on GitHub · 2026-12-01 14:21 UTC · original
Ran the new
the_count_is_of_copies_alivetest at5a4eaf0on an NVIDIA Blackwell desktop part with 16 GB of VRAM.Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own
CARGO_TARGET_DIR, no local patches.The new unit test passes here. It covers the counter of card bytes alive: copies within the limit, one refused over it, one whose buffer was not made, and room coming back after a copy goes. The description's 476-test package run and the long-session ray-tracing symptom were not repeated; no title was run.
Not tested: the full workspace suite, a retail title, a long ray-traced session, Wine, AMD adapters, release profile, game data.
AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the test, wrote this report; the worktree was not modified; no game data was used.
Pull request closed