Repository navigation
perf(render): texture uploads never wait for the GPU - #1133
Merged
Merged
Conversation
Builds on the previous commit (sven-n#1132), which lets uploads outside a load batch share the open submission until the frame's flush. The uploader still kept three staging slots and waited for the oldest one's fence when the ring wrapped, and a browser frame can't wait at all. - A slot the GPU is still copying is skipped: the uploader takes the next finished slot or adds one, up to 16 (64 MiB); only past that, or out of memory, does it wait. Idle slots past the first three are released after 60 frames without growth. - With every upload sharing the open slot until the next flush, the load batch's begin/end on the uploader is gone; a load ends with a flush. - StagedLoad::Pump takes a hold-back check between steps; startup leaves its next step to the next frame while more than 32 MiB of staging is still being copied. - A finished fence is still waited on (it returns at once): SDL's Vulkan backend cleans up finished submissions only on a fence wait or a frame submit, and without it texture creation slowed during loads. - The control socket's `frames` query reports the longest frame and slow frames since the last reset.
nitoygo
force-pushed
the
perf/uploads-never-wait
branch
from
November 15, 2026 20:47
fb7db71 to
21d5b08
Compare
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 was wrong
Texture uploads could stop the frame and wait for the GPU. The uploader had three staging slots. When all three were still being copied, it waited for the oldest one to finish. Outside a load, each texture was also its own GPU submission, so the first time a window opened, the client paid one submission per icon.
On desktop this shows up as small hitches: 1–3 ms of slot waiting per load, and a heavier first window open. In a browser it is a hard blocker. A browser frame can't wait at all; any wait inside a frame throws. That makes this the uploader part of #1094 and of the last item of #1061.
What changed
This builds on #1132 by @jay23606, whose commit is included unchanged as the first commit here. It lets uploads outside a load share the open submission until the frame's flush. Merging this PR with a merge commit (not squash or rebase, which rewrite the commit) also lands #1132 and marks it merged. The second commit adds the rest:
StagedLoad::Pumpnow takes a hold-back check. While more than 32 MiB of staging is still being copied, startup leaves its next step for the next frame.framesquery on the control socket. It reports the longest frame and the number of slow frames (> 50 ms) since the last reset. I used it for the measurements below. It is documented indocs/control-socket.md.Results (Vulkan, 1280×720, RelWithDebInfo)
$benchscene.full)No FPS change in the world. The gain is fewer load hitches, and an uploader that can run inside a browser frame. I also tested it in a browser (WebGPU) build: the client reaches Lorencia, and the first inventory open is clean.
Tests
test_bitmap_gpu_resources(19 cases), using a fake GPU: growth up to the ceiling, waiting only at the ceiling or without memory, trimming, flushes across frames, and lost slots. Two regression cases came from review. One checks that a trim never leaves the ring pointing at a lost slot. The other checks that a trim never removes the last usable slot when lost slots fill the minimum; before the fix that case hung.test_bitmap_gpu_upload_integrationpasses on a real D3D12 device (MU_RUN_GPU_UPLOAD_TESTS=1), including bounded staging growth under a flood.runtime uploads carry a submission across frames…) is kept and passes unchanged.test_staged_load(hold-back) andtest_control_protocol(frames).Closes #1094. Refs #1061, #865.
🤖 Generated with Claude Code