fix(agc): store linear compute writes behind their dispatch #6948

Merged
alfalfa-star merged 4 commits from upstream-pr/6948 into main 2026-10-23 09:12:45 +00:00
alfalfa-star commented 2026-10-16 20:50:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-16T20:50:38Z.


What

Kena: Bridge of Spirits (PPSA01802): terrain, the player character and props pop in and out every few frames while the camera turns, and the sky and fog show through the ground where terrain is missing.

UE4 tests its hierarchical-Z occlusion on the GPU into a 256x256 tiled target, then a compute shader (0x2006e70000 in Kena) copies the results into a 256x256 linear image (format 60) that the CPU reads after the frame's fence to decide which primitives to draw next frame. That linear image stayed pending as a storage image: the flip-time store (StoreSmallPending) skips surfaces over 64 KiB (this one is 256 KiB), and it runs after the fence the CPU waits on anyway. So the CPU read stale or empty occlusion results and culled visible primitives.

Before a label or an end-of-pipe interrupt the CPU may wait on, every pending linear storage image and every pending image of at most SmallStoreBytes (64 KiB, any tile mode) is stored to guest memory (StorageTexture::StoreReadbackBeforeLabel, a FlushPending over each one). The store is recorded in GPU order before the label, so the CPU sees the results once the fence passes. Only images the GPU wrote are pending, and an image is stored once per write. Larger tiled images are left alone. APS5_NO_LABEL_READBACK_STORE=1 restores the old behaviour.

The same pattern on a small tiled image, reported by Pacuka: The Smurfs - Dreams (PPSA21607) computes the sky light's average brightness into a 1x1 RGBA16F R64KBX storage image and reads it on the CPU after a label. The image stayed pending, the CPU read 0, and the Smurfs' Village rendered washed out (specular about 100x too strong).

Tested

AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9), Kena: Bridge of Spirits (PPSA01802).

  • New test agc_driver_linear_readback_label: a PM4 dispatch stores into a linear 32x8 8_8_8_8_UINT image, a RELEASE_MEM label follows, the test polls the label and reads guest memory. A second case does the same with a 16x16 32_UINT R64KBX image (64 KiB); before the small-tiled change it failed with 0 of 8 texels stored. Both pass. agc_driver_linear_readback_label_off runs it with APS5_NO_LABEL_READBACK_STORE=1 and is expected to fail (texel (0, 0) reads the old bytes).
  • The Smurfs - Dreams (PPSA21607), rebased on main 0d078f75d: with only linear images stored, the village is washed out (near-white); with small images too, it renders correctly. Village presents per 10 s are 100-105 vs 100-108. One of three runs with the change crashed during loading in game code (app.elf+0x290e36, a null table pointer read on a new thread); the other two reached the village. The cause is not known.
  • Kena forest title scene on main 0d078f75d, no input, APS5_PROFILE_DRAW=1, 150 s, three alternating rounds, mean presents per 10 s of the last four windows: linear only 56.3 / 66.3 / 72.3, with small images 60.8 / 67.8 / 68.5 (within the spread). The flip-time stores (about 450 per 10 s) now happen at labels: readback before label about 740 per 10 s and 55 MiB, against linear before label about 130 and flip about 450 (45 MiB together).
  • Kena, fixed camera turn from the save's start position, every presented frame dumped (first version of this change, which stored at the dispatch): without the fix whole terrain patches and the player model drop out for single frames; with it the terrain and character stay solid. Forcing the occlusion results to "all visible" (diagnostic, not part of this PR) also removed the popping.
  • Kena forest title scene on main f8b22edfb, no input, APS5_TRACE_SECONDS=100:30, three alternating rounds: main 165 / 175 / 181 presents, this PR 176 / 155 / 169 (within the spread). About 2 stores per present, about 127 KiB each ([storage] line of an APS5_PROFILE_DRAW run: linear before label 209/26.3 MiB per 10 s at 103 presents). Summary lines in the review reply.
  • ctest on main 0d078f75d + this PR: 1439 of 1440 pass; agc_driver_tessellation segfaults inside RADV (LinkPipelineFromLibraries) on main too.

