gpu: scan only summarized words of the BDA fault buffer #1294
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!1294
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1294"
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?
@NeySlim on GitHub · 2026-10-09 10:52 UTC · original
NeySlim:perf/fault-summary→main· +426 −28 · 5 files · 4 commits · openProblem
Shaders that access guest memory through BDA (FLAT, GLOBAL and scalar address loads) record a fault bit when a page has no GPU buffer yet. After every submission that ran such a shader,
FaultManager::ProcessFaultBufferdispatches one invocation per 32 pages of the whole cached address space: 3,145,728 invocations that read the complete 12 MiB bitmap and write every word back to zero, even when no fault was recorded.In God of War Ragnarök (PPSA08332) the pass runs about 13 times per frame. GPU timestamps around each recorded operation put it at 1.06 ms per frame in gameplay and 1.08 ms in the opening cutscene.
Change
The set of reported pages is unchanged: a fault is still recorded by the access that misses, and reported by the next pass.
main now clears the fault buffer and the BDA page table when the buffer cache creates them (
4644c5292), so this PR no longer does. It keeps two checks for those clears: a stale bitmap or summary bit would make the pass report pages that never faulted, and a stale page-table entry would send BDA accesses to a garbage address instead of the fault path.Test
FlatLoadRecordsFaultSummary(compute case): a FLAT load from an unmapped page reads zero and sets both its page bit and its summary bit. It fails without the emitter change.FaultBufferSummary(renderer check): faults recorded with their summary bits are reported (the pages get a buffer) and cleared, and a page bit without a summary bit is left untouched. It fails with the previous full scan.FaultBufferStartsClearedandBdaPageTableStartsCleared(renderer checks): a renderer is created with an allocator that sets every bit of each new device memory block not dedicated to one resource, with blocks large enough to hold the page table. The new fault buffer must read zero, the page-table entries of unregistered pages must be zero, and a registered buffer's pages must translate. Each fails without main's clear.FaultBufferSummaryclears the fault buffer before writing its fixture.Validation
shader_recompiler_compute_tests, one case per process: identical results to origin/main apart from the four new passing cases. The 10 cases that already fail on origin/main with this driver fail the same way.AI use
I used Claude Code (AI agent) to profile the GPU time of each recorded operation, write the change and the tests, and run the measurements and tests above on my machine. I reviewed the diff and the results before opening this PR.
@coderabbitai[bot] on GitHub · 2026-10-09 10:55 UTC · original · edited 2026-10-21 06:55 UTC
📝 Walkthrough
The fault buffer now contains a page bitmap and a summary bitmap. BDA fault recording atomically updates both. Fault processing uses the summary bitmap to find page words, appends fault addresses for download, and restores unprocessed faults when the download limit is reached. The change also initializes the BDA page table and fault buffer to zero. Compute tests check initialization, bitmap state, and fault processing.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: 🔵 Low · up to
c53f8The fault-buffer scanning change itself shows no concrete defect. The risk is confined to the new compute-test harness, which may abort on GPUs with a small maximum buffer size, and a possible missing transfer barrier in one readback check. Address both before merge, or accept them knowingly.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 13.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 6 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
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-09 11:37 UTC · original · edited 2026-10-09 11:58 UTC
On
tests/ShaderRecompilerComputeTests.cppline 5252 (outdated):🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 42099
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 22117
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 6549
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11373
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4326
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 792
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8187
Do not bind a temporary buffer to dedicated memory.
The new page-table check creates a guest buffer with
eShaderDeviceAddress. VMA marks that allocation as dedicated.FillDeviceMemorythen binds the allocation to a different temporary buffer. Dedicated memory can be bound only to its designated resource. This can make the initialization tests fail on devices that use dedicated allocations.Poison eligible memory through the designated buffer or another valid path instead. The page-table and fault buffers themselves use
AllFlags, which does not request dedicated allocation.✅ Addressed in commits 7ed6cc3 to 95cddd3
@ -5495,0 +5735,4 @@auto readback =CreateHostBuffer(name, faults.Size(), vk::BufferUsageFlagBits::eTransferDst, {});const vk::BufferCopy copy{0, 0, faults.Size()};scheduler.Current().Handle().copyBuffer(faults.Handle(), readback.buffer, 1, ©);@coderabbitai[bot] on GitHub · 2026-10-09 11:37 UTC · original · edited 2026-10-09 11:58 UTC
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11743
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12422
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 19674
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5845
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5492
🌐 Web query:
official Vulkan specification same queue submissions implicit memory dependency queue submission order buffer transfer write later transfer read💡 Result:
🌐 Web query:
site:github.khronos.org/Vulkan-Site/spec/latest synchronization vkCmdPipelineBarrier first synchronization scope commands submitted before command buffer later queue submission💡 Result:
Synchronize the fault-buffer initialization before copying.
FaultManagersubmits the zero fill separately. Same-queue submission order does not create a memory dependency. Add a transfer-write-to-transfer-read dependency beforecopyBuffer.🐛 Suggested fix
📝 Committable suggestion
@coderabbitai[bot] on GitHub · 2026-10-09 11:37 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
95098f0d-d7d9-42ab-ad29-a0dc97d51596📥 Commits
Reviewing files that changed from the base of the PR and between ed221b64b108ee2e9a14152787948a6aab26b98b and ccfcb32a42afa49418f30848150e6ee8ee816946.
📒 Files selected for processing (5)
src/graphics/host_gpu/renderer/cache/bufferCache.cppsrc/graphics/host_gpu/renderer/cache/faultManager.cppsrc/graphics/host_gpu/renderer/cache/streamBuffer.cppsrc/graphics/host_gpu/renderer/cache/streamBuffer.htests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
@NeySlim on GitHub · 2026-10-09 11:54 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 5252 (outdated):Same fix as on #1296, in 7ed6cc3d: memory dedicated to a resource is no longer poisoned through another buffer. The fixture wraps
vkAllocateMemoryand skips allocations withVkMemoryDedicatedAllocateInfo, and the block size keeps the page table and fault buffer in poisoned blocks (checked by the tests).@ -5495,0 +5735,4 @@auto readback =CreateHostBuffer(name, faults.Size(), vk::BufferUsageFlagBits::eTransferDst, {});const vk::BufferCopy copy{0, 0, faults.Size()};scheduler.Current().Handle().copyBuffer(faults.Handle(), readback.buffer, 1, ©);@NeySlim on GitHub · 2026-10-09 11:54 UTC · original
The dependency is already there:
Buffer::Fillends with a barrier from transfer write to all commands, memory read and write, recorded in the clear submission. The second scope of a pipeline barrier covers every later command in submission order on the queue, later submissions included, so the copy here and the first shader that uses the buffer are ordered after the clear. 95cddd30 states this in the comment next to the clear.@coderabbitai[bot] on GitHub · 2026-10-09 11:58 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 5252 (outdated):@NeySlimThanks for the clarification. The fix in7ed6cc3daddresses this finding: allocations withVkMemoryDedicatedAllocateInfoare excluded from poisoning through a temporary buffer. The block-size checks preserve poisoning coverage for the page table and fault buffer.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@ -5495,0 +5735,4 @@auto readback =CreateHostBuffer(name, faults.Size(), vk::BufferUsageFlagBits::eTransferDst, {});const vk::BufferCopy copy{0, 0, faults.Size()};scheduler.Current().Handle().copyBuffer(faults.Handle(), readback.buffer, 1, ©);@coderabbitai[bot] on GitHub · 2026-10-09 11:59 UTC · original
🧩 Analysis chain
🏁 Script executed:
Length of output: 4843
@NeySlimYou are correct.Buffer::Fillalready records a transfer-write-to-all-commands barrier with memory-read and memory-write destination access. Its second scope covers later commands on the same queue, including later submissions.I missed that existing dependency. The additional barrier before
copyBufferis unnecessary. I withdraw this finding. Thanks for the clarification.✏️ Learnings added
✅ Review thread resolved.
You are interacting with an AI system.
@coderabbitai[bot] on GitHub · 2026-10-13 22:31 UTC · original · edited 2026-10-13 23:06 UTC
On
tests/ShaderRecompilerComputeTests.cppline 5514 (outdated):🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 15622
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5359
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1395
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 2856
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 354
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1326
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1377
Chunk the temporary buffer to fit the device's maximum buffer size.
PoisonDeviceMemorycreates a single buffer with the full allocation size at line 5514. The harness sets VMA'spreferredLargeHeapBlockSizeto2 * BufferCache::BDA_PAGETABLE_SIZE(line 5476), which equals 1.50 GiB. On a device with amaxBufferSizeof 1 GiB, this exceeds the limit and causesvkCreateBufferto fail, aborting the test withRequireVk.Fill the allocation in chunks that do not exceed the device's maximum buffer size. Query
VkPhysicalDeviceMaintenance4Properties::maxBufferSize(or use a safe fallback such as 1 GiB) and issue multiplefillBuffercommands across aligned chunks.🐛 Suggested approach
Modify
PoisonDeviceMemoryto:maxBufferSizelimit.fillBuffer.Alternatively, create a single buffer up to
maxBufferSizeand issue multiplefillBuffercommands on overlapping or sequential ranges to cover the full allocation.✅ Confirmed as addressed by @NeySlim
@coderabbitai[bot] on GitHub · 2026-10-13 22:31 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
173fe7de-9372-4e81-9b38-be3130a9fed6📥 Commits
Reviewing files that changed from the base of the PR and between 6a8e69b982e44b2cecf31df28de3cb0cc28c14e4 and c53f8fcc8102dd05f2c49da376a74efff6f112d9.
📒 Files selected for processing: 2
src/graphics/host_gpu/renderer/cache/bufferCache.cpptests/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.
@NeySlim on GitHub · 2026-10-13 23:06 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 5514 (outdated):Fixed in
d3b2d3d16: the block is now filled through buffers bound at successive offsets, each at most maxBufferSize (Maintenance4). Checked with a forced 64 MiB chunk: the page table poisoning still catches a missing clear.@coderabbitai[bot] on GitHub · 2026-10-13 23:06 UTC · original
On
tests/ShaderRecompilerComputeTests.cppline 5514 (outdated):@NeySlimThanks for the fix ind3b2d3d16. Buffers bound at successive offsets, each limited tomaxBufferSize, address the size-limit concern. Your forced 64 MiB chunk check also confirms that poisoning still detects a missing page-table clear.If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
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.