gpu: queue and submit image readbacks at end-of-pipe labels #1928
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1928
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1928/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?
@MrBigBritches on GitHub · 2026-10-27 01:25 UTC · original
MrBigBritches:readback-signal-order→main· +430 −10 · 5 files · 2 commits · closed without mergingGames read GPU-written images on the CPU after waiting for an end-of-pipe label. UE4 does this for sky-light ambient. It renders the irradiance SH into a small RGBA16F target and reads it back after the frame's label. With
--readback-linear-imagesor--readback-tiled-images, readbacks were only queued at the garbage-collector pass, so the guest read stale data. In Octopath Traveler II, Throné's opening scene was left without ambient light.With this PR,
RELEASE_MEMqueues the pending readbacks before its label and submits them at once, so their data reaches guest memory about when the label's GPU work finishes. The label itself is still written at once.This replaces the earlier version of this PR, which also held each label back until its readbacks landed. That hold made labels reach the guest only after the host GPU had run everything before them, which let games see the host GPU's real speed. Astro Bot then halved its dynamic resolution, and the image looked pixelated with no AA. Testing showed queuing and submitting at the label is enough for Octopath on its own, so the holds are gone.
Commits
RELEASE_MEMqueues the pending readbacks and submits them. The GDS path submits them through its existingFinish().Tested
Both readback flags were on for the readback rows.
Tests
TextureCacheDownloadRetry: an unready image is kept and copied once it can be, and the in-flight count covers the copy until it lands.TextureCacheDownloadDropAtLabel: an unready image is dropped at a label and never copied later.ReadbackAtLabel:Known issues
@coderabbitai[bot] on GitHub · 2026-10-27 01:31 UTC · original · edited 2026-11-02 06:21 UTC
No actionable comments were generated in the recent review.
3d1d05f7-7d09-48e2-b743-193d375664e7Reviewing files that changed from the base of the PR and between 2d515a2daca9049545a7796dce840c780d0ded66 and
fc98b0b0b5.src/graphics/guest_gpu/command_processor/commandProcessor.hsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Walkthrough
Texture-cache download processing now reports whether it queued work, retains or drops unavailable images according to an option, and tracks readbacks until guest-memory writes complete. Release-label handling processes eligible readbacks before writing the label, with GDS reads relying on the subsequent
Finish(). New tests cover download retries, label-time dropping, and readback completion after a label write.Suggested reviewers:
claxten10Change: Bug fix
Merge Risk:
Minimal · up to
fc98bThe change queues image readbacks before end-of-pipe labels without delaying the labels. The author states that this avoids the Astro Bot dynamic-resolution regression. No actionable merge-blocking risk remains after review.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 4 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@ -2082,3 +2103,3 @@}}m_download_images.clear();return queued;@coderabbitai[bot] on GitHub · 2026-10-27 01:31 UTC · original · edited 2026-10-27 02:12 UTC
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10933
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8278
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19792
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9513
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 14436
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3525
Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4435
Keep retained readbacks in signal-ordering state.
When
DownloadImageMemory()returns false because the image is not yetSafeToDownload(),ProcessDownloadImages()retains the image but returnsfalseif it queued no other readback. The following label can then be written immediately because no readback is queued or in flight. A later retry can write the image to guest memory after that label.Track retained retryable images as pending ordering work. Retry them before the label lands, or drop them definitively before emitting the label.
✅ Addressed in commit c8bb037
@coderabbitai[bot] on GitHub · 2026-10-27 01:31 UTC · original · reviewed
Actionable comments posted: 1
0f696807-1ebf-418e-8692-44e0197cf944Reviewing files that changed from the base of the PR and between
986721f5bcand fc4f28d30900334c8426a4a9e324d30c5c7051a3.src/graphics/guest_gpu/command_processor/commandProcessor.hsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/guest_gpu/graphicsRun.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderContext.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@ -2082,3 +2103,3 @@}}m_download_images.clear();return queued;@MrBigBritches on GitHub · 2026-10-27 01:58 UTC · original
fixed in c8bb0377
@coderabbitai[bot] on GitHub · 2026-10-27 02:10 UTC · original · reviewed
39f6e5ac-3827-419e-b7ab-25d58d88b431Reviewing files that changed from the base of the PR and between fc4f28d30900334c8426a4a9e324d30c5c7051a3 and c8bb0377a75d2daa9b7fda194e3b64d51379e71a.
src/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@MrBigBritches on GitHub · 2026-10-27 03:03 UTC · original
@coderabbitai RDNA2, WRITE_DATA executes when the CP parses it, while RELEASE_MEM's end-of-pipe write lands only after earlier work drains, so a WRITE_DATA right after a RELEASE_MEM can land first on hardware too. Drivers put a WAIT_REG_MEM between them, and that wait blocks here until the held-back label lands. Blocking every WRITE_DATA on the shared pending count would stall unrelated queues and register writes. Kept as the known gap listed in the PR description.
@coderabbitai[bot] on GitHub · 2026-10-27 03:03 UTC · original
@MrBigBritches I couldn't produce a complete response to this request. Please try again.
You are interacting with an AI system.
@MrBigBritches on GitHub · 2026-11-01 18:55 UTC · original · edited 2026-11-02 06:18 UTC
Solved in
fc98b0bDiscovered regression: Astro Bot loses anti-aliasing with this change + readbacks enabledRoot cause: with readbacks on, this change holds end-of-pipe labels and interrupts back 1–5 ms. Astro Bot's dynamic resolution reads that as a slower GPU and halves the render resolution, which looks pixelated with no AA.@Nmzik on GitHub · 2026-11-07 14:38 UTC · original
@MrBigBritches Credited will be in main
Pull request closed