[draft] gpu: make CPU access wait for pending image readbacks #2120

Closed
github-bot wants to merge 9 commits from gh-pr/2120/head into gh-pr/2120/base
Owner

@⁠MrBigBritches on GitHub · 2026-11-05 04:44 UTC · original
MrBigBritches:readback-fault-wait → main · +2855 −49 · 21 files · 9 commits · closed without merging

Some games read a GPU-written image on the CPU right after its end-of-pipe label. RELEASE_MEM writes that label when the command processor reaches it, before the host GPU has finished, so the game reads old data.

Kena: Bridge of Spirits shows this as objects flickering and vanishing while the camera moves. It looks like UE4's HZB occlusion test: verdicts are drawn to a 256x256 target and copied by a compute dispatch to a linear image, and the CPU then reads that image. With old verdicts, the game skips draws for visible objects.

With --readback-fault-wait, a pending readback's guest pages are blocked until its data lands, so a guest access waits for the data to land. Labels are still written on time. Holding labels instead fixes Kena but lowers Astro Bot's render resolution, which is why #1928 removed them.

The flag is off by default and requires --readback-linear-images. There is no launcher field yet, so it is command-line only.

Stacked on #1928. Its two commits come first here, and this stays a draft until that PR lands.

Commits

These follow #1928's two commits.

  1. page_manager: add a readback hold count. A hold blocks all guest access to a page and is counted separately from watchers.
  2. texture_cache: add ReadbackGuard. Tracks held ranges and waits. A wait gives up after 2 s without GPU progress or 30 s in total, and the hold is then lifted so the guest reads old data rather than hanging. Three timeouts in a row stop holds for the session.
  3. texture_cache: hold qualifying readbacks until they land. Only linear images with one level, one layer and one depth slice qualify, up to 1 MiB, and only their whole pages are held. Private mappings are excluded.
  4. gpu: make guest faults wait for held readbacks. Each kind of thread takes the route it can safely take:
    • A guest thread waits on the guard.
    • The GPU thread submits and waits directly, because only it can submit the landing. It uses Wait rather than Finish, since pending operations could free a buffer the faulting code is still using.
    • The priority thread and pending operations lift the hold, because waiting there could never end. The guest may see old data in this case.
  5. gpu: wait for held readbacks before host file calls. A host call fails on a held page instead of faulting, so file reads and writes wait first.
  6. config: add --readback-fault-wait. With no image readback on, the flag does nothing and logs one line saying so.
  7. gpu: reword and wrap readback fault comments. No code changes.

Behaviour change with the flag on

Write faults on any mapped page change slightly, not only faults on held pages. If no watcher still explains a fault, it's treated as stale and retried, without entering the normal path. Without this, a fault taken under the texture cache's lock could try to take that lock again.

In the longest Kena run this fired 449,861 times, almost all on writes. Only 5,946 repeated the same address as that thread's last stale fault, and the longest streak was 99. It also fires when no pages are held at all, so holds don't cause it. Those numbers point to threads racing on one page rather than a thread stuck retrying, though I haven't confirmed that cause.

Tested

All runs are on Windows, with --readback-linear-images and --readback-tiled-images on. Flag off and on refer to --readback-fault-wait. Fps is the overlay's 30 s average from single runs.

