AGC frame capture: depth planes kept only on the GPU are not captured, so agc_frame_replay draws Minecraft Dungeons II (PPSA16064) terrain black #15113

Open
opened 2026-11-02 17:05:07 +00:00 by splice11 · 0 comments
splice11 commented 2026-11-02 17:05:07 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by splice11 on 2026-11-02T17:05:07Z.


What happens

A capture of Minecraft Dungeons II replays with its terrain and the campfire light solid black. The title samples a 2048x2048 D16 depth plane (a cached shadow map) that it drew before the capture window. AnyPS5 keeps that format only on the GPU (only D32 with 64 KiB Z swizzle is mirrored to guest memory), so the capture never holds its contents, and the replay samples empty depth.

Reading such planes back at capture start and restoring them in the replay fixes it. Squid Coast and the camp title screen then replay within 0.05 to 0.7 of 255 mean difference of the title's own frames. The changes are on a lab branch, not yet split into PRs: https://github.com/splice11/AnyPS5/tree/lab/frame-capture-mcd2 (b928638b98).

Three smaller things came up on the way. Two may already be covered by open PRs.

Title, test or build step

Minecraft Dungeons II, PPSA16064 01.100.100, the camp title screen ("Press any button") and Squid Coast.

AnyPS5 commit

main e450145140 with #11346, #11575, #11611 and #11630 merged locally, a local commit for layered mesh draws and MCD2 debug hacks (9ecc0b6269), and the lab branch above on top.

System

Nobara Linux 44 (kernel 7.3.0), GCC 16.2.1, AMD Radeon RX 6700 (RADV, Mesa 26.2.6).

Steps to reproduce

APS5_FRAME_CAPTURE=<dir>/capture APS5_FRAME_CAPTURE_TRIGGER=<dir>/trigger APS5_FRAME_CAPTURE_FRAMES=3 ./app.elf
# at the title screen:
echo 3 > <dir>/trigger
agc_frame_replay <dir>/capture --frames <out>

On main the capture itself stops after 2 calls (item 2 below); the lab branch's APS5_FRAME_CAPTURE_DELTA_WAIT_MS=200 gets it through.

Log

With a lab diagnostic that logs each depth-like texture the title samples, and whether a live depth surface backs it:

  • in the game, 0x3079910000 (2048x2048 D16) is sampled from a live surface;
  • in the replay, the same address has no surface and is read from guest memory, which holds nothing for it.

With the fix, capture start reads back every single-sample depth plane that is not mirrorable:

[depth-saved] 0x30798b0000 2048x2048 format 124 stencil 0x0 htile 0x0 slices 0..0
[depth-saved] 0x3079100000 2048x2048 format 124 stencil 0x0 htile 0x0 slices 0..0

Camp: 3 planes, 74 MiB. Squid Coast: 7 planes, 522 MiB.

What was checked

Game frame on the left, replay on the right.

Before (mean difference 30.0 of 255):
camp before

After (0.05):
camp after

Mean absolute difference per channel (0-255), first display buffer, three replays of one capture each:

scene before after: run 1 run 2 run 3
camp 30.0 0.45 0.05 3.42
Squid Coast 28.6 0.44 0.47 0.70

Camp run 3 has a few garbage texels (green and orange blocks) on some foliage; not explained yet.

How the lab branch does it. Graphics::ReadBackDepthSurfaces() copies each plane to a host-visible buffer at capture start, and the recorder writes them to capture/depth.bin (saved_depth_planes in capture.json). In the replay, a plane is restored when the frames first create its surface (drawn first) or first sample it (sampled first). Limitation: a plane with several slices (a 1024x1024 cube shadow, slices 0..5) is saved as slice 0 only.

Other findings on the same captures:

  1. Shader data registered before the capture can live outside every registered allocation. The title registers some shaders from host heap pages. Without them, the replay stops with "invalid shader header". The lab branch saves those pages as host ranges (prologue_host_ranges: 9 on camp, 10 on Squid Coast). It copies them with process_vm_readv before the snapshot, because the title frees heap pages meanwhile and a plain copy crashed.
  2. A memory delta never sees the driver idle. Once per frame, always just before a Submit with one submission in flight, the delta's idle wait times out (3000 ms made no difference), and the capture stops after 2 calls. The lab branch records it anyway after a timeout and counts it (unsynced_deltas, one per frame). Dropping these deltas breaks the replay, so they hold needed data. This looks like what #12567 fixes; I haven't tried it.
  3. The replay defaults release waits too early here. With synthesized values and release after 3 ms, the same capture replayed anywhere from black to correct. With --no-synthesize --release-after-ms 200, it is stable. #12568 (GPU-stored words out of deltas) may be the real fix.

Also, agc_frame_replay now registers restored direct-memory ranges with the guest write watch, as the title does when it maps them. That didn't change the image, but it matches the game.

