graphics: refresh only the buffer-written part of an image (opt-in) #2067

Open
github-bot wants to merge 8 commits from github-bot/gh-2067 into main AGit
Owner

@⁠MrBigBritches on GitHub · 2026-11-02 02:25 UTC · original
MrBigBritches:bufmod-partial-refresh → main · +2605 −173 · 25 files · 8 commits · open

When a compute dispatch writes a storage buffer whose address equals an image's base, InvalidateMemoryFromGPU marks 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.

  • At the next bind, only the texels in that range are refreshed.
  • The image keeps its own content elsewhere, and stays marked GPU-written.
  • Linear images copy just the covered rows.
  • Tiled images download the touched blocks, detile only the written bytes over them with a masked region detile, and upload those blocks back. These writes start at the image base, so a 32 KB write over a 4K render target now refreshes one 64 KB block.

A range is recorded only on images whose bytes can be refreshed exactly, and only for writes up to half the image.

  • Eligible:
    • linear images, and the Standard, Prt and RenderTarget tile modes
    • colour images with DCC or CMASK metadata. A base write lands on the data, and the fast-clear keys are consumed after the refresh, so a pending clear still wins.
  • Keep today's whole mark: depth and stencil (HTILE), volumes, MSAA, block-compressed, compressed and video-out images, Fmask, colour-transform formats, and DMA fills and copies.

Anything refused at refresh time falls back to today's full upload:

  • a CPU-dirty image
  • a range that grew past the limit
  • an image the tiler can't handle

With the flag off, nothing changes.

Commits

  1. Range tracking on Image: a range is kept alongside the whole mark. Later marks merge into the range covering them, and a whole mark always wins.
  2. The flag, plus TextureCache::InvalidateBufferWrite: storage-buffer writes record ranges. The upload is still full in this commit, so behaviour is identical.
  3. refreshRegions: maps a byte range to element rectangles (tiled blocks and mip tails, linear rows) and to buffer-to-image copies.
  4. Partial refresh for linear images. A readback waiting on a range-marked image now stays pending until the refresh, instead of being dropped.
  5. Prep: split TileManager::Prepare and Record into helpers, with no behaviour change.
  6. A region-detile variant of the tiler shaders (a REGION spec constant). It uses rectangle origins and a byte window in the existing TilingInfo uniform, with no push-constant or pipeline-layout change. It never clears the target, and the legacy detile and tile paths are unchanged after specialization.
  7. Partial refresh for tiled images: download, masked region detile, upload. The render-target upload check is shared with the full path.
  8. Allow colour DCC and CMASK images.

Measured (LEGO Batman, before the title screen, per 2 s)

These numbers are on top of the other open LEGO changes.

Before With this PR
Steady texture uploads 4.1-4.5 GB 1.6-2.0 GB (skipping the re-uploads entirely gives 1.1-1.4 GB)
Early-scene texture uploads 7.1-7.5 GB 4.3-4.8 GB
GPU wait time 0.72-0.95 s 0.65-0.78 s
FPS, 1% low 30, not recorded 30, 29.6, no visual issues (the scene appears capped at 30)

Tests