Game Flag off Flag on Holds Guest waits
Kena 31.6 fps, flicker 29.0 and 29.8 fps, no flicker 5,722 in the longest run 5,294
Astro Bot 38.5 fps 40.1 fps, AA and resolution look correct 1,076 0
Octopath II, Throné's opening Lighting correct Lighting correct 2,366 0
LEGO Batman 17.2 fps, smoke clean 17.1 fps, smoke clean 0 0
Atelier Yumia 59.6 fps 59.6 fps 0 0
  • Kena with protection skipped: every step ran except blocking the pages, giving 31.1 fps with the flicker back. So the holds are what fixes it.
  • Kena's waits: in the longest run they averaged 0.54 ms, the longest was 11.4 ms, and there were no timeouts, lifts or GPU-thread stalls. That run covered different areas, a save reload and a normal exit. Suspend and resume weren't tested.
  • Kena's cost: about 6-8%. Waits explain only about 0.6 ms of the roughly 2.8 ms a frame lost, and I haven't found the rest.
  • How these runs were set up: they used the previous base, a7e14aa7, plus an unstaged measurement patch and an environment switch in place of the flag.
  • After rebasing onto 07e87b95: one Kena pair with the real flag, started from the command line, gave 24.8 fps with flicker with the flag off, and 23.0 fps without flicker with it on. That launch path wrote no log, so this pair has no counts, and its fps can't be compared with the launcher runs above.

Only Kena exercises the wait path. Astro Bot and Octopath show holds are harmless when nothing reads them, and LEGO and Yumia hold nothing.

Tests

  • page_manager: hold counts and how they combine with watchers.
  • readback_guard (new): the qualifying gate, waits, timeouts, progress, the stop after repeated timeouts, and lifts.
  • shader_recompiler_compute:
    • ReadbackHoldAtLabel: pages are blocked while pending and open afterwards, the label is still written at once, images that don't qualify are never held, and unmapping is safe with a hold pending.
    • ReadbackFaultWait: each thread route, including a guest write that a baseline with the flag off loses to the landing and that now survives.
    • ReadbackFaultWaitFlag: the flag's default, and that it needs a readback option.

The full suite passes apart from three existing problems: common, kernel_file_system, and vdecsw_tests, which doesn't build on Windows (#1966). On my Windows build the compute test also needed #undef near and #undef far to compile. I added those locally and left them out of this PR.

Mutations. Each change was checked by breaking it and confirming that a test fails. About 90 mutations were killed. These survive:

  • page_manager: the tracked-space guard being off by one, which needs a sanitizer.
  • ReadbackGuard: a timeout lift not notifying other waiters, which only delays them by one wait slice, and EXIT_IF on an empty progress source.
  • Texture cache:
    • the tiled check wired wrongly, because the test setup doesn't reach the download
    • removing the second backing read
    • not refreshing progress, which needs a 2 s GPU stall to show
    • a landing releasing before it writes
    • a failed second read leaking its hold
    • shutdown leaving holds behind

These have no automated coverage:

  • The KernelRead socket branch, KernelPwrite and Writev, which were only checked by reading.
  • The flag's entry in the main.cpp table, checked with --help and the command-line Kena run.
  • The log lines.

Known issues

  • Only tested on Windows. The flag makes blocking inside the signal handler reachable on Linux and macOS, and that hasn't been run. CI on those platforms doesn't run the compute test, so of this PR's tests only page_manager and readback_guard run there.
  • Other host calls aren't covered. POSIX socket calls such as recv and send, getsockopt, setsockopt, Linux select and futex, and libSaveData's WriteFile still pass guest pointers to the OS without waiting. None looks like a readback target.
  • A hold can start after a host call's wait. There's no retry in that gap.
  • A file read waits only for the bytes left in the file, while ReadFile receives the full length.
  • Only whole pages are held. Edge pages of an unaligned image, images under one page, tiled images and anything over 1 MiB behave as they do without the flag. Kena also reads back an image under one page, about one per hold. The flicker is gone without holding it.
  • Other ways around a hold: a guest mprotect opens a held page, a release can restore read-write over a guest read-only setting, and direct-memory aliases at another address aren't held.
  • Shutdown race. A guest thread still waiting when the render context is destroyed could touch freed memory. Fault handling already has this race, and the file-call waits widen it. I haven't verified whether guest threads are still alive at that point.
  • A single submit longer than 2 s looks like no progress, because only completed ticks count.
  • GPU-thread route. It has no timeout. I found no lock cycle in the priority operations I read, but didn't trace inside CompleteFlip or TriggerInterrupt.
