Texture registry: binary search for a registration's and a page mapping's overlap run #56
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/ThatRecompDev--five-star-recomp!56
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/56/head"
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?
@Sr-0w on GitHub · 2026-11-26 06:29 UTC · original
Sr-0w:resources/registry-insert-without-sort→main· +159 −17 · 3 files · 2 commits · merged 2026-11-26 06:49 UTCWhat
GpuTextureRegistryno longer scans or re-sorts all its textures:Registercopied every registered texture into a list and sorted it again, for each new texture. Registered ranges never overlap, so the textures a new one overlaps form one run of the sorted array.OverlapRunfinds that run fromLastStartingBeforeand walks back. The run is retired as before, and the new array is the prefix, the texture and the suffix: two block copies, no sort.Mark, called for each page the game maps or unmaps (CopyPageMappings), scanned all textures. It now visits only that run.Why
On a loading screen the registry holds about 15,000 textures and registers thousands more. With
--cpu-sample, on a retail game and an RX 7800 XT:CreateShaderResourceViewAtAddress) was 100 % busy in the sort's comparer (<Register>b__36_0,GpuTexture.Address). The other game threads were blocked behind it, frames took 18 to 37 s, and the game's 30 s hang watchdog (RVA 0x23cf683) ended every boot on current main before the world.Registerfix only, the same thread was 100 % busy inCopyPageMappings→GpuTextureRegistry.Mark.In game
The registry no longer shows in the CPU samples, but on this machine these two changes alone still left the boot ending at the watchdog (1,200 presents). The remaining cost was the texture refresh of submissions, which is handled in a separate PR. With both PRs, the boot passes the loading screen and plays the intro: a night street with car lights, signs and lit windows, at about 1 fps.
Tests
GpuTextureRegistryRunTests:OverlapRunagainst a scan of every texture, over 2,000 random ranges, including where a range with no overlap belongs;UnmappedandMappedagainst a scan;docs/gpu-resources.mdis updated.🤖 Generated with Claude Code
@ThatRecompDev on GitHub · 2026-11-26 07:30 UTC · original
nice, the full re-sort per register was a silly one to leave in. the run search + tests against a full scan look solid
merged together with #57