Every commit compares the flag on against the flag off, and each mutation fails its own case.

  • Range tracking: merging in both orders, whole-mark precedence, clamping, ignored marks, and heap notification.
  • Recording: the recorded range and kept GPU mark, the half-image threshold at its boundary, and one eligibility case per excluded image kind against a colour baseline.
  • Region mapping (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.
  • Linear refresh:
    • the written texel refreshed and every other texel kept (the flag-off baseline overwrites them)
    • upload bytes cut to the range
    • download consistency
    • padded rows, and a three-rectangle split with distinct guest words
    • fallbacks for over-limit, ineligible, CPU-dirty and tiled images
    • a kept readback
  • Region detile (gpu_tiler):
    • the mask inside a block, origins, a narrow window, chunking and layers
    • a sweep over all five reachable tile families at all five element sizes, each with legacy detile and tile, a full-window region and a partial misaligned region
    • GpuTilerCpuParity still passes
  • Tiled refresh:
    • a 256x256 render target refreshing one block and keeping every other texel, with distinct per-address words
    • a range that starts inside the image
    • a mipped texture where only tail texels change
    • download consistency and a kept readback
  • DCC and CMASK:
    • with a real DCC descriptor, a pending clear wins
    • an applied and checked clear survives a partial refresh (the flag-off baseline loses it)
    • the checked state is kept
    • a real CMASK render target with a register clear pending refreshes partially, and the clear still wins
    • HTILE stays excluded

Known gaps

  • Remaining full re-uploads in LEGO: depth targets (about 1.7 GB of whole marks per 2 s) and new images created over GPU-written bytes (about 1.6 GB).
  • The range is the binding size, not the bytes the shader actually wrote, so a large binding over a small image falls back.
  • Only writes starting at an image's base are detected, as before. A write into the middle of an image still isn't seen.
  • Garbage collection still frees a range-marked, GPU-written image without a readback. That's no worse than today's full refresh.
**@⁠MrBigBritches** on GitHub · 2026-11-02 02:25 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2067) `MrBigBritches:bufmod-partial-refresh` → `main` · +2605 −173 · 25 files · 8 commits · open When a compute dispatch writes a storage buffer whose address equals an image's base, `InvalidateMemoryFromGPU` marks 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. - **At the next bind,** only the texels in that range are refreshed. - **The image keeps its own content elsewhere,** and stays marked GPU-written. - **Linear images** copy just the covered rows. - **Tiled images** download the touched blocks, detile only the written bytes over them with a masked region detile, and upload those blocks back. These writes start at the image base, so a 32 KB write over a 4K render target now refreshes one 64 KB block. **A range is recorded only on images whose bytes can be refreshed exactly, and only for writes up to half the image.** - **Eligible:** - linear images, and the Standard, Prt and RenderTarget tile modes - colour images with DCC or CMASK metadata. A base write lands on the data, and the fast-clear keys are consumed after the refresh, so a pending clear still wins. - **Keep today's whole mark:** depth and stencil (HTILE), volumes, MSAA, block-compressed, compressed and video-out images, Fmask, colour-transform formats, and DMA fills and copies. **Anything refused at refresh time falls back to today's full upload:** - a CPU-dirty image - a range that grew past the limit - an image the tiler can't handle With the flag off, nothing changes. ## Commits 1. **Range tracking on `Image`:** a range is kept alongside the whole mark. Later marks merge into the range covering them, and a whole mark always wins. 2. **The flag, plus `TextureCache::InvalidateBufferWrite`:** storage-buffer writes record ranges. The upload is still full in this commit, so behaviour is identical. 3. **`refreshRegions`:** maps a byte range to element rectangles (tiled blocks and mip tails, linear rows) and to buffer-to-image copies. 4. **Partial refresh for linear images.** A readback waiting on a range-marked image now stays pending until the refresh, instead of being dropped. 5. **Prep: split `TileManager::Prepare` and `Record` into helpers,** with no behaviour change. 6. **A region-detile variant of the tiler shaders** (a `REGION` spec constant). It uses rectangle origins and a byte window in the existing `TilingInfo` uniform, with no push-constant or pipeline-layout change. It never clears the target, and the legacy detile and tile paths are unchanged after specialization. 7. **Partial refresh for tiled images:** download, masked region detile, upload. The render-target upload check is shared with the full path. 8. **Allow colour DCC and CMASK images.** ## Measured (LEGO Batman, before the title screen, per 2 s) These numbers are on top of the other open LEGO changes. | | Before | With this PR | |---|---|---| | Steady texture uploads | 4.1-4.5 GB | 1.6-2.0 GB (skipping the re-uploads entirely gives 1.1-1.4 GB) | | Early-scene texture uploads | 7.1-7.5 GB | 4.3-4.8 GB | | GPU wait time | 0.72-0.95 s | 0.65-0.78 s | | FPS, 1% low | 30, not recorded | 30, 29.6, no visual issues (the scene appears capped at 30) | ## Tests Every commit compares the flag on against the flag off, and each mutation fails its own case. - **Range tracking:** merging in both orders, whole-mark precedence, clamping, ignored marks, and heap notification. - **Recording:** the recorded range and kept GPU mark, the half-image threshold at its boundary, and one eligibility case per excluded image kind against a colour baseline. - **Region mapping (`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. - **Linear refresh:** - the written texel refreshed and every other texel kept (the flag-off baseline overwrites them) - upload bytes cut to the range - download consistency - padded rows, and a three-rectangle split with distinct guest words - fallbacks for over-limit, ineligible, CPU-dirty and tiled images - a kept readback - **Region detile (`gpu_tiler`):** - the mask inside a block, origins, a narrow window, chunking and layers - a sweep over all five reachable tile families at all five element sizes, each with legacy detile and tile, a full-window region and a partial misaligned region - `GpuTilerCpuParity` still passes - **Tiled refresh:** - a 256x256 render target refreshing one block and keeping every other texel, with distinct per-address words - a range that starts inside the image - a mipped texture where only tail texels change - download consistency and a kept readback - **DCC and CMASK:** - with a real DCC descriptor, a pending clear wins - an applied and checked clear survives a partial refresh (the flag-off baseline loses it) - the checked state is kept - a real CMASK render target with a register clear pending refreshes partially, and the clear still wins - HTILE stays excluded ## Known gaps - **Remaining full re-uploads in LEGO:** depth targets (about 1.7 GB of whole marks per 2 s) and new images created over GPU-written bytes (about 1.6 GB). - **The range is the binding size,** not the bytes the shader actually wrote, so a large binding over a small image falls back. - **Only writes starting at an image's base are detected,** as before. A write into the middle of an image still isn't seen. - **Garbage collection** still frees a range-marked, GPU-written image without a readback. That's no worse than today's full refresh.
A buffer write over an image's memory marks the whole image, so its next
bind re-uploads all of it, even when the write covered a few bytes.
Image can now also hold a range mark, as a bounding range of the bytes
that were written. Later marks merge into the range that covers them,
a whole mark always wins, the range is clamped to the image, and marks
that fall outside the image are ignored. A range mark tells resident
image heaps to look at the image again, as a whole mark does. Nothing
records a range yet. The texture cache starts doing so behind an opt-in
flag in a later commit, and every existing caller keeps the whole mark.