**@⁠MrBigBritches** on GitHub · 2026-11-05 04:44 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2120) `MrBigBritches:readback-fault-wait` → `main` · +2855 −49 · 21 files · 9 commits · closed without merging Some games read a GPU-written image on the CPU right after its end-of-pipe label. `RELEASE_MEM` writes that label when the command processor reaches it, before the host GPU has finished, so the game reads old data. Kena: Bridge of Spirits shows this as objects flickering and vanishing while the camera moves. It looks like UE4's HZB occlusion test: verdicts are drawn to a 256x256 target and copied by a compute dispatch to a linear image, and the CPU then reads that image. With old verdicts, the game skips draws for visible objects. With `--readback-fault-wait`, a pending readback's guest pages are blocked until its data lands, so a guest access waits for the data to land. Labels are still written on time. Holding labels instead fixes Kena but lowers Astro Bot's render resolution, which is why #1928 removed them. The flag is off by default and requires `--readback-linear-images`. There is no launcher field yet, so it is command-line only. **Stacked on #1928.** Its two commits come first here, and this stays a draft until that PR lands. ## Commits These follow #1928's two commits. 1. **`page_manager: add a readback hold count`.** A hold blocks all guest access to a page and is counted separately from watchers. 2. **`texture_cache: add ReadbackGuard`.** Tracks held ranges and waits. A wait gives up after 2 s without GPU progress or 30 s in total, and the hold is then lifted so the guest reads old data rather than hanging. Three timeouts in a row stop holds for the session. 3. **`texture_cache: hold qualifying readbacks until they land`.** Only linear images with one level, one layer and one depth slice qualify, up to 1 MiB, and only their whole pages are held. Private mappings are excluded. 4. **`gpu: make guest faults wait for held readbacks`.** Each kind of thread takes the route it can safely take: - A guest thread waits on the guard. - The GPU thread submits and waits directly, because only it can submit the landing. It uses `Wait` rather than `Finish`, since pending operations could free a buffer the faulting code is still using. - The priority thread and pending operations lift the hold, because waiting there could never end. The guest may see old data in this case. 5. **`gpu: wait for held readbacks before host file calls`.** A host call fails on a held page instead of faulting, so file reads and writes wait first. 6. **`config: add --readback-fault-wait`.** With no image readback on, the flag does nothing and logs one line saying so. 7. **`gpu: reword and wrap readback fault comments`.** No code changes. ## Behaviour change with the flag on Write faults on any mapped page change slightly, not only faults on held pages. If no watcher still explains a fault, it's treated as stale and retried, without entering the normal path. Without this, a fault taken under the texture cache's lock could try to take that lock again. In the longest Kena run this fired 449,861 times, almost all on writes. Only 5,946 repeated the same address as that thread's last stale fault, and the longest streak was 99. It also fires when no pages are held at all, so holds don't cause it. Those numbers point to threads racing on one page rather than a thread stuck retrying, though I haven't confirmed that cause. ## Tested All runs are on Windows, with `--readback-linear-images` and `--readback-tiled-images` on. Flag off and on refer to `--readback-fault-wait`. Fps is the overlay's 30 s average from single runs. | Game | Flag off | Flag on | Holds | Guest waits | |---|---|---|---|---| | Kena | 31.6 fps, flicker | 29.0 and 29.8 fps, no flicker | 5,722 in the longest run | 5,294 | | Astro Bot | 38.5 fps | 40.1 fps, AA and resolution look correct | 1,076 | 0 | | Octopath II, Throné's opening | Lighting correct | Lighting correct | 2,366 | 0 | | LEGO Batman | 17.2 fps, smoke clean | 17.1 fps, smoke clean | 0 | 0 | | Atelier Yumia | 59.6 fps | 59.6 fps | 0 | 0 | - **Kena with protection skipped:** every step ran except blocking the pages, giving 31.1 fps with the flicker back. So the holds are what fixes it. - **Kena's waits:** in the longest run they averaged 0.54 ms, the longest was 11.4 ms, and there were no timeouts, lifts or GPU-thread stalls. That run covered different areas, a save reload and a normal exit. Suspend and resume weren't tested. - **Kena's cost:** about 6-8%. Waits explain only about 0.6 ms of the roughly 2.8 ms a frame lost, and I haven't found the rest. - **How these runs were set up:** they used the previous base, a7e14aa7, plus an unstaged measurement patch and an environment switch in place of the flag. - **After rebasing onto 07e87b95:** one Kena pair with the real flag, started from the command line, gave 24.8 fps with flicker with the flag off, and 23.0 fps without flicker with it on. That launch path wrote no log, so this pair has no counts, and its fps can't be compared with the launcher runs above. Only Kena exercises the wait path. Astro Bot and Octopath show holds are harmless when nothing reads them, and LEGO and Yumia hold nothing. ## Tests - **`page_manager`:** hold counts and how they combine with watchers. - **`readback_guard` (new):** the qualifying gate, waits, timeouts, progress, the stop after repeated timeouts, and lifts. - **`shader_recompiler_compute`:** - **`ReadbackHoldAtLabel`:** pages are blocked while pending and open afterwards, the label is still written at once, images that don't qualify are never held, and unmapping is safe with a hold pending. - **`ReadbackFaultWait`:** each thread route, including a guest write that a baseline with the flag off loses to the landing and that now survives. - **`ReadbackFaultWaitFlag`:** the flag's default, and that it needs a readback option. The full suite passes apart from three existing problems: `common`, `kernel_file_system`, and `vdecsw_tests`, which doesn't build on Windows (#1966). On my Windows build the compute test also needed `#undef near` and `#undef far` to compile. I added those locally and left them out of this PR. **Mutations.** Each change was checked by breaking it and confirming that a test fails. About 90 mutations were killed. These survive: - `page_manager`: the tracked-space guard being off by one, which needs a sanitizer. - `ReadbackGuard`: a timeout lift not notifying other waiters, which only delays them by one wait slice, and `EXIT_IF` on an empty progress source. - Texture cache: - the tiled check wired wrongly, because the test setup doesn't reach the download - removing the second backing read - not refreshing progress, which needs a 2 s GPU stall to show - a landing releasing before it writes - a failed second read leaking its hold - shutdown leaving holds behind These have no automated coverage: - The `KernelRead` socket branch, `KernelPwrite` and `Writev`, which were only checked by reading. - The flag's entry in the `main.cpp` table, checked with `--help` and the command-line Kena run. - The log lines. ## Known issues - **Only tested on Windows.** The flag makes blocking inside the signal handler reachable on Linux and macOS, and that hasn't been run. CI on those platforms doesn't run the compute test, so of this PR's tests only `page_manager` and `readback_guard` run there. - **Other host calls aren't covered.** POSIX socket calls such as `recv` and `send`, `getsockopt`, `setsockopt`, Linux `select` and futex, and `libSaveData`'s `WriteFile` still pass guest pointers to the OS without waiting. None looks like a readback target. - **A hold can start after a host call's wait.** There's no retry in that gap. - **A file read waits only for the bytes left in the file**, while `ReadFile` receives the full length. - **Only whole pages are held.** Edge pages of an unaligned image, images under one page, tiled images and anything over 1 MiB behave as they do without the flag. Kena also reads back an image under one page, about one per hold. The flicker is gone without holding it. - **Other ways around a hold:** a guest `mprotect` opens a held page, a release can restore read-write over a guest read-only setting, and direct-memory aliases at another address aren't held. - **Shutdown race.** A guest thread still waiting when the render context is destroyed could touch freed memory. Fault handling already has this race, and the file-call waits widen it. I haven't verified whether guest threads are still alive at that point. - **A single submit longer than 2 s looks like no progress**, because only completed ticks count. - **GPU-thread route.** It has no timeout. I found no lock cycle in the priority operations I read, but didn't trace inside `CompleteFlip` or `TriggerInterrupt`.
Count the image readbacks whose guest write has not run yet, so tests can
tell when GPU results are still on their way to guest memory. The count
includes the write-backs of evicted images, even with readbacks off,
because an evicted image's data then exists only in its pending
write-back.