Checklist

  • Based on current main; no other open PR implements the same functions (#6960 also stores pending images before a label, at the same two call sites, but only images over memory outside the write watch (!GuestMemory::Watched), for stores a CPU write could lose; images over watched memory stay pending there)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA01802 (terrain, player and props culled; no bring-up discussion yet), PPSA21607 (village washed out)
  • GPUs tested: AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4894120021 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-16T20:50:38Z. --- ### What Kena: Bridge of Spirits (PPSA01802): terrain, the player character and props pop in and out every few frames while the camera turns, and the sky and fog show through the ground where terrain is missing. UE4 tests its hierarchical-Z occlusion on the GPU into a 256x256 tiled target, then a compute shader (`0x2006e70000` in Kena) copies the results into a 256x256 **linear** image (format 60) that the CPU reads after the frame's fence to decide which primitives to draw next frame. That linear image stayed pending as a storage image: the flip-time store (`StoreSmallPending`) skips surfaces over 64 KiB (this one is 256 KiB), and it runs after the fence the CPU waits on anyway. So the CPU read stale or empty occlusion results and culled visible primitives. Before a label or an end-of-pipe interrupt the CPU may wait on, every pending linear storage image and every pending image of at most `SmallStoreBytes` (64 KiB, any tile mode) is stored to guest memory (`StorageTexture::StoreReadbackBeforeLabel`, a `FlushPending` over each one). The store is recorded in GPU order before the label, so the CPU sees the results once the fence passes. Only images the GPU wrote are pending, and an image is stored once per write. Larger tiled images are left alone. `APS5_NO_LABEL_READBACK_STORE=1` restores the old behaviour. The same pattern on a small tiled image, reported by Pacuka: The Smurfs - Dreams (PPSA21607) computes the sky light's average brightness into a 1x1 RGBA16F R64KBX storage image and reads it on the CPU after a label. The image stayed pending, the CPU read 0, and the Smurfs' Village rendered washed out (specular about 100x too strong). ### Tested AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9), Kena: Bridge of Spirits (PPSA01802). - New test `agc_driver_linear_readback_label`: a PM4 dispatch stores into a linear 32x8 8_8_8_8_UINT image, a RELEASE_MEM label follows, the test polls the label and reads guest memory. A second case does the same with a 16x16 32_UINT R64KBX image (64 KiB); before the small-tiled change it failed with 0 of 8 texels stored. Both pass. `agc_driver_linear_readback_label_off` runs it with `APS5_NO_LABEL_READBACK_STORE=1` and is expected to fail (texel (0, 0) reads the old bytes). - The Smurfs - Dreams (PPSA21607), rebased on `main` 0d078f75d: with only linear images stored, the village is washed out (near-white); with small images too, it renders correctly. Village presents per 10 s are 100-105 vs 100-108. One of three runs with the change crashed during loading in game code (`app.elf+0x290e36`, a null table pointer read on a new thread); the other two reached the village. The cause is not known. - Kena forest title scene on `main` 0d078f75d, no input, `APS5_PROFILE_DRAW=1`, 150 s, three alternating rounds, mean presents per 10 s of the last four windows: linear only 56.3 / 66.3 / 72.3, with small images 60.8 / 67.8 / 68.5 (within the spread). The flip-time stores (about 450 per 10 s) now happen at labels: `readback before label` about 740 per 10 s and 55 MiB, against `linear before label` about 130 and `flip` about 450 (45 MiB together). - Kena, fixed camera turn from the save's start position, every presented frame dumped (first version of this change, which stored at the dispatch): without the fix whole terrain patches and the player model drop out for single frames; with it the terrain and character stay solid. Forcing the occlusion results to "all visible" (diagnostic, not part of this PR) also removed the popping. - Kena forest title scene on `main` f8b22edfb, no input, `APS5_TRACE_SECONDS=100:30`, three alternating rounds: `main` 165 / 175 / 181 presents, this PR 176 / 155 / 169 (within the spread). About 2 stores per present, about 127 KiB each (`[storage]` line of an `APS5_PROFILE_DRAW` run: `linear before label` 209/26.3 MiB per 10 s at 103 presents). Summary lines in the review reply. - ctest on `main` 0d078f75d + this PR: 1439 of 1440 pass; `agc_driver_tessellation` segfaults inside RADV (`LinkPipelineFromLibraries`) on `main` too. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#6960 also stores pending images before a label, at the same two call sites, but only images over memory outside the write watch (`!GuestMemory::Watched`), for stores a CPU write could lose; images over watched memory stay pending there) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA01802 (terrain, player and props culled; no bring-up discussion yet), PPSA21607 (village washed out) - [x] GPUs tested: AMD Radeon RX 9070 XT (RADV GFX1201), Mesa 26.2.4, Arch Linux (kernel 7.2.9) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
alfalfa-star commented 2026-10-16 20:59:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-16T20:59:02Z.


Checked on plain main (a7f108030 + this change only, no other local changes), Kena PPSA01802 from the same save, default settings:

  • APS5_NO_LINEAR_READBACK_STORE=1 (main behaviour): once in the forest, Kena herself, the Rot around her and nearby trunks are missing in every dumped frame for the rest of the run. The occlusion results the CPU reads are stale, so these primitives are culled.
  • With this change: Kena, the Rot and the trunks are drawn at the same spot.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224580585 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6224580585). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-16T20:59:02Z. --- Checked on plain main (a7f108030 + this change only, no other local changes), Kena PPSA01802 from the same save, default settings: - `APS5_NO_LINEAR_READBACK_STORE=1` (main behaviour): once in the forest, Kena herself, the Rot around her and nearby trunks are missing in every dumped frame for the rest of the run. The occlusion results the CPU reads are stale, so these primitives are culled. - With this change: Kena, the Rot and the trunks are drawn at the same spot. AI-assisted: yes (Claude Code)
CnRJay commented 2026-10-16 22:07:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-16T22:07:28Z.

Review: COMMENTED


The diagnosis is clear (a pending 256 KiB linear image the CPU reads after the fence). The fix does its work in the wrong place and the cost is unmeasured.

  • StoreLinearWrites runs after every compute dispatch, on both the inline path and the committer path. For each dispatch it walks every GuestImages binding, decodes every 8-word descriptor with DecodeTextureResource, and uses try/catch as the filter for descriptors that don't decode. That is per-dispatch CPU work on the hottest path, in every title, to serve one shader. Do the decode once per compiled variant, not per dispatch.
  • It doesn't check that the dispatch writes the image. A linear texture that is only sampled by the dispatch goes through FlushPending too, and a linear image written by several dispatches in a frame is stored after each of them. The recompile result knows which images a program stores to; restrict to those, and store once, before the label or fence the CPU waits on, rather than at each dispatch. #6960 adds StoreBeforeGuestCompletion for the same moment, so these two should be one mechanism.
  • FlushPending over a 256 KiB surface after each dispatch records a store into the batch, so the number that matters is how many such dispatches a frame has and how large the images are. The description measures Kena at 24.3 vs 23.3 fps on one scene each, which is a 4% drop that the description reads as noise without showing the spread. Please post the summary lines of main and this PR from the same scene in PPSA01802 without any APS5_PROFILE_*, with a repeat of each, and the count of StoreLinearReadback calls per frame.
  • No test. The fix is "the CPU sees the results once the fence passes"; a test that writes a linear image in a dispatch, waits on a label, and reads guest memory (and fails with APS5_NO_LINEAR_READBACK_STORE=1) is what shows it.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5554223358 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#pullrequestreview-5554223358). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-16T22:07:28Z. **Review:** COMMENTED --- The diagnosis is clear (a pending 256 KiB linear image the CPU reads after the fence). The fix does its work in the wrong place and the cost is unmeasured. - `StoreLinearWrites` runs after every compute dispatch, on both the inline path and the committer path. For each dispatch it walks every `GuestImages` binding, decodes every 8-word descriptor with `DecodeTextureResource`, and uses `try/catch` as the filter for descriptors that don't decode. That is per-dispatch CPU work on the hottest path, in every title, to serve one shader. Do the decode once per compiled variant, not per dispatch. - It doesn't check that the dispatch writes the image. A linear texture that is only sampled by the dispatch goes through `FlushPending` too, and a linear image written by several dispatches in a frame is stored after each of them. The recompile result knows which images a program stores to; restrict to those, and store once, before the label or fence the CPU waits on, rather than at each dispatch. #6960 adds `StoreBeforeGuestCompletion` for the same moment, so these two should be one mechanism. - `FlushPending` over a 256 KiB surface after each dispatch records a store into the batch, so the number that matters is how many such dispatches a frame has and how large the images are. The description measures Kena at 24.3 vs 23.3 fps on one scene each, which is a 4% drop that the description reads as noise without showing the spread. Please post the summary lines of main and this PR from the same scene in PPSA01802 without any `APS5_PROFILE_*`, with a repeat of each, and the count of `StoreLinearReadback` calls per frame. - No test. The fix is "the CPU sees the results once the fence passes"; a test that writes a linear image in a dispatch, waits on a label, and reads guest memory (and fails with `APS5_NO_LINEAR_READBACK_STORE=1`) is what shows it.