The new checks in UnifiedTextureCacheFlow cover:
- the whole mark
- merging, in both orders
- a whole mark not being downgraded
- clearing
- clamping
- ignored marks, on a marked and a clean image
- heap notification, with ignored marks as the baseline
Each of 9 mutations failed its matching check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A compute dispatch that writes a storage buffer at an image's base
marks the whole image, and the image's next bind re-uploads all of it.
In LEGO Batman, 32 KB and 4-byte writes re-upload images of up to
33 MB, several GB every 2 s.

With --partial-buffer-refresh, InvalidateBufferWrite records the
written range on the image instead, and keeps the image's GPU-written
mark, because outside the range the image is newer than the buffer. A
range is recorded only on images whose bytes can be refreshed exactly
later, and only for writes up to half the image. Depth, volume, MSAA,
block-compressed, metadata, video-out, Fmask and colour-transform
images, and the kDepth tile mode, keep today's whole mark. DMA fills
and copies keep the whole mark. A copied image takes the source's mark
as a whole mark.

The upload is still a full refresh in this commit, so InitializeImage
drops the GPU-written mark first, and the result is exactly today's.
Later commits refresh only the recorded range. With the flag off, the
call forwards to the old path.

The new checks in UnifiedTextureCacheFlow compare the flag on and off,
and cover:
- the recorded range, and the GPU-written mark kept
- matching texels and state after the bind
- the half-image threshold, at and over the boundary
- each excluded image kind, one case per trait against a colour
  baseline
A CLI test covers the flag. Each of 20 mutations failed its matching
check, one per eligibility rule plus the flag, threshold, boundary,
range and fallback paths.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A partial refresh needs to know which texels a buffer write covered.
The new refreshRegions helpers turn a byte range of an image into
rectangles of elements, and the rectangles into buffer-to-image copies:
- Tiled images use the tiler's own block layout, so the touched blocks
  of each mip and layer become at most three rectangles, clipped to the
  mip. A mip-tail level shares one block, so it is refreshed whole.