Happy to split the depth-plane part into a PR on main with a test, if this approach looks right.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6167190543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/15113). Originally posted by [splice11](https://github.com/splice11) on 2026-11-02T17:05:07Z. --- ### What happens A capture of Minecraft Dungeons II replays with its terrain and the campfire light solid black. The title samples a 2048x2048 D16 depth plane (a cached shadow map) that it drew before the capture window. AnyPS5 keeps that format only on the GPU (only D32 with 64 KiB Z swizzle is mirrored to guest memory), so the capture never holds its contents, and the replay samples empty depth. Reading such planes back at capture start and restoring them in the replay fixes it. Squid Coast and the camp title screen then replay within 0.05 to 0.7 of 255 mean difference of the title's own frames. The changes are on a lab branch, not yet split into PRs: https://github.com/splice11/AnyPS5/tree/lab/frame-capture-mcd2 (`b928638b98`). Three smaller things came up on the way. Two may already be covered by open PRs. ### Title, test or build step Minecraft Dungeons II, PPSA16064 01.100.100, the camp title screen ("Press any button") and Squid Coast. ### AnyPS5 commit `main` `e450145140` with #11346, #11575, #11611 and #11630 merged locally, a local commit for layered mesh draws and MCD2 debug hacks (`9ecc0b6269`), and the lab branch above on top. ### System Nobara Linux 44 (kernel 7.3.0), GCC 16.2.1, AMD Radeon RX 6700 (RADV, Mesa 26.2.6). ### Steps to reproduce ```sh APS5_FRAME_CAPTURE=<dir>/capture APS5_FRAME_CAPTURE_TRIGGER=<dir>/trigger APS5_FRAME_CAPTURE_FRAMES=3 ./app.elf # at the title screen: echo 3 > <dir>/trigger agc_frame_replay <dir>/capture --frames <out> ``` On `main` the capture itself stops after 2 calls (item 2 below); the lab branch's `APS5_FRAME_CAPTURE_DELTA_WAIT_MS=200` gets it through. ### Log With a lab diagnostic that logs each depth-like texture the title samples, and whether a live depth surface backs it: - in the game, `0x3079910000` (2048x2048 D16) is sampled from a live surface; - in the replay, the same address has no surface and is read from guest memory, which holds nothing for it. With the fix, capture start reads back every single-sample depth plane that is not mirrorable: ```text [depth-saved] 0x30798b0000 2048x2048 format 124 stencil 0x0 htile 0x0 slices 0..0 [depth-saved] 0x3079100000 2048x2048 format 124 stencil 0x0 htile 0x0 slices 0..0 ``` Camp: 3 planes, 74 MiB. Squid Coast: 7 planes, 522 MiB. ### What was checked Game frame on the left, replay on the right. Before (mean difference 30.0 of 255): ![camp before](https://raw.githubusercontent.com/splice11/AnyPS5/359049aa2206f6995cf1485bd3565483736d64a0/camp-before.png) After (0.05): ![camp after](https://raw.githubusercontent.com/splice11/AnyPS5/359049aa2206f6995cf1485bd3565483736d64a0/camp-after.png) Mean absolute difference per channel (0-255), first display buffer, three replays of one capture each: | scene | before | after: run 1 | run 2 | run 3 | |---|---|---|---|---| | camp | 30.0 | 0.45 | 0.05 | 3.42 | | Squid Coast | 28.6 | 0.44 | 0.47 | 0.70 | Camp run 3 has a few garbage texels (green and orange blocks) on some foliage; not explained yet. **How the lab branch does it.** `Graphics::ReadBackDepthSurfaces()` copies each plane to a host-visible buffer at capture start, and the recorder writes them to `capture/depth.bin` (`saved_depth_planes` in `capture.json`). In the replay, a plane is restored when the frames first create its surface (drawn first) or first sample it (sampled first). Limitation: a plane with several slices (a 1024x1024 cube shadow, slices 0..5) is saved as slice 0 only. **Other findings on the same captures:** 1. **Shader data registered before the capture can live outside every registered allocation.** The title registers some shaders from host heap pages. Without them, the replay stops with "invalid shader header". The lab branch saves those pages as host ranges (`prologue_host_ranges`: 9 on camp, 10 on Squid Coast). It copies them with `process_vm_readv` before the snapshot, because the title frees heap pages meanwhile and a plain copy crashed. 2. **A memory delta never sees the driver idle.** Once per frame, always just before a `Submit` with one submission in flight, the delta's idle wait times out (3000 ms made no difference), and the capture stops after 2 calls. The lab branch records it anyway after a timeout and counts it (`unsynced_deltas`, one per frame). Dropping these deltas breaks the replay, so they hold needed data. This looks like what #12567 fixes; I haven't tried it. 3. **The replay defaults release waits too early here.** With synthesized values and release after 3 ms, the same capture replayed anywhere from black to correct. With `--no-synthesize --release-after-ms 200`, it is stable. #12568 (GPU-stored words out of deltas) may be the real fix. Also, `agc_frame_replay` now registers restored direct-memory ranges with the guest write watch, as the title does when it maps them. That didn't change the image, but it matches the game. Happy to split the depth-plane part into a PR on `main` with a test, if this approach looks right. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#15113
No description provided.