graphics: write proven compute buffer fills to guest memory #1628
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!1628
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1628/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?
@ysnock404 on GitHub · 2026-10-18 01:44 UTC · original
ysnock404:fix/ppsa04159-cpu-buffer-fill→main· +67 −26 · 3 files · 1 commits · merged 2026-10-18 03:42 UTCGoat Simulator 3 (PPSA04159) clears color metadata with compute shaders that fill a typed buffer with one constant. These ranges are not image backings, so ClearImageFromBuffer declined them and the dispatch marked the whole range GPU-modified. The next MaterializeColorClear then had to read the range back synchronously, about once per frame per render target.
When the fill is already proven by ResolveComputeBufferFill, the range is at most 1 MiB, holds no GPU-owned bytes and no registered image, write the value to the guest backing and invalidate the caches instead of dispatching. The metadata stays CPU-owned and needs no readback.
Measured in-game on an RTX 3070 at the same spot:
fps 6.2 -> 8.1
CPU waits on GPU 182/s (243 ms/s) -> 57/s (128 ms/s)
buffer downloads 11.2 MB/s -> 0.1 MB/s
buffer evictions 198/s -> 12/s
No visual difference observed.
@coderabbitai[bot] on GitHub · 2026-10-18 01:49 UTC · original · edited 2026-10-18 03:43 UTC
📝 Walkthrough
When the GPU image-clear path cannot clear a buffer range, the code attempts a CPU fill. The helper accepts ranges up to 1 MiB that are divisible by four, contain no GPU-modified bytes, are not registered as textures, and can be written to guest backing. On success, it writes repeated 32-bit values, invalidates the range, and logs at most 32 fills.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Refactor
Merge Risk: 🟡 Moderate · up to
799a9When a buffer has another guest mapping, this optimization can leave GPU-visible data stale. Address alias handling before merging unless that risk is explicitly accepted.
Pre-merge checks:
4 ·
1
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-18 01:49 UTC · original
On
src/graphics/host_gpu/renderer/renderCompute.cppline 146 (outdated):🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Account for other aliases of the written backing.
If two guest virtual ranges map the same backing bytes,
TryWriteBackingchanges both ranges’ CPU-visible contents.InvalidateMemory(address, size)updates cache state only for the destination virtual range. A cached buffer or image at the other alias can then retain the old value when the GPU reads it. Reject aliased ranges from this fallback, or invalidate every affected alias before returning success. (raw.githubusercontent.com)@coderabbitai[bot] on GitHub · 2026-10-18 01:49 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
310043d7-8ce8-4d2a-ae57-38795c305655📥 Commits
Reviewing files that changed from the base of the PR and between
fe3857a171and 799a98bdff3ede39d8cdff0318e47eaf5d336a5c.📒 Files selected for processing: 1
src/graphics/host_gpu/renderer/renderCompute.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Nmzik on GitHub · 2026-10-18 03:42 UTC · original
@ysnock404 Thanks