- Linear images split each touched slice into a partial first row, the
  full rows between and a partial last row. Bytes in row padding map
  to no texels.
- Volumes return nothing, so they keep a full refresh.
Ranges are widened to whole elements and 32-bit words. Nothing calls
these yet.

The tests in shaderCfgTests check:
- that every texel whose tiled address is in a range lies in a region
- that every region covers only touched blocks, and that regions don't
  overlap
- exact results at block boundaries, across a block row, for mip tails,
  for array layers, and for linear rows with and without padding
The oracle mirrors TileManager::Prepare and the tiler shader. Each
mutation failed its check, except treating mip-tail levels as blocks,
which gives the same result because a tail fits in one block. A
precondition on the row splitter keeps a padding adjustment from being
dead code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --partial-buffer-refresh, a linear image whose recorded range is
pending now uploads only the texels that range covers, instead of the
whole image. The rest of the image keeps its own contents, which are
newer than the buffer there, so the image stays marked as GPU-written.
Today's full refresh overwrote them with stale buffer bytes.

The partial path runs only when all of these hold:
- the image is eligible
- it is not CPU-dirty
- it is linear
- the range is at most half the image
Anything else counts a fallback and takes the full upload. Tiled images
fall back until a later commit. Only the rounded range is fetched from
the buffer cache. New debug counters record partial refreshes, partial
upload bytes and fallbacks.

A readback that waits on an image with a pending range now stays
pending until the refresh, instead of being dropped.

The tests compare the flag on and off on R32 linear images. They cover:
- the written texel refreshed and every other texel kept
- upload bytes cut to the range
- a later download writing the refreshed and kept texels
- padded rows and a range split over three rectangles, with distinct
  guest words so a wrong row length shows
- fallbacks for an over-limit range, an ineligible image, a CPU-dirty
  image and a tiled image
- the kept readback
Each of 12 mutations failed its check. One commit-2 check that expected
the old full upload now checks the partial result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Prepare and Record were about 120 and 80 lines, and the next commit
needs to extend both for partial detiles. They are now split into
helpers of at most 50 lines, with no change in behaviour.

Prepare now runs, in the same order as before:
- ValidateImageForTiling
- a loop over BuildMip, which takes the mip size as a window that a
  later commit can narrow to a rectangle
- UploadParams

The per-mip checks keep their order, now split into CheckLinearSide and
CheckTiledSide, and the checked arithmetic lambdas become free
functions. Record now runs RecordBarriers, BindTilerDescriptors and
DispatchTexels, with the same barriers, stages, clear and dispatch
order. Shaders, the pipeline layout, spec constants and pipeline slots
are unchanged.

The full test suite passes apart from the known Windows
kernel_file_system failure, including the tiled round-trip and detile
tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A partial refresh of a tiled image has to detile only the blocks a
buffer write touched, and copy only the written bytes within them.
TileManager::DetileRegions does that for a list of element rectangles,
reading from a buffer that holds just the written byte window.

The tiler shaders gain a REGION specialization constant. With it set,
each record carries a rectangle origin and layer, and the shader skips
any element whose tiled byte offset is outside the window, using one
unsigned compare on a source base that may wrap by design. The region
data rides in the existing TilingInfo uniform: each mip record grows
to 64 bytes with the origin, and two spare header words hold the
window. The push constants and pipeline layout are unchanged.

Region pipelines are a third direction in the lazily built slot array.
The detile and tile slots keep their old numbers. With REGION at zero
the shaders compute exactly what they did before. The SPIR-V of every
family changes, but only the legacy behaviour after specialization is
claimed unchanged.

DetileRegions never clears the target, so texels outside the regions
keep their contents. It dispatches up to 16 regions at a time, counts
window texels, and rejects depth and volume images.

The tests compare against the tile tables, with sentinel targets and
misaligned sources. They cover:
- the mask inside a block
- rectangle origins
- a whole-mip rectangle with a narrow window
- several regions in one dispatch, and more than one dispatch
- an array layer
- the CPU-side records
- a sweep over every family a partial refresh reaches at every element
  size, each with legacy detile and tile, a full-window region and a
  partial misaligned region