ProcessDownloadImages() now reports whether it queued a copy and keeps an
enrolled image it cannot download yet, for example while a CPU write is
newer than the GPU one, instead of dropping it. Images that can never be
downloaded are still dropped. With readbacks on, such an image's GPU
result can now reach guest memory at a later pass, where before it was
lost. The next commit drops these images at end-of-pipe labels, so the
retry mostly matters between labels.

DownloadImageMemory() commits download-buffer space only after reading
the guest data succeeds, so an image whose read keeps failing does not
use up the buffer on every retry. The new test covers the retry and the
count, but not a failing read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Games read GPU-written images on the CPU after waiting for an end-of-pipe
label. UE4 does this for sky-light ambient: it renders the irradiance SH
into a small RGBA16F target and reads it back after the frame's label.
With --readback-linear-images or --readback-tiled-images, readbacks were
only queued at the garbage-collector pass, so in Octopath Traveler II the
guest read stale data and Throné's opening scene was left without
ambient light.

RELEASE_MEM now queues the pending readbacks before its label and submits
them at once. The GDS path submits them through its existing Finish().
Their data reaches guest memory about when the label's GPU work finishes.
An interrupt is still a priority operation queued after them, so it is
raised once their data has landed.

The label itself is written at once, as before. Holding it back until
the readbacks land made it reach the guest only after the host GPU ran
everything before it, which showed the game the host GPU's real speed.
Astro Bot then halved its dynamic resolution. In Throné's opening scene
the readbacks still land before the game reads them.