alfalfa-star commented 2026-10-17 10:06:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-17T10:06:44Z.


Thanks. Reworked in 931f7297b (pushed on top, no rebase):

  • Where the store happens: the per-dispatch walk is gone. StoreLinearBeforeLabel runs at the start of WriteLabelOnGpu and for an end-of-pipe interrupt without a label. Those are the moments #6960's StoreBeforeGuestCompletion uses. It stores every pending linear storage image, recorded before the label.
  • Which images: only images the GPU wrote are pending, so an image a dispatch only samples is never stored. An image written by several dispatches in a frame is stored once, at the next label after the writes, not after each dispatch. No descriptor is decoded; the pending images carry their tile mode.
  • One mechanism with #6960: this is the same point and the same FlushPending loop over Pending(). #6960 stores pending results over compared (unwatched) memory; this stores pending linear images in either kind of memory. Whichever merges second can fold its condition into the other's loop. I didn't make this PR depend on #6960, so it can be reviewed on its own.
  • Test: agc_driver_linear_readback_label submits a PM4 dispatch that stores into a linear 32x8 8_8_8_8_UINT image (format 60, as in Kena), then a RELEASE_MEM label. It polls the label and reads guest memory. It passes. agc_driver_linear_readback_label_off runs it with APS5_NO_LINEAR_READBACK_STORE=1 and is marked WILL_FAIL: there texel (0, 0) still holds the bytes from before the dispatch.

Measurement on Kena (PPSA01802), forest title scene, no input. main f8b22edfb with and without this PR, warm cache, APS5_TRACE_SECONDS=100:30 and no other switch. Three rounds, alternating with other builds. Linux 7.2.9, RX 9070 XT, RADV Mesa 26.2.4, Release.

build presents in 30 s p50 frame ms
main 165 / 175 / 181 169.5 / 163.6 / 166.5
this PR 176 / 155 / 169 169.1 / 184.1 / 170.4

This is within the run-to-run spread. GPU busy per present is 3–5 ms higher (80–85 vs 86–88 ms). Store count from the [storage] line of a separate APS5_PROFILE_DRAW=1 run: linear before label 209 stores / 26.3 MiB per 10 s at 103 presents, so about 2 per present at about 127 KiB each.

Summary lines
{"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":718,"ms":30073.422},"presents":165,"frame_ms":{"p50":169.538,"p90":223.536,"p99":301.436,"max":424.069},"gpu_busy_ms_per_present":80.256,"trace":"aps5-trace-f8b22edfb7f5-137784.json.gz"}
{"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":666,"ms":30168.441},"presents":176,"frame_ms":{"p50":169.113,"p90":180.3,"p99":310.721,"max":317.803},"gpu_busy_ms_per_present":86.381,"trace":"aps5-trace-f7b5c94ab327-148893.json.gz"}
{"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":665,"ms":30090.232},"presents":175,"frame_ms":{"p50":163.648,"p90":214.229,"p99":361.756,"max":372.431},"gpu_busy_ms_per_present":83.005,"trace":"aps5-trace-f8b22edfb7f5-177231.json.gz"}
{"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":680,"ms":30026.675},"presents":155,"frame_ms":{"p50":184.106,"p90":245.867,"p99":397.582,"max":422.729},"gpu_busy_ms_per_present":88.04,"trace":"aps5-trace-f7b5c94ab327-166447.json.gz"}
{"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":656,"ms":30117.623},"presents":181,"frame_ms":{"p50":166.457,"p90":172.421,"p99":180.508,"max":188.155},"gpu_busy_ms_per_present":84.704,"trace":"aps5-trace-f8b22edfb7f5-194924.json.gz"}
{"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":712,"ms":30001.724},"presents":169,"frame_ms":{"p50":170.413,"p90":187.812,"p99":394.069,"max":420.286},"gpu_busy_ms_per_present":87.228,"trace":"aps5-trace-f7b5c94ab327-184433.json.gz"}

The traces are kept locally; I can attach any of them. The visual check (camera turn, terrain and character no longer dropping out) was done with the first, per-dispatch version. I haven't repeated it in gameplay with this version yet; the new test covers the ordering it relies on.