GpuTilerCpuParity still passes. Every mutation failed, including
dropping the mask, the origin, the layer, the window bias and the
no-clear rule. The compact-buffer size check now expects 64-byte
records.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With --partial-buffer-refresh, a tiled image whose recorded range is
pending now refreshes only the blocks the range touched. LEGO Batman's
32 KB writes over 4K render targets refresh one 64 KB block instead of
the whole image.

The refresh fetches only the written byte window from the buffer cache.
It then downloads the image's current texels for the touched block
rectangles into the linear scratch, detiles just the written elements
over them with the masked region detile, and uploads those rectangles
back. Texels in a touched block but outside the written bytes keep the
image's own values. The image stays marked as GPU-written. A write that
covers no texel, such as bytes of a mip-tail block that no level uses,
clears the mark with no upload.

The tiled path refuses, and the full upload runs instead, for:
- the Depth64KB family
- images too large for the tiler
- render targets that the full upload's own check would reject
That check is now one IsValidColorAttachmentUpload helper shared by
both paths, so they cannot drift apart.

The tests compare the flag on and off on tiled images:
- a 256x256 render target with a 32 KB base write, refreshing one block
  and keeping every other texel, with a check that uses distinct per-
  address words
- a range that starts inside the image
- a mipped Standard64KB texture where only tail texels change
- a later download writing the merged contents
- a pending readback kept until the refresh
The commit-4 placeholder that expected tiled images to fall back now
expects a partial refresh. Every mutation failed: skipping the
download, the detile or the upload, routing to the full upload,
dropping the window start, clearing the GPU-written mark, and planning
the whole image.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Partial refresh excluded every image with metadata. In LEGO Batman that
left most of the remaining full re-uploads in place, because its 4K
colour render target carries DCC and gets hundreds of small storage
writes at its base every few seconds.

Colour DCC and CMASK images are now eligible. A storage write at the
image base lands on the image data, and the metadata lives at its own
address. The keys only matter to MaterializeColorClear, which runs
after the refresh and keeps its checked state. So a pending fast clear
still wins, exactly as with the full refresh. After a clear was
already applied, the partial refresh keeps the cleared texels outside
the written range, where the full refresh brought back stale guest
bytes. Eligibility is now a whitelist of no metadata, DCC and CMASK.
HTILE and any future kind stay on the full refresh, as do depth and
compressed images.

The tests use a real DCC descriptor, flag on and off. They cover:
- a pending clear winning over the refresh on the GPU path
- an applied and checked clear kept outside the written range, which
  the flag-off baseline loses
- the checked state kept across later binds
A real CMASK render target with a register clear pending takes exactly
one partial refresh, and the clear still wins at both corners.
Eligibility rows cover DCC, CMASK, HTILE on a colour image, and a
compression change between the mark and the refresh. Every mutation
failed its check, including refreshing after the clear, forgetting the
checked state, dropping CMASK and admitting every kind.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:13:22 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-02 02:37 UTC · original

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 893b035526 and 9dc8760cb9.

Files selected for processing: 25
  • CMakeLists.txt
  • src/common/debugCounters.h
  • src/common/emulatorConfig.cpp
  • src/common/emulatorConfig.h
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/image.h
  • src/graphics/host_gpu/renderer/image/refreshRegions.cpp
  • src/graphics/host_gpu/renderer/image/refreshRegions.h
  • src/graphics/host_gpu/renderer/image/tiler.cpp
  • src/graphics/host_gpu/renderer/image/tiler.h
  • src/graphics/host_gpu/renderer/pipeline/descriptors.cpp
  • src/graphics/host_gpu/shaders/gpu_tiler_common.inc
  • src/graphics/host_gpu/shaders/gpu_tiler_depth.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_prt.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_prt_3d.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_render_target.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_standard256.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_standard4.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_standard4_3d.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_standard64.comp
  • src/graphics/host_gpu/shaders/gpu_tiler_standard64_3d.comp
  • src/main.cpp
  • tests/ShaderRecompilerComputeTests.cpp
  • tests/shaderCfgTests.cpp

Included 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: nmzik

Change: Feature

Merge Risk: Low · up to 9dc87

The 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: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive 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. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed 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 trac…
Description check Passed 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, …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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.

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)
tests/shaderCfgTests.cpp