At a label, images that cannot be downloaded yet are dropped. Such an
image was written by the CPU after the GPU, so its guest memory is
already newer, and a retry would land a frame or more later. The
garbage collector still keeps them for a retry.

Known limitation: readbacks land after the label, not before it. A guest
that reads a readback target straight after seeing the label can still
see stale data, and a guest write to it before the readback lands is
overwritten. The garbage-collector path had the same race once a frame.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A later change holds the guest pages of a pending image readback until it
lands, so a guest read that arrives early can wait for the data instead of
seeing the old bytes. Holds need their own count because a read watch allows
only one owner per page, and a readback can share a page with one.

PageState grows to 16 bits with an 8-bit hold count, and a held page is
NoAccess. WatchersAllowAccess reports whether a watcher or hold blocks an
access, under the region lock, so a fault handler can recognise a stale fault.
It can't tell an untracked page from a released one, so a caller must check
that the guest may make the access first.

Nothing in the emulator calls these yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A game can read a GPU-written image as soon as it sees an end-of-pipe label,
but the label is written when the command processor reaches it, ahead of the
host GPU. Holding the label shows the game the host GPU's real speed, which
lowered Astro Bot's resolution, so the guard blocks the pages instead. A guest
that reads them early waits for the data, and a game that never reads them
pays nothing.

Only whole pages of small single-level linear images qualify, so unrelated
data never waits. A wait gives up only when the GPU stops making progress,
since long GPU stalls exist, and repeated timeouts stop holds for the session
rather than stalling every frame.

Nothing in the emulator calls this yet. The tests use real page protection
and a real fault blocking in the host exception handler, and also run on Linux
and macOS CI.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A readback's whole guest pages are now blocked from before its snapshot until
its write-back lands, so a later change can make an early guest read wait for
the data. The end-of-pipe label is still written at once, because a held label
shows a game the host GPU's real speed.

Only images that pass ReadbackGuard's gate are held. A backing read comes first,
so private mappings are never held: a thread copying from one keeps the
address-space lock, and a fault there could wait while the landing needs it. A
real unmap already waits for pending landings, and the cache's unmap lifts any
hold in the range.

