graphics: refresh only the buffer-written part of an image (opt-in) #2067
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!2067
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2067"
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:25 UTC · original
MrBigBritches:bufmod-partial-refresh→main· +2605 −173 · 25 files · 8 commits · openWhen a compute dispatch writes a storage buffer whose address equals an image's base,
InvalidateMemoryFromGPUmarks the whole image buffer-modified, and the image's next bind re-uploads all of it. In LEGO Batman (PPSA16833), 32 KB and 4-byte writes at the base of render targets of up to 33 MB re-uploaded 3-6 GB per 2 s before the title screen. These are most likely Unreal RDG transient-heap aliasing writes.Today's full refresh is also wrong: a small write replaces the image's whole GPU contents with stale buffer bytes. A test that skipped these re-uploads entirely showed no visible change and 75% fewer texture uploads. But skipping is unsafe in general. GPU texture streaming, compute buffer-to-texture copies and compute compression do update textures through buffer writes.
With the new opt-in
--partial-buffer-refresh, a storage-buffer write records its byte range on the image instead.A range is recorded only on images whose bytes can be refreshed exactly, and only for writes up to half the image.
Anything refused at refresh time falls back to today's full upload:
With the flag off, nothing changes.
Commits
Image: a range is kept alongside the whole mark. Later marks merge into the range covering them, and a whole mark always wins.TextureCache::InvalidateBufferWrite: storage-buffer writes record ranges. The upload is still full in this commit, so behaviour is identical.refreshRegions: maps a byte range to element rectangles (tiled blocks and mip tails, linear rows) and to buffer-to-image copies.TileManager::PrepareandRecordinto helpers, with no behaviour change.REGIONspec constant). It uses rectangle origins and a byte window in the existingTilingInfouniform, with no push-constant or pipeline-layout change. It never clears the target, and the legacy detile and tile paths are unchanged after specialization.Measured (LEGO Batman, before the title screen, per 2 s)
These numbers are on top of the other open LEGO changes.
Tests
Every commit compares the flag on against the flag off, and each mutation fails its own case.
shader_cfg): an oracle built from the tile tables checks that every texel in a range is covered, that only touched blocks are covered, and exact block boundaries, mip tails, layers and padded linear rows.gpu_tiler):GpuTilerCpuParitystill passesKnown gaps
@coderabbitai[bot] on GitHub · 2026-11-02 02:37 UTC · original
No actionable comments were generated in the recent review.
c6c2b1a5-4029-4163-9c27-21b3536f2b3dReviewing files that changed from the base of the PR and between
893b035526and9dc8760cb9.CMakeLists.txtsrc/common/debugCounters.hsrc/common/emulatorConfig.cppsrc/common/emulatorConfig.hsrc/graphics/host_gpu/renderer/cache/textureCache.cppsrc/graphics/host_gpu/renderer/cache/textureCache.hsrc/graphics/host_gpu/renderer/image/image.hsrc/graphics/host_gpu/renderer/image/refreshRegions.cppsrc/graphics/host_gpu/renderer/image/refreshRegions.hsrc/graphics/host_gpu/renderer/image/tiler.cppsrc/graphics/host_gpu/renderer/image/tiler.hsrc/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/host_gpu/shaders/gpu_tiler_common.incsrc/graphics/host_gpu/shaders/gpu_tiler_depth.compsrc/graphics/host_gpu/shaders/gpu_tiler_prt.compsrc/graphics/host_gpu/shaders/gpu_tiler_prt_3d.compsrc/graphics/host_gpu/shaders/gpu_tiler_render_target.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard256.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard4.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard4_3d.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard64.compsrc/graphics/host_gpu/shaders/gpu_tiler_standard64_3d.compsrc/main.cpptests/ShaderRecompilerComputeTests.cpptests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
Walkthrough
The emulator adds an opt-in partial buffer refresh feature. It tracks buffer write ranges, maps ranges to linear or tiled image regions, and refreshes eligible images through regional uploads or tiled detiling. Ineligible images and unsupported refresh plans use the full-upload path. The changes also add CLI documentation, counters, and tests for range tracking, region mapping, tiler behavior, and texture-cache integration.
Suggested reviewers:
nmzikChange: Feature
Merge Risk:
Low · up to
9dc87The feature is opt-in and off by default. With it enabled, an image written by a small storage-buffer write and then left unbound for many GC cycles can be evicted. Texels outside the written range are then rebuilt from stale guest memory. This is a documented limitation, so it is reasonable to accept for now or follow up on before the flag is promoted.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: an opt-in mode that refreshes only the buffer-written part of an image instead of the whole image. The changeset adds the --partial-buffer-refresh flag, per-range tracking on Image, TextureCache::InvalidateBufferWrite, refreshRegions helpers, and a region-detile tiler path, all of which match this title.
Full details: Description check
Explanation
The description explains the problem (whole-image re-uploads after storage-buffer writes at an image base), the opt-in --partial-buffer-refresh flag, eligibility and fallback rules, measured results, tests, and known gaps. All of these relate directly to the changeset.
Full details: Docstring Coverage
Explanation
Docstring coverage is 60.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 55 functions across 12 files. (13 skipped: 11 unsupported, 2 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.