GPU: bound shadow buffer lookup by maximum registered size instead of 64 entries #2096
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2096
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2096"
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?
@fuzeofficlal on GitHub · 2026-11-25 04:49 UTC · original
fuzeofficlal:fix/gpu-shadow-overflow-and-find-906→main· +143 −21 · 1 files · 1 commits · openRefs #906.
Summary
.take(64)cap inshadow::find(crates/victory-gpu/src/shadow.rs) with a reverse scan bounded by the maximum buffer size currently registered inBUFFERS(lowest = end.saturating_sub(max_size), returningNoneimmediately whenlowest > address).max_sizeonBuffers::insertand recompute it onBuffers::removewhen the previous maximum-size entry is unregistered, so misses reachingloose()stop at the live maximum buffer bound while lookups still reach a covering outer buffer past more than 64 smaller inner buffers.Verification
shadow::tests::find_reaches_covering_buffer_past_many_inner_buffersshadow::tests::find_stops_at_max_size_bound_and_tightens_on_unregistercargo clippy -p victory-gpu --tests --locked -- -D warningsandcargo xtask policy: passed.@Marvisak on GitHub · 2026-11-25 10:36 UTC · original · edited 2026-11-25 11:23 UTC
Automated triage for the maintainers.
Merge candidate.
shadow::findnow scans backwards only fromend - max_size(find_buffer), whereBufferstracks the largest registered length and recomputes it when the largest entry is removed or replaced; a buffer that covers[address, end)must start at or after that bound, so lookups still reach an outer buffer past many smaller ones while misses reachingloose()stop early. The overflow guards and the equal-start tie-breaker are gone. #402 overlaps but currently has merge conflicts; this one merges cleanly. CI passes.On your reply: confirmed in
2f43424, this is what was asked. A minor follow-up, not a blocker:Buffers::removerescans the whole map each time an entry of the maximum size goes, which is O(n) per release if many buffers share that size; a size-count map would make it O(log n).Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 10:51 UTC · original
Updated in
2f434243per triage feedback:find_bufferby the maximum currently registered buffer size (lowest = end.saturating_sub(max_size)over(lowest, 0)..=(address, usize::MAX)), tighteningmax_sizeonunregisterwhen the largest buffer is removed so misses stop early instead of walking the map.u64::MAXoverflow/saturating guards and the equal-start tie-breaker.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.