gpu: add opt-in skipping of redundant unmap drains #2064
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!2064
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2064"
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-11-02 02:23 UTC · original
MrBigBritches:skip-redundant-unmap-drains→main· +244 −7 · 7 files · 1 commits · openWhen the guest releases direct memory and then maps a fresh allocation at the same address, the range is unmapped from the GPU side twice, once by the release and again when the fixed map replaces the now-empty range. Buffers stay registered after an unmap, so the second unmap still waits for the whole GPU queue to finish. LEGO Batman: Legacy of the Dark Knight (PPSA16833) does this several times a second before its title screen.
With the new
--skip-redundant-unmap-drainsoption, an unmap skips the queue drain when all of these hold:The rest of the unmap still runs, so the range is still marked CPU-modified and queued for BDA sync. Every deferred operation that writes guest memory is a priority operation, so the pending check covers them. A deferred fault scan can now run after such an unmap, which can at most register a buffer over the unmapped range, without reading host memory. The option is read once when the render context is created, and it's off by default.
Measured
In LEGO Batman before the title screen, the repeated drains cost about 20-27 ms a second. With the option on, those redundant drains are skipped. In one 2 s sample, 268 were skipped and 23 still drained because work was in flight.
Tests
The new test counts queue submits with the option off and on:
@coderabbitai[bot] on GitHub · 2026-11-02 02:28 UTC · original
No actionable comments were generated in the recent review.
a25da4be-b084-46de-a32a-481187697593Reviewing files that changed from the base of the PR and between
893b035526and16970ca635.CMakeLists.txtsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/renderContext.hsrc/main.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Walkthrough
Adds the
--skip-redundant-unmap-drainsoption, disabled by default. When enabled,RenderContextskips a GPU drain for an unmapped range only when the range has no registered texture, GPU-dirty bytes, GPU-modified region, or pending priority operations. Tests cover both option modes and verify that relevant cache state or pending operations still cause a drain.Suggested reviewers:
nmzik,shadowbeat070Change: Feature
Merge Risk:
Minimal · up to
16970No identified issue blocks merging after normal checks.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.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 6 functions across 5 files. (2 skipped: 1 unsupported, 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
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.