Cppcheck timed out; analysis of this file is incomplete

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
**@⁠coderabbitai[bot]** on GitHub · 2026-11-02 02:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2067#issuecomment-6567721232) <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2067?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="16" height="16" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/893b03552699dc873474023bc1f4c69c57fb36b2/.coderabbit.yaml>) - **Commit**: [893b035](<https://github.com/KytyPS5/KytyPS5/commit/893b03552699dc873474023bc1f4c69c57fb36b2>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `c6c2b1a5-4029-4163-9c27-21b3536f2b3d` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> Reviewing files that changed from the base of the PR and between 893b03552699dc873474023bc1f4c69c57fb36b2 and 9dc8760cb9cd99bfc3d69c638bc4d524d92af1a7. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 25</strong></summary> <dl> <dd> * `CMakeLists.txt` * `src/common/debugCounters.h` * `src/common/emulatorConfig.cpp` * `src/common/emulatorConfig.h` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/image/image.h` * `src/graphics/host_gpu/renderer/image/refreshRegions.cpp` * `src/graphics/host_gpu/renderer/image/refreshRegions.h` * `src/graphics/host_gpu/renderer/image/tiler.cpp` * `src/graphics/host_gpu/renderer/image/tiler.h` * `src/graphics/host_gpu/renderer/pipeline/descriptors.cpp` * `src/graphics/host_gpu/shaders/gpu_tiler_common.inc` * `src/graphics/host_gpu/shaders/gpu_tiler_depth.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_prt.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_prt_3d.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_render_target.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_standard256.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_standard4.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_standard4_3d.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_standard64.comp` * `src/graphics/host_gpu/shaders/gpu_tiler_standard64_3d.comp` * `src/main.cpp` * `tests/ShaderRecompilerComputeTests.cpp` * `tests/shaderCfgTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. </dd> </dl> </details> <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> 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:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"9dc8760cb9cd99bfc3d69c638bc4d524d92af1a7" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>9dc87</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔵 Low** · up to `9dc87` --> <!-- final_review_risk_coverage:{"sourceCommitId":"9dc8760cb9cd99bfc3d69c638bc4d524d92af1a7","coveredCommitId":"9dc8760cb9cd99bfc3d69c638bc4d524d92af1a7","kind":"reviewed"} --> The 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. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-inconclusive-14-v2.svg" width="14" height="14" align="middle" alt="Inconclusive" title="Inconclusive"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 inconclusive</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :--------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Inconclusive](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-inconclusive.svg) | 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. Documenta… | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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 trac… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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, … | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> **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. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> **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. </dd> </dl> </details> </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> **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. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- operational_warnings_start --> <!-- This is an auto-generated comment: all tool run failures by coderabbit.ai --> > [!WARNING] > Some tools did not complete. Review the errors below. > > <details> > <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/wrench-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/wrench.svg" width="16" height="16" align="absmiddle" alt=""></picture> Cppcheck (2.22.0)</strong></summary> > <dl> > <dd> > > <details> > <summary><strong>tests/shaderCfgTests.cpp</strong></summary> > <dl> > <dd> > > Cppcheck timed out; analysis of this file is incomplete > > </dd> > </dl> > </details> > > </dd> > </dl> > </details> <!-- end of auto-generated comment: all tool run failures by coderabbit.ai --> <!-- operational_warnings_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2067)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end -->
This pull request has changes conflicting with the target branch.
  • src/common/emulatorConfig.cpp
  • src/common/emulatorConfig.h
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/image/tiler.cpp
  • src/graphics/host_gpu/renderer/image/tiler.h
  • src/main.cpp
  • tests/ShaderRecompilerComputeTests.cpp
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.
git fetch -u origin '+refs/pull/2067/head:github-bot/gh-2067'
git switch 'github-bot/gh-2067'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2067'
git switch 'github-bot/gh-2067'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2067'
git switch 'github-bot/gh-2067'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2067'
git switch 'main'
git merge --squash 'github-bot/gh-2067'
git switch 'main'
git merge --ff-only 'github-bot/gh-2067'
git switch 'main'
git merge 'github-bot/gh-2067'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.