ctest -R '^agc_' on main + this PR: 621 of 622 pass. agc_driver_tessellation segfaults on main too.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6232632808 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6232632808). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-17T10:06:44Z. --- Thanks. Reworked in `931f7297b` (pushed on top, no rebase): - **Where the store happens:** the per-dispatch walk is gone. `StoreLinearBeforeLabel` runs at the start of `WriteLabelOnGpu` and for an end-of-pipe interrupt without a label. Those are the moments #6960's `StoreBeforeGuestCompletion` uses. It stores every pending linear storage image, recorded before the label. - **Which images:** only images the GPU wrote are pending, so an image a dispatch only samples is never stored. An image written by several dispatches in a frame is stored once, at the next label after the writes, not after each dispatch. No descriptor is decoded; the pending images carry their tile mode. - **One mechanism with #6960:** this is the same point and the same `FlushPending` loop over `Pending()`. #6960 stores pending results over compared (unwatched) memory; this stores pending linear images in either kind of memory. Whichever merges second can fold its condition into the other's loop. I didn't make this PR depend on #6960, so it can be reviewed on its own. - **Test:** `agc_driver_linear_readback_label` submits a PM4 dispatch that stores into a linear 32x8 8_8_8_8_UINT image (format 60, as in Kena), then a RELEASE_MEM label. It polls the label and reads guest memory. It passes. `agc_driver_linear_readback_label_off` runs it with `APS5_NO_LINEAR_READBACK_STORE=1` and is marked `WILL_FAIL`: there texel (0, 0) still holds the bytes from before the dispatch. Measurement on Kena (PPSA01802), forest title scene, no input. `main` f8b22edfb with and without this PR, warm cache, `APS5_TRACE_SECONDS=100:30` and no other switch. Three rounds, alternating with other builds. Linux 7.2.9, RX 9070 XT, RADV Mesa 26.2.4, Release. | build | presents in 30 s | p50 frame ms | |---|---|---| | `main` | 165 / 175 / 181 | 169.5 / 163.6 / 166.5 | | this PR | 176 / 155 / 169 | 169.1 / 184.1 / 170.4 | This is within the run-to-run spread. GPU busy per present is 3–5 ms higher (80–85 vs 86–88 ms). Store count from the `[storage]` line of a separate `APS5_PROFILE_DRAW=1` run: `linear before label` 209 stores / 26.3 MiB per 10 s at 103 presents, so about 2 per present at about 127 KiB each. <details><summary>Summary lines</summary> ```json {"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":718,"ms":30073.422},"presents":165,"frame_ms":{"p50":169.538,"p90":223.536,"p99":301.436,"max":424.069},"gpu_busy_ms_per_present":80.256,"trace":"aps5-trace-f8b22edfb7f5-137784.json.gz"} {"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":666,"ms":30168.441},"presents":176,"frame_ms":{"p50":169.113,"p90":180.3,"p99":310.721,"max":317.803},"gpu_busy_ms_per_present":86.381,"trace":"aps5-trace-f7b5c94ab327-148893.json.gz"} {"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":665,"ms":30090.232},"presents":175,"frame_ms":{"p50":163.648,"p90":214.229,"p99":361.756,"max":372.431},"gpu_busy_ms_per_present":83.005,"trace":"aps5-trace-f8b22edfb7f5-177231.json.gz"} {"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":680,"ms":30026.675},"presents":155,"frame_ms":{"p50":184.106,"p90":245.867,"p99":397.582,"max":422.729},"gpu_busy_ms_per_present":88.04,"trace":"aps5-trace-f7b5c94ab327-166447.json.gz"} {"commit":"f8b22edfb7f5","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":656,"ms":30117.623},"presents":181,"frame_ms":{"p50":166.457,"p90":172.421,"p99":180.508,"max":188.155},"gpu_busy_ms_per_present":84.704,"trace":"aps5-trace-f8b22edfb7f5-194924.json.gz"} {"commit":"f7b5c94ab327","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"100:30"},"gpu":"AMD Radeon RX 9070 XT (RADV GFX1201)","driver":"radv Mesa 26.2.4-arch1.1","os":"Linux 7.2.9-arch1-1","resolution":"3840x2160","window":{"spec":"seconds 100:30","first_present":712,"ms":30001.724},"presents":169,"frame_ms":{"p50":170.413,"p90":187.812,"p99":394.069,"max":420.286},"gpu_busy_ms_per_present":87.228,"trace":"aps5-trace-f7b5c94ab327-184433.json.gz"} ``` </details> The traces are kept locally; I can attach any of them. The visual check (camera turn, terrain and character no longer dropping out) was done with the first, per-dispatch version. I haven't repeated it in gameplay with this version yet; the new test covers the ordering it relies on. `ctest -R '^agc_'` on `main` + this PR: 621 of 622 pass. `agc_driver_tessellation` segfaults on `main` too. AI-assisted: yes (Claude Code)
TheSovietWaffle commented 2026-10-17 11:30:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-17T11:30:08Z.


Windows data point: head 931f7297b as-is, Release, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7. Device chosen with ANYPS5_GPU:

Device agc_driver_linear_readback_label agc_driver_linear_readback_label_off (WILL_FAIL)
NVIDIA RTX 3080, 617.42 40 of 40 5 of 5 (fails as expected without the store)
AMD Radeon Graphics (Raphael iGPU, 1002:164e), AMD Windows driver 3 of 3 3 of 3

So on both, the test detects the missing store and passes with it. An initial batch of 5 runs of the first test through my run script reported neither a pass nor any failure output; the 40 direct runs afterwards all passed, so I count that batch as a harness problem, not a test failure.

Not checked: other tests, titles.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233366065 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6233366065). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-17T11:30:08Z. --- Windows data point: head `931f7297b` as-is, Release, Windows 10 Pro 22H2 (19045), WinLibs GCC 15.2.0 r7. Device chosen with `ANYPS5_GPU`: | Device | `agc_driver_linear_readback_label` | `agc_driver_linear_readback_label_off` (WILL_FAIL) | |---|---|---| | NVIDIA RTX 3080, 617.42 | 40 of 40 | 5 of 5 (fails as expected without the store) | | AMD Radeon Graphics (Raphael iGPU, `1002:164e`), AMD Windows driver | 3 of 3 | 3 of 3 | So on both, the test detects the missing store and passes with it. An initial batch of 5 runs of the first test through my run script reported neither a pass nor any failure output; the 40 direct runs afterwards all passed, so I count that batch as a harness problem, not a test failure. Not checked: other tests, titles. AI-assisted: yes (Claude Code).
jotitadev commented 2026-10-17 13:35:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-17T13:35:46Z.

Review: COMMENTED


NVIDIA and lavapipe runs, since the description has only RADV.

Machine: Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged onto main 12a71f3f5 (clean). ANYPS5_NO_SHADER_CACHE=1, -j1 --timeout 30.

Run RTX 3070 lavapipe
agc_driver_linear_readback_label, _off, agc_driver_linear_target_resident, agc_driver_storage_cache_budget, _one_slice_alias, _write_back_overhang pass 3/3 pass
same, with the four non-test files from main agc_driver_linear_readback_label fails: texel (0, 0) read after the label is 0xefcaa580, the dispatch before the label stored a different value same failure
^agc (638 tests), PR vs main no new failures (636/638; the 2 failures, agc_driver_f16_fma_denormal_modes and agc_driver_fma_mix_f16_denormal_modes, fail on main on this GPU too) 638/638 on both

Not run: Windows, AMD, Kena or any title.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5557980747 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#pullrequestreview-5557980747). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-17T13:35:46Z. **Review:** COMMENTED --- NVIDIA and lavapipe runs, since the description has only RADV. **Machine:** Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same host. PR merged onto `main` `12a71f3f5` (clean). `ANYPS5_NO_SHADER_CACHE=1`, `-j1 --timeout 30`. | Run | RTX 3070 | lavapipe | |---|---|---| | `agc_driver_linear_readback_label`, `_off`, `agc_driver_linear_target_resident`, `agc_driver_storage_cache_budget`, `_one_slice_alias`, `_write_back_overhang` | pass 3/3 | pass | | same, with the four non-test files from `main` | `agc_driver_linear_readback_label` fails: `texel (0, 0) read after the label is 0xefcaa580, the dispatch before the label stored a different value` | same failure | | `^agc` (638 tests), PR vs `main` | no new failures (636/638; the 2 failures, `agc_driver_f16_fma_denormal_modes` and `agc_driver_fma_mix_f16_denormal_modes`, fail on `main` on this GPU too) | 638/638 on both | Not run: Windows, AMD, Kena or any title. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02) and lavapipe (Mesa 26.0.3), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Pacuka commented 2026-10-18 10:12:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-18T10:12:22Z.


@alfalfa-star a data point for this PR from The Smurfs - Dreams (PPSA21607, Unreal Engine), RX 6650 XT, RADV / Mesa 26.2.4.

