graphics: avoid draining unrelated priority work on guest unmap #1263
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!1263
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1263"
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?
@popeee99 on GitHub · 2026-10-08 23:04 UTC · original
popeee99:fix/range-scoped-priority-unmap→main· +369 −32 · 10 files · 4 commits · openAvoid draining the GPU queue when guest memory is unmapped while an unrelated priority callback is pending. Fixes #1178 (#1178). ### Cause and change
RenderContext::UnmapMemoryused a global pending-priority check, so even a host-only end-of-pipe event forcedFinish()while the guest memory-operation lock was held. Priority operations now carry an optional guest range. Buffer and texture downloads declare their writeback ranges; flip, interrupt and suspend-point callbacks declare no guest-memory access. Omitted ranges remain conservative. The scheduler checks both queued operations and the currently executing callback under its existing mutex, retaining the active range until the callback returns. Existing cache-ownership checks and completion ordering are preserved. Buffer downloads conservatively cover their entire source buffer, including every packed copy. This does not remove required waits for cached GPU resources, overlapping writebacks or unannotated callbacks. ### Regression evidence A standalone reproduction linked against unchanged upstream emulator code at2f4b8a335d5e27a5153bdea670bd877a061e37b1queues the existingSync::TriggerEopEventAtEndOfPipeoperation, then unmaps an unrelated CPU-only range. Upstream advances the submission tick from 1 to 2 and fails the no-submission assertion. With the fix, the tick is unchanged.SchedulerUnmapTests.cppuses a real Vulkan device and the productionRenderContextandCommandScheduler. Its five scenarios cover host-only events, multiple queued ranges and overlap/adjacency boundaries, conservative unknown ranges, an actively executing callback, and real guest-backing writeback before unmap returns. These are state-based checks, not timing benchmarks. The focused fixture can run without the barycentric and min-LOD extensions required by the broader shader harness. ### Validation - Local Linux/WSL, Clang 21.1.8, Mesa llvmpipe: all five new scenarios pass. - ASan + UBSan: the test and every changed production translation unit are instrumented; all five scenarios pass without sanitizer diagnostics. Unchanged emulator translation units and third-party libraries were reused without sanitizer instrumentation. The guest test address is outside ASan's shadow reservation; no sanitizer checks are disabled. - Existing memory-tracker, page-manager, BitArray, LRU and emulator CLI CTest checks: 8/8 pass. - Full local emulator build and the CMake regression target both succeed; CTest runs all five scenarios successfully (18.91 seconds). - Implementation-commit fork CI: run 37852205381 succeeds on commit6590aabb47f2b2a272d2ad979b64d3779b687a39: full application builds succeed on Windows, Linux and macOS; Windows CTest 12/12, Linux 15/15 (includingscheduler_unmap, 4.55 seconds), macOS 14/14. All platforms build the new target; its Vulkan runtime regression runs on Linux with Mesa software Vulkan. Windows and macOS run their existing CI suites; this PR does not claim a Vulkan runtime test on those runners. -git diff --checkpasses.7cbcad4a8058a6663ed17f07b42d8de4a1284659adds function contracts only. Removing the added documentation lines reproduces the previously verified source exactly. Cross-platform CI for this follow-up is in progress. ### Related work and limits PR #1190 changes submission ordering and merges cleanly in a three-way tree check; it was not combined for game testing. PR #702 addresses predicate waits, not unmap. It already conflicts with current main, and both changes touch the texture-download callback. Integrating both must preserve #702's pending-download bookkeeping and this PR's range argument; no combined-build claim is made. No proprietary game files were used. Ready or Not, hardware-GPU behavior and frame-time/audio improvements were not tested. The evidence establishes removal of the unrelated submission and preservation of the tested memory-completion ordering, not a game-performance result. ### AI assistance OpenAI Codex assisted with investigation, implementation, diff review and test execution. No human code review is claimed; human maintainer review is requested.@coderabbitai[bot] on GitHub · 2026-10-08 23:08 UTC · original · edited 2026-10-08 23:26 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
b718c408-8dca-4b32-86e2-8ab6323a2b09📥 Commits
Reviewing files that changed from the base of the PR and between
2f4b8a335dand7cbcad4a80.📒 Files selected for processing (10)
.github/workflows/build.ymlCMakeLists.txtsrc/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/commandScheduler.hsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/sync.cpptests/SchedulerUnmapTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
Walkthrough
Deferred priority operations now carry optional guest ranges, and
RenderContext::UnmapMemorychecks for pending operations that overlap the range being unmapped. Buffer and texture writebacks provide their guest ranges; other deferred callbacks pass empty ranges. A Vulkan-backed test covers range overlap, unknown ranges, active callbacks, host events, and guest-memory writeback. CMake and CI configuration adds and builds the test; Linux CI also runs it.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: ⚪ Minimal · up to
7cbcaNo new merge-blocking issue is established. The remaining active-overlap test gap is optional integration coverage.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
#1178].RenderContext::UnmapMemorywaits for priority work only when the unmapped range overlaps queued or active guest-memory work. Empty ranges represe…#1178]. Scheduler range tracking, callback annotations, unmap handling, regression tests, CMake registration, and Vulkan CI dependencies implement or validate range-specific w…Full details: Docstring Coverage
Explanation
Docstring coverage is 64.86% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 37 functions across 8 files. (2 skipped: 2 unsupported.)
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
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-08 23:17 UTC · original · reviewed
ℹ️ Review info
⚙️ Run configuration
f470db0f-989d-4c9c-b387-1899bf841ae0📥 Commits
Reviewing files that changed from the base of the PR and between
6590aabb47and7cbcad4a80.📒 Files selected for processing (7)
src/graphics/guest_gpu/graphicsRun.cppsrc/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/commandScheduler.cppsrc/graphics/host_gpu/renderer/renderContext.cppsrc/graphics/host_gpu/renderer/sync.cpptests/SchedulerUnmapTests.cpp🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
@popeee99 on GitHub · 2026-10-08 23:18 UTC · original
@coderabbitai Please identify the exact file paths and function names counted as undocumented by the 64.86% docstring-coverage check on
7cbcad4a. The report counts 37 functions but does not list the missing ones. We want to document meaningful API, synchronization and lifetime contracts without adding redundant comments or changing the coverage configuration. Please also clarify the suggested active overlapping-writeback regression gap with reference to CheckActiveRange and CheckGuestWriteback.@coderabbitai[bot] on GitHub · 2026-10-08 23:19 UTC · original
🧩 Analysis chain
🏁 Script executed:
Length of output: 11427
🏁 Script executed:
Length of output: 72907
🏁 Script executed:
Length of output: 17396
@popeee99I checked the source and the published report at7cbcad4a8058a6663ed17f07b42d8de4a1284659.Docstring coverage
I cannot identify the exact 13 functions that the check classified as undocumented from the available report. The published comment contains only the aggregate result. GitHub returned no check-run output with a per-function list.
The arithmetic is consistent with 24 documented functions out of 37, leaving 13 undocumented functions. It does not identify those functions.
Source inspection found the following 24 named function definitions touched by the PR. Every definition already has an adjacent
///documentation comment at this commit:src/graphics/guest_gpu/graphicsRun.cppGuestGpu::Process,CommandProcessor::PrepareCpuFlipsrc/graphics/host_gpu/renderer/cache/bufferCache.cppBufferCache::DownloadBufferMemory<async>src/graphics/host_gpu/renderer/cache/textureCache.cppTextureCache::DownloadImageMemorysrc/graphics/host_gpu/renderer/commandScheduler.cppCommandScheduler::PopPendingOperations,CommandScheduler::DeferPriorityOperation,CommandScheduler::QueueOperation,CommandScheduler::HasPendingPriorityOperations(),CommandScheduler::HasPendingPriorityOperations(GuestRange),CommandScheduler::PriorityOperationsThreadsrc/graphics/host_gpu/renderer/renderContext.cppRenderContext::UnmapMemorysrc/graphics/host_gpu/renderer/sync.cppSync::WriteAtEndOfPipeWithInterruptWriteBackFlip32,Sync::WriteAtEndOfPipeWithFlip32,Sync::WriteAtEndOfPipeOnlyFlip,Sync::TriggerEopEventAtEndOfPipetests/SchedulerUnmapTests.cppRequire,RequireVk,VulkanContext::VulkanContext,VulkanContext::~VulkanContext,CheckHostEvent,CheckQueuedRanges,CheckUnknownRange,CheckGuestWriteback,CheckActiveRange,mainThe eighth C++ file is
src/graphics/host_gpu/renderer/commandScheduler.h. Its changed function declarations have documented definitions incommandScheduler.cpp.This source audit does not reproduce the check’s classification. I cannot establish whether the remaining entries are declarations, lambdas, or other extracted functions. Listing any of them as the exact missing 13 would be speculation.
The existing comments already describe meaningful contracts:
I do not recommend duplicate comments or coverage-configuration changes based on this aggregate warning. Please retry the check and share any per-function diagnostic output it exposes. Until that output is available, the exact missing-function list remains unverified.
Active overlapping-writeback regression
My earlier wording was too broad. The tests already cover active-range retention and writeback-before-unmap-return. The remaining suggestion concerns their combination.
Both functions are in
tests/SchedulerUnmapTests.cpp:CheckActiveRange, Line 204CheckGuestWriteback, Line 180WriteBacking, calls an overlapping unmap, then verifies the published value before releasing the kernel mapping.The narrow additional case would:
WriteBacking, and verify the value after unmap returns.This would directly test the integration between active-range detection and the completion wait. The implementation already retains the active range through callback return and includes the active callback in
WaitPriorityOperations.This is an optional strengthening of integration coverage, not evidence of a current ordering defect or missing active-range coverage.
Thanks for the guidance on meaningful documentation.
✏️ Learnings added
You are interacting with an AI system.
@popeee99 on GitHub · 2026-10-08 23:20 UTC · original
@coderabbitai review
@coderabbitai[bot] on GitHub · 2026-10-08 23:20 UTC · original
⚠️ Action not completed
Already reviewed the last commit. Use
@coderabbitai full reviewto rerun a review of the entire changeset.@popeee99 on GitHub · 2026-10-08 23:22 UTC · original
@coderabbitai full review
@coderabbitai[bot] on GitHub · 2026-10-08 23:22 UTC · original · edited 2026-10-08 23:26 UTC
✅ Action performed
Full review finished.
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.