Repository navigation
Texture refresh: a submission takes the queued textures on several threads - #57
Merged
ThatRecompDev merged 1 commit intoNov 26, 2026
Conversation
…reads Settle refreshed every texture still queued on the submitting game thread, one after another, before the submission could go on. Through a loading screen about 1,300 textures were queued between two summaries, mostly first fills, and the CPU sampler showed the submitting thread in ContentHash.Of (33 to 58 %), NtReadVirtualMemory (14 to 17 %) and the detiling: up to 16.8 s a frame in texture refresh, and the game's 30 s hang watchdog ended the boot before the world. The game thread waits for the whole queue there anyway, and reading, hashing and detiling run outside the uploader's lock (copy buffers are per thread, the counters atomic, each texture behind its own gate), so Settle now drains the queue with Parallel.ForEach on half the logical processors. The background worker keeps one thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
thanks, this lines up with what we saw on our side (texture refresh on the submitting thread was most of the CPU frame) one thing to keep an eye on is memory, the per-thread copy buffers plus the driver compiles is where your run ran out. merged, we'll watch commit in the next boots |
ThatRecompDev
added a commit
that referenced
this pull request
Nov 26, 2026
…ad budget The first ExecuteCommandLists of each frame checked every CPU-mapped texture (Bink video planes, the glyph cache) one after another on the submitting thread: a read through the kernel, the page hashes and, when they changed, an upload. That was up to tens of ms of every w109 world frame before its first submission reached the GPU. The queued (written) textures already settle on several threads (#57); the watched ones did not. RefreshWatched now refreshes them with Parallel.ForEach on TextureRefreshWorker's SettleThreads (half the logical processors), the same budget #57 uses, still before the submission: each texture is read and hashed under its refresh gate in its thread's copy buffer, and the uploads take the uploader's lock in turn. No new buffers: the per-thread copy buffers are the pool threads' that #57's settle uses. Watched textures the registry retired are dropped from the list instead of being walked every frame. Test: two mapped textures refreshed together each get their own bytes, and an unchanged second check uploads nothing.
ThatRecompDev
added a commit
that referenced
this pull request
Nov 26, 2026
Every fill held GpuTextureUploader's lock from taking a slot to submitting its copy, detile and list recording included, so the refresh worker's settle threads (#57) and the frame's check of CPU-mapped textures read and hashed in parallel but detiled one at a time. The lock now covers taking a slot (its staging buffer made, the slot marked busy) and submitting the copy (fence value and Signal in submission order). The detile into the slot's upload buffer and the recording of its list run on the filling thread, with that thread's footprints (thread-static, as the failure text now is); a fill that comes round to a busy slot waits for it (Monitor.Wait), and Dispose waits for busy slots before it lets them go. A failed detile or record drops its slot as a failed staging did. Test: 40 fills from 8 threads round the 16 slots are all made, and each texture ends with its own bytes.
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
TextureRefreshWorker.Settle, called before every submission, now refreshes the textures still queued on several threads:Parallel.ForEachon half the logical processors (SettleThreads). Before, it refreshed them one after another on the submitting game thread. The background worker keeps its one thread.Why
The game thread waits for the whole queue in
Settleanyway. Reading, hashing and detiling a texture run outside the uploader's lock:[ThreadStatic];Interlocked;RefreshGate;The worker and the submitting thread already ran
Refreshconcurrently. No lock is held around the call (XboxQueueMethods.Execute).Through a loading screen, about 1,300 textures were queued between two summaries, mostly first fills. With
--cpu-sample, the submitting thread spent its time inContentHash.Of(33–58 %),NtReadVirtualMemory(14–17 %) andXgSwizzle.Index. Up to 16.8 s of one frame went to texture refresh, and the game's 30 s hang watchdog ended the boot.In game (a retail game, RX 7800 XT, main + #56, untraced)
The run with the fix later ended in a device removal with the system commit full (74.2 of 74.3 GB). The driver's pipeline compiles take up to 6 GB each, several at once, and our process stood at 29.9 GB private. The per-thread copy buffers add at most one largest-texture buffer per settle thread.
Tests
docs/gpu-resources.mdis updated.🤖 Generated with Claude Code