The Smurfs' Village rendered washed out (pale, near-white). The cause is the same readback pattern as here, but on a tiled image. At level load the engine computes the sky light's average brightness on the GPU into a 1x1 RGBA16F (format 71), tile mode R64KBX storage image (guestBytes 0x10000) and reads it on the CPU after a label. The image stays pending, so the CPU reads 0. SkyIrradianceEnvironmentMap[7].x ends up 0 in guest memory, and the reflection pass's static-sky lightmap mixing divides by max(0, 1e-4), which makes specular ~100x too strong.

What I checked:

  • APS5_STORE_AT_LABEL=1 fixes the colors, but drops the village from ~6.5 to ~3.4 fps.
  • Storing only pending images ≤ 64 KiB at labels fixes it at full speed. Narrowed down: storing only that one 1x1 format-71 image is enough.
  • This PR as-is does not fix it, because StoreLinearBeforeLabel skips tiled images.
  • With this one-line change on top of the PR, the village renders correctly with no env switch, at 6.7–7 fps (unchanged), and agc_driver_linear_readback_label still passes:
-            if (texture->descriptor.tileMode == TextureTileMode::kLinear) ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes));
+            if (texture->descriptor.tileMode == TextureTileMode::kLinear || texture->guestBytes <= SmallStoreBytes) ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes));

Would you consider covering small tiled images too, or would you rather have it as a separate follow-up PR? Happy to test either.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6248621700 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6248621700). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-18T10:12:22Z. --- @alfalfa-star a data point for this PR from The Smurfs - Dreams (PPSA21607, Unreal Engine), RX 6650 XT, RADV / Mesa 26.2.4. The Smurfs' Village rendered washed out (pale, near-white). The cause is the same readback pattern as here, but on a **tiled** image. At level load the engine computes the sky light's average brightness on the GPU into a **1x1 RGBA16F (format 71), tile mode R64KBX** storage image (`guestBytes` 0x10000) and reads it on the CPU after a label. The image stays pending, so the CPU reads 0. `SkyIrradianceEnvironmentMap[7].x` ends up 0 in guest memory, and the reflection pass's static-sky lightmap mixing divides by `max(0, 1e-4)`, which makes specular ~100x too strong. What I checked: - `APS5_STORE_AT_LABEL=1` fixes the colors, but drops the village from ~6.5 to ~3.4 fps. - Storing only pending images ≤ 64 KiB at labels fixes it at full speed. Narrowed down: storing only that one 1x1 format-71 image is enough. - This PR as-is does not fix it, because `StoreLinearBeforeLabel` skips tiled images. - With this one-line change on top of the PR, the village renders correctly with no env switch, at 6.7–7 fps (unchanged), and `agc_driver_linear_readback_label` still passes: ```diff - if (texture->descriptor.tileMode == TextureTileMode::kLinear) ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes)); + if (texture->descriptor.tileMode == TextureTileMode::kLinear || texture->guestBytes <= SmallStoreBytes) ranges.emplace_back(texture->descriptor.baseAddress, static_cast<std::size_t>(texture->guestBytes)); ``` Would you consider covering small tiled images too, or would you rather have it as a separate follow-up PR? Happy to test either. AI-assisted (Claude Code).
alfalfa-star commented 2026-10-18 13:06:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-18T13:06:31Z.


@Pacuka Thanks for tracking this down. I took your change into this PR (56d7ebe41, credited in the commit message) and rebased on main 0d078f75d:

  • The label-time store now takes pending linear images plus any pending image of at most SmallStoreBytes. The function is renamed StoreReadbackBeforeLabel, and the opt-out APS5_NO_LABEL_READBACK_STORE, since it no longer covers only linear images.
  • agc_driver_linear_readback_label has a second case: a 16x16 32_UINT R64KBX image (64 KiB) stored by a dispatch, then a label. It failed before the change (0 of 8 texels) and passes now.

Tested on the same RX 9070 XT / RADV 26.2.4:

  • The Smurfs - Dreams, village reached from a new save. With only linear images stored, the village is washed out (near-white), as you saw. With this change it renders correctly. Presents per 10 s in the village: 100-105 before, 100-108 after.
  • Kena title scene, three alternating rounds: no fps change beyond the spread. The small images the flip used to store (about 450 per 10 s) are now stored at labels instead.
  • ctest: 1439 of 1440. agc_driver_tessellation segfaults in RADV on main too.

One thing I can't explain yet: one of my three Smurfs runs with the change crashed during loading, before the main menu. It was a SIGSEGV in game code at app.elf+0x290e36, mov (%rsi,%rcx,4),%ecx with rsi = [rbx+0x30] = 0, on a thread that had just started. The other two runs reached the village. I made only one run without the change, so I can't tell whether it's related. Have you seen a crash there, with or without the change?

#6960 adds a store at the same two call sites, but only for images over memory outside the write watch. Whichever lands second will need a small merge.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6250275230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6250275230). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-18T13:06:31Z. --- @Pacuka Thanks for tracking this down. I took your change into this PR (56d7ebe41, credited in the commit message) and rebased on `main` 0d078f75d: - The label-time store now takes pending linear images plus any pending image of at most `SmallStoreBytes`. The function is renamed `StoreReadbackBeforeLabel`, and the opt-out `APS5_NO_LABEL_READBACK_STORE`, since it no longer covers only linear images. - `agc_driver_linear_readback_label` has a second case: a 16x16 32_UINT R64KBX image (64 KiB) stored by a dispatch, then a label. It failed before the change (0 of 8 texels) and passes now. Tested on the same RX 9070 XT / RADV 26.2.4: - **The Smurfs - Dreams**, village reached from a new save. With only linear images stored, the village is washed out (near-white), as you saw. With this change it renders correctly. Presents per 10 s in the village: 100-105 before, 100-108 after. - **Kena** title scene, three alternating rounds: no fps change beyond the spread. The small images the flip used to store (about 450 per 10 s) are now stored at labels instead. - ctest: 1439 of 1440. `agc_driver_tessellation` segfaults in RADV on `main` too. One thing I can't explain yet: one of my three Smurfs runs with the change crashed during loading, before the main menu. It was a SIGSEGV in game code at `app.elf+0x290e36`, `mov (%rsi,%rcx,4),%ecx` with `rsi = [rbx+0x30] = 0`, on a thread that had just started. The other two runs reached the village. I made only one run without the change, so I can't tell whether it's related. Have you seen a crash there, with or without the change? #6960 adds a store at the same two call sites, but only for images over memory outside the write watch. Whichever lands second will need a small merge. AI-assisted: yes (Claude Code)
Pacuka commented 2026-10-18 16:47:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-18T16:47:25Z.