Nothing enables this yet, so behaviour doesn't change outside tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A fault on a page held for a pending readback now ends with the guest
seeing the GPU's data, by the route each kind of thread can safely take.

A guest thread waits on the guard. The GPU thread can't, because only it
can submit the landing, so it submits and waits directly. It uses Wait and
not Finish, since pending operations could free a buffer that the code
which faulted is still preparing to use. The priority thread and pending
operations lift the hold instead, because waiting there could never end.

A fault that arrives just after its hold ended is treated as handled when
no watcher explains it, so it doesn't reach the normal path, which can
relock the texture cache from under a fault.

The switch stays off until a later commit adds its flag, so this changes
nothing for users yet. ActiveWaiters gives the tests a way to order a
landing after a waiter without sleeping.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A host call that takes a guest pointer fails on a held page rather than
faulting, so the fault wait can't help it. A file read would return an
error or a short count to the game.

InvalidateMemory now waits first, which covers file reads, and it waits
before the mapped check because a range that isn't wholly mapped can still
overlap a held page. KernelWrite, KernelPwrite, Writev and the socket branch
of KernelRead wait through a new Memory::WaitForGpuReadbacks.

There's no retry if a hold starts between the wait and the host call. Other
routes that hand guest pointers to the OS, such as the POSIX socket calls,
aren't covered. None of them looks like a readback target.

The switch is still off, so no pages are held and each of these calls costs
one atomic load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The flag turns on the fault waits and holds from the previous commits. CPU
access to a pending linear image readback now waits for its data, instead of
seeing what the guest memory held before the GPU wrote it. Kena's HZB occlusion
verdicts were read that way, which made objects flicker.

It needs image readback to be on and doesn't turn it on itself. Alone it does
nothing and logs one line saying so. With tiled readback only, normal readbacks
hold nothing, since only linear images can be held.

It's off by default and has no launcher field. Validated on Windows only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The stale-fault comment named only holds, but measurement shows the path also
fires for ordinary watchers that ended just before the fault. The rest is
wrapping to the column limit. No code changes.

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

@⁠coderabbitai[bot] on GitHub · 2026-11-05 04:51 UTC · original

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds optional page holds for eligible GPU image readbacks. Guest faults and host calls can wait for pending readbacks, while GPU-related execution paths can lift holds when they cannot wait. Readback submission is coordinated with labels, and tests and build workflows now cover the guard, page tracking, and access paths.

Suggested reviewers: nmzik

Change: Bug fix

Merge Risk: Minimal · up to 4d226

The change adds an opt-in, default-off flag that lets CPU access wait for pending GPU image readbacks. No concrete merge-blocking defect was established, so behavior with the flag off should be unchanged. Testing was reported on Windows only, so Linux and macOS behavior with the flag on is unverified.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 44.59% 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 clearly and concisely summarizes the main change: CPU access waits for pending image readbacks.
Description check Passed The description is directly related to the changeset. It explains the new opt-in flag, readback holds, wait behavior, tests, performance results, and known limitations.
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: Docstring Coverage

Explanation

