Demon's Souls: avoid full buffer sweeps during BDA preparation #1391
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!1391
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1391/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?
@kewalker on GitHub · 2026-10-11 00:00 UTC · original
kewalker:perf/demons-souls-bda-dirty-worklist→main· +431 −88 · 8 files · 6 commits · closed without mergingI attest that the changes below have been verified and tested by me for correctness. The AI disclosure section at the end describes the exact usage.
During investigation,
PrepareBdarepeatedly traversed every mapped range and registered buffer before BDA draws and dispatches, including buffers with no CPU writes. This PR removes that unnecessary CPU work; it does not claim to resolve the game's overall low FPS or its readback stalls.The tracker publishes CPU-dirty region hints in a fixed hierarchical atomic bitmap. The GPU thread consumes those hints and synchronizes only their intersections with mapped ranges. Existing locked page ownership checks still determine the bytes uploaded. Buffer registration queues the full new buffer span, and mapping queues the mapped range, so initial CPU-owned data and writes whose hints were consumed while unmapped are examined on the next pass. Consuming hints does not clear dirty-page ownership, and subsequent writes publish work for another pass. The fault-handler publication path does not allocate and has no bounded-log overflow case.
Related: #1286 pursues the same goal with bounded page-range logs and depends on another PR. This is an alternative based directly on current main, using coarse 4 MiB region hints. It can still examine unrelated buffers sharing a dirty region and adds roughly 520 KiB of bitmap storage per tracker. The repository's pinned formatting hook also reformatted existing declarations in the touched files.
Validation:
MemoryTrackerTestspassed: new-region hints, deduplication, unchanged page ownership after consuming hints, registration hints, later writes, invalidation, and untracking.--bda-dirty-worklist-onlypassed on Vulkan: registration after previously consumed hints, initial neighboring CPU-owned bytes, clean passes, CPU rewrites, and remapping after consuming an unmapped dirty hint. Registered asbuffer_cache_bda_dirty_worklistin CTest and included in the full harness.--mapped-range-onlyand--buffer-cache-range-onlyregression checks passed.Linux/macOS builds and controlled game A/B measurements have not been performed. Diagnostic instrumentation, shader readback changes, resource snapshot caching, completion-query changes, and pipeline-cache changes are excluded from this PR.
AI assistance: Codex implemented/extracted the change, wrote the tests, and ran the build, formatting, benchmark, and Vulkan validation at the contributor's request. The contributor provided Demon’s Souls timing logs and tested earlier development builds. Code was manually verified.
@coderabbitai[bot] on GitHub · 2026-10-11 00:34 UTC · original · edited 2026-10-16 02:12 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
feb55c3a-2d7b-4ee8-9a1d-fde911d8b231📥 Commits
Reviewing files that changed from the base of the PR and between
1f2d44b18cand0a9625c753.📒 Files selected for processing: 3
src/graphics/host_gpu/memoryTracker.hsrc/graphics/host_gpu/renderer/cache/bufferCache.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.
📝 Walkthrough
MemoryTracker now records CPU-dirty region hints and provides APIs to queue and drain them. BufferCache queues registered and mapped ranges, then synchronizes dirty intersections with mapped ranges during BDA preparation. RenderContext queues newly mapped ranges and calls the synchronization method. The changes add memory-tracker tests, a GPU regression test, a test selector, and a CTest entry.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Refactor
Merge Risk: ⚪ Minimal · up to
0a962The change reduces BDA preparation scanning overhead using dirty-region hints. No concrete merge-blocking risk was found in the supplied context, and the author reports focused tests passing.
Pre-merge checks:
5
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.@kewalker on GitHub · 2026-10-11 14:06 UTC · original
@nmzik CodeRabbit suggested you as a reviewer for this Demon's Souls BDA buffer-preparation change. Would you be able to review it when you have time? Thank you.
@kewalker on GitHub · 2026-10-16 15:29 UTC · original
Closing as superseded by
d58aefde(renderer: reduce synchronization and allocation overhead), which adds incremental BDA synchronization to main. This PR used a coarse atomic bitmap; any future comparison of that approach should be a separate, measured change.Pull request closed