@alfalfa-star Thank you for taking it in and for the extra test case!

I haven't seen that crash. My Smurfs runs with the change (about a dozen today, on 9f25d0bf5 + this PR and later stacks with #4449 / #6208 / #6501 / #6617) all reached the menu and the village. A run on plain main e5f18ea99 from a new save this evening also loaded fine. Setup: RX 6650 XT / RADV Mesa 26.2.4, CachyOS.

I'll run your head 56d7ebe41 a few times from a new save and report back whether the loading crash shows up here. If it does, I'll attach a backtrace of that thread. Is there anything else on this PR you'd like tested on RDNA2?

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252490605 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6252490605). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-18T16:47:25Z. --- @alfalfa-star Thank you for taking it in and for the extra test case! I haven't seen that crash. My Smurfs runs with the change (about a dozen today, on 9f25d0bf5 + this PR and later stacks with #4449 / #6208 / #6501 / #6617) all reached the menu and the village. A run on plain `main` e5f18ea99 from a new save this evening also loaded fine. Setup: RX 6650 XT / RADV Mesa 26.2.4, CachyOS. I'll run your head 56d7ebe41 a few times from a new save and report back whether the loading crash shows up here. If it does, I'll attach a backtrace of that thread. Is there anything else on this PR you'd like tested on RDNA2? AI-assisted (Claude Code).
Pacuka commented 2026-10-18 16:52:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-18T16:52:57Z.


@alfalfa-star Ran your head 56d7ebe41 (no other PRs) three times, each from a new save (save data removed before every run), warm shader cache. RX 6650 XT / RADV Mesa 26.2.4, CachyOS, Release.

All three runs got through loading, the title screen, the New Save dialog and the Solo / Co-op menu into the Smurfs' Village, and exited cleanly when closed. No SIGSEGV or other crash, so I couldn't reproduce the loading crash here. The intro was skipped in at least one run.