Docstring coverage is 44.59% 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 74 functions across 18 files. (3 skipped: 2 unsupported, 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 07e87b950a and 4d226996f5.

Files selected for processing: 21

  • .github/workflows/build.yml
  • CMakeLists.txt
  • src/common/emulatorConfig.cpp
  • src/common/emulatorConfig.h
  • src/graphics/guest_gpu/command_processor/commandProcessor.h
  • src/graphics/guest_gpu/graphicsRun.cpp
  • src/graphics/host_gpu/pageManager.cpp
  • src/graphics/host_gpu/pageManager.h
  • src/graphics/host_gpu/renderer/cache/readbackGuard.cpp
  • src/graphics/host_gpu/renderer/cache/readbackGuard.h
  • src/graphics/host_gpu/renderer/cache/textureCache.cpp
  • src/graphics/host_gpu/renderer/cache/textureCache.h
  • src/graphics/host_gpu/renderer/renderContext.cpp
  • src/graphics/host_gpu/renderer/renderContext.h
  • src/kernel/fileSystem.cpp
  • src/kernel/memory.cpp
  • src/kernel/memory.h
  • src/main.cpp
  • tests/PageManagerTests.cpp
  • tests/ReadbackGuardTests.cpp
  • tests/ShaderRecompilerComputeTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-05 04:51 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2120#issuecomment-6649995188) <!-- 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/2120?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> The change adds optional page holds for eligible GPU image readbacks. Guest faults and host calls can wait for pending readbacks, while GPU-related execution paths can lift holds when they cannot wait. Readback submission is coordinated with labels, and tests and build workflows now cover the guard, page tracking, and access paths. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"4d226996f51a3ae3121535475d8d7a3bcacc92af" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- 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-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>4d226</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `4d226` --> <!-- final_review_risk_coverage:{"sourceCommitId":"4d226996f51a3ae3121535475d8d7a3bcacc92af","coveredCommitId":"4d226996f51a3ae3121535475d8d7a3bcacc92af","kind":"reviewed"} --> The change adds an opt-in, default-off flag that lets CPU access wait for pending GPU image readbacks. No concrete merge-blocking defect was established, so behavior with the flag off should be unchanged. Testing was reported on Windows only, so Linux and macOS behavior with the flag on is unverified. <!-- 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> <br> <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 44.59% 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> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely summarizes the main change: CPU access waits for pending image readbacks. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description is directly related to the changeset. It explains the new opt-in flag, readback holds, wait behavior, tests, performance results, and known limitations. | | 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. | </dd> </dl> </details> <details> <summary><strong>Full details: Docstring Coverage</strong></summary> <dl> <dd> <br> **Explanation** Docstring coverage is 44.59% 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 74 functions across 18 files. (3 skipped: 2 unsupported, 1 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 --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2120)! 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> <br> - [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 --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- 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> <br> - **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/07e87b950a9cbe590c13e8dcc5346bc1f5480506/.coderabbit.yaml>) - **Commit**: [07e87b9](<https://github.com/KytyPS5/KytyPS5/commit/07e87b950a9cbe590c13e8dcc5346bc1f5480506>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `203da161-1f11-41ef-bc41-33f7bad9c5a0` </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> <br> Reviewing files that changed from the base of the PR and between 07e87b950a9cbe590c13e8dcc5346bc1f5480506 and 4d226996f51a3ae3121535475d8d7a3bcacc92af. </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: 21</strong></summary> <dl> <dd> <br> * `.github/workflows/build.yml` * `CMakeLists.txt` * `src/common/emulatorConfig.cpp` * `src/common/emulatorConfig.h` * `src/graphics/guest_gpu/command_processor/commandProcessor.h` * `src/graphics/guest_gpu/graphicsRun.cpp` * `src/graphics/host_gpu/pageManager.cpp` * `src/graphics/host_gpu/pageManager.h` * `src/graphics/host_gpu/renderer/cache/readbackGuard.cpp` * `src/graphics/host_gpu/renderer/cache/readbackGuard.h` * `src/graphics/host_gpu/renderer/cache/textureCache.cpp` * `src/graphics/host_gpu/renderer/cache/textureCache.h` * `src/graphics/host_gpu/renderer/renderContext.cpp` * `src/graphics/host_gpu/renderer/renderContext.h` * `src/kernel/fileSystem.cpp` * `src/kernel/memory.cpp` * `src/kernel/memory.h` * `src/main.cpp` * `tests/PageManagerTests.cpp` * `tests/ReadbackGuardTests.cpp` * `tests/ShaderRecompilerComputeTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠Nmzik on GitHub · 2026-11-07 16:55 UTC · original

@⁠MrBigBritches merged & credited

**@⁠Nmzik** on GitHub · 2026-11-07 16:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2120#issuecomment-6710240172) @⁠MrBigBritches merged & credited

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.