Repository navigation
Texture registry: binary search for a registration's and a page mapping's overlap run - #56
Merged
ThatRecompDev merged 2 commits intoNov 26, 2026
Conversation
…ch instead of sorting Register copied every registered texture into a list and sorted it again for each new texture. A loading screen registers thousands of textures over a registry of about 15,000: the CPU sampler (--cpu-sample) showed the game thread that creates views at addresses (CreateShaderResourceViewAtAddress) 100 % busy in that sort's comparer (GpuTexture.Address), the other game threads blocked behind it, frames of 18 to 37 s, and the game's 30 s hang watchdog ending the boot before the world. Registered ranges never overlap, so the textures a new one overlaps are one run of the sorted array: OverlapRun finds it from LastStartingBefore and 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). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After the sort, the CPU sampler showed the same game thread 100 % busy in CopyPageMappings: each page the game maps or unmaps went through Mark, which scanned all 15,000 registered textures for the ones over the page. Mark now visits only the run OverlapRun finds; a test checks Unmapped and Mapped against a scan over 2,000 random ranges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
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