The village is clearly brighter than on plain main, where it is almost fully black. On this GPU it still has black areas and a black menu background, but that is the separate 8-layer mesh-shader limit (#6528), which this build doesn't include.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252547057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6252547057). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-18T16:52:57Z. --- @alfalfa-star Ran your head 56d7ebe41 (no other PRs) three times, each from a new save (save data removed before every run), warm shader cache. RX 6650 XT / RADV Mesa 26.2.4, CachyOS, Release. All three runs got through loading, the title screen, the New Save dialog and the Solo / Co-op menu into the Smurfs' Village, and exited cleanly when closed. No SIGSEGV or other crash, so I couldn't reproduce the loading crash here. The intro was skipped in at least one run. The village is clearly brighter than on plain `main`, where it is almost fully black. On this GPU it still has black areas and a black menu background, but that is the separate 8-layer mesh-shader limit (#6528), which this build doesn't include. AI-assisted (Claude Code).
adriadam10 commented 2026-10-19 14:59:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T14:59:52Z.

Review: CHANGES_REQUESTED


The full Build fails agc_driver_clamped_global_fill on linux (run 39267846472); it passes on main.

  • ClampedGlobalFill.cpp:229 (KeyFillOrderTests) waits for a label and then expects the 64 KiB surface (SurfaceBytes = 65536) to still be pending under its keys. StoreReadbackBeforeLabel (Texture.cpp:3963) stores every pending image with guestBytes <= SmallStoreBytes before the label, so it is no longer pending: "the surface written after the key fill has no pending image under its keys".
  • Fix: keep that test's check meaningful with the store active, for example run it with APS5_NO_LABEL_READBACK_STORE=1, or make its surface larger than SmallStoreBytes. Please also check DccKeysFirstWrite.cpp, which has the same "pending image under its keys" assertion, and rerun every agc_driver_* test that polls a label and then calls FindPending.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5573513567 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#pullrequestreview-5573513567). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T14:59:52Z. **Review:** CHANGES_REQUESTED --- The full Build fails `agc_driver_clamped_global_fill` on linux (run 39267846472); it passes on main. - `ClampedGlobalFill.cpp:229` (`KeyFillOrderTests`) waits for a label and then expects the 64 KiB surface (`SurfaceBytes = 65536`) to still be pending under its keys. `StoreReadbackBeforeLabel` (`Texture.cpp:3963`) stores every pending image with `guestBytes <= SmallStoreBytes` before the label, so it is no longer pending: "the surface written after the key fill has no pending image under its keys". - Fix: keep that test's check meaningful with the store active, for example run it with `APS5_NO_LABEL_READBACK_STORE=1`, or make its surface larger than `SmallStoreBytes`. Please also check `DccKeysFirstWrite.cpp`, which has the same "pending image under its keys" assertion, and rerun every `agc_driver_*` test that polls a label and then calls `FindPending`.
Pacuka commented 2026-10-19 16:51:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Pacuka on 2026-10-19T16:51:31Z.


@alfalfa-star I reproduced the agc_driver_clamped_global_fill failure from the review locally and tried both of the suggested fixes. Setup: RX 6650 XT, RADV Mesa 26.2.4, CachyOS, Release. Build: this PR's head 56d7ebe41 merged onto main 32004dfa5, the way CI tests it.

  • Same failure as CI: the surface written after the key fill has no pending image under its keys. The test's surface is exactly 64 KiB (128x128 RGBA8), which is SmallStoreBytes, so the <= check stores it before the label.
  • The other label/FindPending tests pass on that build: DccKeysFirstWrite, AliasCopyLabel, ArrayLayerTarget, BcBlockCopy, DepthCompareCopy, DepthSurfaceFromStorage, ImageSrgbLoad, ImageSrgbSampleCopy (+ _forced), PackedMipTailTarget, PendingExactSurface, StagedClearSampledRead, StorageFileWrite, StorageOneSliceAlias, StoreOverUntracked, and LinearReadbackLabel (+ _off).

Both fixes pass 3 of 3 runs:

  1. Running the test with APS5_NO_LABEL_READBACK_STORE=1, which leaves the test unchanged.
  2. A larger surface, so the store skips it and the check stays meaningful with the store on:
-constexpr std::uint32_t Side = 128;
+constexpr std::uint32_t Side = 256;
-constexpr std::size_t SurfaceBytes = 65536;
+constexpr std::size_t SurfaceBytes = 262144;
-constexpr std::size_t BlockBytes = 2 * 65536;
+constexpr std::size_t BlockBytes = 2 * SurfaceBytes;

I'd keep the threshold at <=. The Smurfs image is a 1x1 R64KBX surface, which most likely also takes exactly 64 KiB, so a < check would probably bring the washed-out village back.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272462863 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6272462863). Originally posted by [Pacuka](https://github.com/Pacuka) on 2026-10-19T16:51:31Z. --- @alfalfa-star I reproduced the `agc_driver_clamped_global_fill` failure from the review locally and tried both of the suggested fixes. Setup: RX 6650 XT, RADV Mesa 26.2.4, CachyOS, Release. Build: this PR's head `56d7ebe41` merged onto `main` `32004dfa5`, the way CI tests it. - Same failure as CI: `the surface written after the key fill has no pending image under its keys`. The test's surface is exactly 64 KiB (128x128 RGBA8), which is `SmallStoreBytes`, so the `<=` check stores it before the label. - The other label/`FindPending` tests pass on that build: `DccKeysFirstWrite`, `AliasCopyLabel`, `ArrayLayerTarget`, `BcBlockCopy`, `DepthCompareCopy`, `DepthSurfaceFromStorage`, `ImageSrgbLoad`, `ImageSrgbSampleCopy` (+ `_forced`), `PackedMipTailTarget`, `PendingExactSurface`, `StagedClearSampledRead`, `StorageFileWrite`, `StorageOneSliceAlias`, `StoreOverUntracked`, and `LinearReadbackLabel` (+ `_off`). Both fixes pass 3 of 3 runs: 1. Running the test with `APS5_NO_LABEL_READBACK_STORE=1`, which leaves the test unchanged. 2. A larger surface, so the store skips it and the check stays meaningful with the store on: ```diff -constexpr std::uint32_t Side = 128; +constexpr std::uint32_t Side = 256; -constexpr std::size_t SurfaceBytes = 65536; +constexpr std::size_t SurfaceBytes = 262144; -constexpr std::size_t BlockBytes = 2 * 65536; +constexpr std::size_t BlockBytes = 2 * SurfaceBytes; ``` I'd keep the threshold at `<=`. The Smurfs image is a 1x1 R64KBX surface, which most likely also takes exactly 64 KiB, so a `<` check would probably bring the washed-out village back. AI-assisted (Claude Code).
alfalfa-star commented 2026-10-19 16:59:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-19T16:59:28Z.


@adriadam10 Fixed in 2c4d1388a, rebased on main dbac9fa15 (force-pushed).

agc_driver_clamped_global_fill now runs with APS5_NO_LABEL_READBACK_STORE=1, set in CMakeLists.txt the same way agc_driver_storage_file_write gets APS5_SUSPEND_DRAIN. KeyFillOrderTests checks that the 64 KiB surface stays pending under its keys after the label, and the store before the label retires exactly that surface. With the store off, the key-order check means what it did on main.

I reran every agc_driver_* test on the rebased head (591 tests, Linux 7.2.9, RX 9070 XT, RADV Mesa 26.2.4, Release):

  • clamped_global_fill failed with "the surface written after the key fill has no pending image under its keys" before the change and passes after it.
  • dcc_keys_first_write passes without a change. It has the same assertion, but its check doesn't wait on a label.
  • linear_readback_label, linear_readback_label_off (WILL_FAIL) and flip_stores_small_results pass.
  • Four others fail on this machine, and they fail the same way on plain main dbac9fa15 built in the same tree: image_table_vouched_lookups, bda_device, guest_memory_lifetime (amdgpu rejects a CS) and tessellation (SIGSEGV). None of them polls a label and then calls FindPending.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6272614377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6272614377). Originally posted by [alfalfa-star](https://github.com/alfalfa-star) on 2026-10-19T16:59:28Z. --- @adriadam10 Fixed in 2c4d1388a, rebased on `main` dbac9fa15 (force-pushed). `agc_driver_clamped_global_fill` now runs with `APS5_NO_LABEL_READBACK_STORE=1`, set in `CMakeLists.txt` the same way `agc_driver_storage_file_write` gets `APS5_SUSPEND_DRAIN`. `KeyFillOrderTests` checks that the 64 KiB surface stays pending under its keys after the label, and the store before the label retires exactly that surface. With the store off, the key-order check means what it did on `main`. I reran every `agc_driver_*` test on the rebased head (591 tests, Linux 7.2.9, RX 9070 XT, RADV Mesa 26.2.4, Release): - `clamped_global_fill` failed with "the surface written after the key fill has no pending image under its keys" before the change and passes after it. - `dcc_keys_first_write` passes without a change. It has the same assertion, but its check doesn't wait on a label. - `linear_readback_label`, `linear_readback_label_off` (WILL_FAIL) and `flip_stores_small_results` pass. - Four others fail on this machine, and they fail the same way on plain `main` dbac9fa15 built in the same tree: `image_table_vouched_lookups`, `bda_device`, `guest_memory_lifetime` (amdgpu rejects a CS) and `tessellation` (SIGSEGV). None of them polls a label and then calls `FindPending`. AI-assisted: yes (Claude Code)
ntamas94 commented 2026-10-19 21:43:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-10-19T21:43:28Z.


Confirmed on another title and platform: this also fixes the realtime lightmaps of Gang Beasts (CUSA04865, a PS4 title, Unity 2017.2 with Enlighten), which rendered every static surface of the main menu white.

Mechanism there: Unity's Enlighten reads back its per-system albedo (sRGB8) and emissive (fp16) meta-pass textures through a GPU block copy into a linear scratch image, an EOP label and a CPU read. With the stale scratch the radiosity solver produced NaN and huge values, and the RGB9E5 lightmaps the CPU then tiled saturated to white (20% of the texels 0xFFFFFFFF, shared exponents 25–31). With this branch the lightmaps are sane (shared exponent at most 14, no saturated texel) and the brick wall matches shadPS4. I had arrived at the same change (storing pending linear images in WriteLabelOnGpu) before finding this PR, so no separate PR.

Tested: Windows 11 (10.0.26200), NVIDIA GeForce RTX 2080, driver 617.14. The net diff of this PR at 2c4d1388a applied on a local branch (main + #6977 and local PS4 title changes; without docs/dev/ENVIRONMENT.md, which that branch lacks).

  • agc_driver_linear_readback_label passes and agc_driver_linear_readback_label_off fails as expected; agc_driver_flip_stores_small_results, agc_driver_store_idle_results, agc_driver_same_queue_label_wait and agc_driver_unimported_label_order pass.
  • Gang Beasts main menu, APS5_PROFILE_DRAW=1, APS5_TRACE_FLUSH=1, 150 s: 133 readback before label stores (0x200–0x9000 bytes each), all while loading, none at interrupts; no crash.
  • Same build with APS5_NO_LABEL_READBACK_STORE=1 against without, two 95 s runs each, warm shader cache, presents per 10 s: off 335–354, on 328–350 (GPU busy 22–24 ms per frame both ways). With the store off the lightmap dump is white again (52989 saturated texels); one of the off runs aborted after 20 s on an unrelated unimplemented sampler feature.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278055401 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6278055401). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-10-19T21:43:28Z. --- Confirmed on another title and platform: this also fixes the realtime lightmaps of Gang Beasts (CUSA04865, a PS4 title, Unity 2017.2 with Enlighten), which rendered every static surface of the main menu white. Mechanism there: Unity's Enlighten reads back its per-system albedo (sRGB8) and emissive (fp16) meta-pass textures through a GPU block copy into a linear scratch image, an EOP label and a CPU read. With the stale scratch the radiosity solver produced NaN and huge values, and the RGB9E5 lightmaps the CPU then tiled saturated to white (20% of the texels 0xFFFFFFFF, shared exponents 25–31). With this branch the lightmaps are sane (shared exponent at most 14, no saturated texel) and the brick wall matches shadPS4. I had arrived at the same change (storing pending linear images in `WriteLabelOnGpu`) before finding this PR, so no separate PR. Tested: Windows 11 (10.0.26200), NVIDIA GeForce RTX 2080, driver 617.14. The net diff of this PR at 2c4d1388a applied on a local branch (`main` + #6977 and local PS4 title changes; without `docs/dev/ENVIRONMENT.md`, which that branch lacks). - `agc_driver_linear_readback_label` passes and `agc_driver_linear_readback_label_off` fails as expected; `agc_driver_flip_stores_small_results`, `agc_driver_store_idle_results`, `agc_driver_same_queue_label_wait` and `agc_driver_unimported_label_order` pass. - Gang Beasts main menu, `APS5_PROFILE_DRAW=1`, `APS5_TRACE_FLUSH=1`, 150 s: 133 `readback before label` stores (0x200–0x9000 bytes each), all while loading, none at interrupts; no crash. - Same build with `APS5_NO_LABEL_READBACK_STORE=1` against without, two 95 s runs each, warm shader cache, presents per 10 s: off 335–354, on 328–350 (GPU busy 22–24 ms per frame both ways). With the store off the lightmap dump is white again (52989 saturated texels); one of the off runs aborted after 20 s on an unrelated unimplemented sampler feature.
JJenkx commented 2026-10-20 01:16:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-20T01:16:52Z.


Independent PPSA21607 (The Smurfs – Dreams 01.002.000) rendering check on RX 6650 XT / RADV Mesa 26.2.4, Arch Linux / GCC 16.2.1: applying this PR removes the severe white village washout in my local comparison.

Baseline 7f39ff42fbe39b386a7c99633757dca2f1099be6 is main 3aa35dc014a84b783c2fbe642f8e08341feb1a30 plus #6959. Candidate 97a9225d722842fc1e893ceabca3969617230e47 adds the exact #6948 diff at 2c4d1388a17bb84784bb877514b6dd1e19478526. This isolates this PR on that integration base; it is not a result against newest main.

Both started from the same checkpoint with separate initially empty shader/Mesa caches, identical input through the compared 345-second village capture, and no keyboard-focus holding. Both reached the village and closed normally (native/supervisor exit 0, PID gone, udmabuf restored to 64 MiB). Baseline subsequently accepted analog movement, moving the character and camera from spawn to the right fence. Movement on the candidate was not tested. The opening sequence also progresses beyond the previously reported still image. Audio and full-title progression remain unverified.

Baseline village With #6948
Before With PR6948

Focused tests on the same GPU: baseline 6/6; candidate 8/8 including agc_driver_linear_readback_label and its expected-failure disabled control. Mandatory Vulkan, core validation and shader cache disabled: no skips, missing-layer messages or VUIDs. The candidate follows this PR's test configuration, including APS5_NO_LABEL_READBACK_STORE=1 for clamped_global_fill.

Performance is still very slow: the candidate window reported about 0.9–1 FPS in the village. These are observations, not a controlled performance comparison or a speed-up claim. Removing the visible washout does not establish pixel-perfect reference correctness.

Evidence packet: exact commands, pins, native reports, focused-test summaries, selected captures and hashes. No game assets, binaries or saves included. Game discussion: #8158.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281034859 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6948#issuecomment-6281034859). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-20T01:16:52Z. --- Independent PPSA21607 (The Smurfs – Dreams 01.002.000) rendering check on RX 6650 XT / RADV Mesa 26.2.4, Arch Linux / GCC 16.2.1: applying this PR removes the severe white village washout in my local comparison. Baseline `7f39ff42fbe39b386a7c99633757dca2f1099be6` is main `3aa35dc014a84b783c2fbe642f8e08341feb1a30` plus #6959. Candidate `97a9225d722842fc1e893ceabca3969617230e47` adds the exact #6948 diff at `2c4d1388a17bb84784bb877514b6dd1e19478526`. This isolates this PR on that integration base; it is not a result against newest main. Both started from the same checkpoint with separate initially empty shader/Mesa caches, identical input through the compared 345-second village capture, and no keyboard-focus holding. Both reached the village and closed normally (native/supervisor exit 0, PID gone, udmabuf restored to 64 MiB). Baseline subsequently accepted analog movement, moving the character and camera from spawn to the right fence. Movement on the candidate was not tested. The opening sequence also progresses beyond the previously reported still image. Audio and full-title progression remain unverified. | Baseline village | With #6948 | | --- | --- | | ![Before](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/smurfs-village-before-label-readback.png) | ![With PR6948](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/smurfs-village-with-pr6948.png) | Focused tests on the same GPU: baseline 6/6; candidate 8/8 including `agc_driver_linear_readback_label` and its expected-failure disabled control. Mandatory Vulkan, core validation and shader cache disabled: no skips, missing-layer messages or VUIDs. The candidate follows this PR's test configuration, including `APS5_NO_LABEL_READBACK_STORE=1` for clamped_global_fill. Performance is still very slow: the candidate window reported about 0.9–1 FPS in the village. These are observations, not a controlled performance comparison or a speed-up claim. Removing the visible washout does not establish pixel-perfect reference correctness. [Evidence packet](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/smurfs-village-label-readback-validation.tar.gz): exact commands, pins, native reports, focused-test summaries, selected captures and hashes. No game assets, binaries or saves included. Game discussion: #8158.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6948
No description provided.