AGC: Sonic the Hedgehog (2006) Recompiled (PPSA99903) draws its stage geometry with stale data unless draws or packet stores are synchronous #11562

Open
opened 2026-10-26 19:52:35 +00:00 by josealissonbr · 0 comments
josealissonbr commented 2026-10-26 19:52:35 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by josealissonbr on 2026-10-26T19:52:35Z.


What happens

In a stage, the floor is invisible (the sky gradient shows through) and the buildings flicker; the frames that go wrong are drawn with a different camera. There is no error.

Title, test or build step

PPSA99903 01.000.000, homebrew: Sonic the Hedgehog (2006) Recompiled (PS5 port of MarathonRecomp), relinked with --windows --to-intel.

AnyPS5 commit

main ae17955d2 with local changes, none of them in the label or write-back paths:

  • DB_DEPTH_CLEAR decoded without the finite check, and a new depth surface with a non-finite clear value starts from its plane in guest memory (without this the title stops after the character select);
  • two frame-recorder fixes so the capture replays on Windows: pages the write tracker does not cover, and pages whose write walk was refused, are compared by hash at every call;
  • page-rounded commits in agc_frame_replay;
  • a privateRegions cache in libc WindowsMappings::Collect.

System

Windows 11 Pro 26200, RTX 5070 (NVIDIA 616.64), WinLibs GCC 15.2.0 x86_64-ucrt-posix-seh r7, Release build.

Steps to reproduce

Start the title, pick a character and stand anywhere in the first town stage. The floor stays invisible and the buildings flicker; the flicker gets worse with Shadow Resolution 8192 than with 512.

A 10-frame capture of that spot (APS5_FRAME_CAPTURE, trigger file) reproduces it offline:

agc_frame_replay <capture> --frames <dir>

Log

No error or warning around the bad frames.

What was checked

Two captures of the same spot, replayed with one switch at a time (3 presented frames each; both captures reproduce the bug without a switch and are correct with APS5_SYNC_DRAWS):

switch result
none floor missing in 2 of 3 frames, buildings missing in some
APS5_SYNC_DRAWS all 3 frames correct (floor, buildings, camera)
APS5_DRAW_DRAIN all 3 correct
APS5_CPU_STORES all 3 correct
APS5_NO_DISPATCH_CACHE partly better: camera and buildings right in 2 frames, floor still missing
APS5_LOCKED_DRAW_PREPARE, APS5_DRAIN_COMPLETION_LABELS only the first frame correct
APS5_PIPELINED_DRAWS=0, APS5_NO_DRAW_RECIPE, APS5_NO_WRITE_EVIDENCE, APS5_NO_GPU_SAMPLE_DUMPS not fixed
APS5_NO_RESIDENT_TARGETS, APS5_NO_PENDING_HTILE_FILLS, APS5_LABEL_GATE_ALL, APS5_NO_VALIDATE_SKIP replay stops on an invalid PM4 packet (below)
APS5_SYNC_DISPATCH replay stops on a SET_CONTEXT_REG whose register offset is a packet header (0xc0004600)
APS5_STORE_AT_LABEL=1, APS5_NO_DRAW_KEY, APS5_NO_HOST_IMPORT replay stops on guest memory is not readable

In the title itself, APS5_SYNC_DRAWS=1 and APS5_CPU_STORES=1 each remove every visual bug, at about 4 fps and 2-3 fps (normally 11-14 fps at 4K). In an earlier session, APS5_STORE_AT_LABEL=1 stopped the buildings flickering in the title but not the floor.

The shaders store almost nothing (APS5_TRACE_BUFFER_WRITTEN: 1 written element in the whole replay), so the stale data does not come from a shader writing a buffer. The packet stores the driver records on the GPU (VulkanDevice::WriteLabelOnGpu reaching NoteLabel) are 577 small stores in the replay, almost all 4 bytes at two fences:

address stores
0x201780000+0x4 225
0x201790000+0x4 222
0x4087a00004+0x4, 0x4087a00008+0x4 30 each
8 others 5 to 10 each

When a switch changes the replay's timing, a submission can contain words that are not packets. In this case a SET_CONTEXT_REG header says five values where one belongs, and the next packets' headers follow inside it:

[gpu]   at DWORD 32694  header 0xc0056900 SET_CONTEXT_REG          7 dwords: 000002df 0000002e c0004600 0000002c c0064900 0040c514
agc_frame_replay: AGC driver: unsupported PM4 packet type: header 0x23000000 at DWORD 32701 of 33217

The comment in WriteLabelOnGpu describes this case: a write-back that the CPU runs at the reap lands after a label that the GPU already made visible, so "a title that rebuilds its command buffer there sees a stale packet". The guard holds a label of 8 bytes or less behind the completions only while a copied writer is listed. APS5_DRAIN_COMPLETION_LABELS drains only under that same condition, and it does not fix the frames here. My guess is that another write-back that the CPU makes after the batch (storage image results, target or depth plane stores) can land after one of these fences is visible. I have not found which one.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6047061265 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/11562). Originally posted by [josealissonbr](https://github.com/josealissonbr) on 2026-10-26T19:52:35Z. --- ### What happens In a stage, the floor is invisible (the sky gradient shows through) and the buildings flicker; the frames that go wrong are drawn with a different camera. There is no error. ### Title, test or build step PPSA99903 01.000.000, homebrew: Sonic the Hedgehog (2006) Recompiled (PS5 port of MarathonRecomp), relinked with `--windows --to-intel`. ### AnyPS5 commit `main` ae17955d2 with local changes, none of them in the label or write-back paths: - `DB_DEPTH_CLEAR` decoded without the finite check, and a new depth surface with a non-finite clear value starts from its plane in guest memory (without this the title stops after the character select); - two frame-recorder fixes so the capture replays on Windows: pages the write tracker does not cover, and pages whose write walk was refused, are compared by hash at every call; - page-rounded commits in `agc_frame_replay`; - a `privateRegions` cache in libc `WindowsMappings::Collect`. ### System Windows 11 Pro 26200, RTX 5070 (NVIDIA 616.64), WinLibs GCC 15.2.0 `x86_64-ucrt-posix-seh` r7, Release build. ### Steps to reproduce Start the title, pick a character and stand anywhere in the first town stage. The floor stays invisible and the buildings flicker; the flicker gets worse with Shadow Resolution 8192 than with 512. A 10-frame capture of that spot (`APS5_FRAME_CAPTURE`, trigger file) reproduces it offline: ```text agc_frame_replay <capture> --frames <dir> ``` ### Log No error or warning around the bad frames. ### What was checked Two captures of the same spot, replayed with one switch at a time (3 presented frames each; both captures reproduce the bug without a switch and are correct with `APS5_SYNC_DRAWS`): | switch | result | |---|---| | none | floor missing in 2 of 3 frames, buildings missing in some | | `APS5_SYNC_DRAWS` | all 3 frames correct (floor, buildings, camera) | | `APS5_DRAW_DRAIN` | all 3 correct | | `APS5_CPU_STORES` | all 3 correct | | `APS5_NO_DISPATCH_CACHE` | partly better: camera and buildings right in 2 frames, floor still missing | | `APS5_LOCKED_DRAW_PREPARE`, `APS5_DRAIN_COMPLETION_LABELS` | only the first frame correct | | `APS5_PIPELINED_DRAWS=0`, `APS5_NO_DRAW_RECIPE`, `APS5_NO_WRITE_EVIDENCE`, `APS5_NO_GPU_SAMPLE_DUMPS` | not fixed | | `APS5_NO_RESIDENT_TARGETS`, `APS5_NO_PENDING_HTILE_FILLS`, `APS5_LABEL_GATE_ALL`, `APS5_NO_VALIDATE_SKIP` | replay stops on an invalid PM4 packet (below) | | `APS5_SYNC_DISPATCH` | replay stops on a `SET_CONTEXT_REG` whose register offset is a packet header (`0xc0004600`) | | `APS5_STORE_AT_LABEL=1`, `APS5_NO_DRAW_KEY`, `APS5_NO_HOST_IMPORT` | replay stops on `guest memory is not readable` | In the title itself, `APS5_SYNC_DRAWS=1` and `APS5_CPU_STORES=1` each remove every visual bug, at about 4 fps and 2-3 fps (normally 11-14 fps at 4K). In an earlier session, `APS5_STORE_AT_LABEL=1` stopped the buildings flickering in the title but not the floor. The shaders store almost nothing (`APS5_TRACE_BUFFER_WRITTEN`: 1 written element in the whole replay), so the stale data does not come from a shader writing a buffer. The packet stores the driver records on the GPU (`VulkanDevice::WriteLabelOnGpu` reaching `NoteLabel`) are 577 small stores in the replay, almost all 4 bytes at two fences: | address | stores | |---|---| | 0x201780000+0x4 | 225 | | 0x201790000+0x4 | 222 | | 0x4087a00004+0x4, 0x4087a00008+0x4 | 30 each | | 8 others | 5 to 10 each | When a switch changes the replay's timing, a submission can contain words that are not packets. In this case a `SET_CONTEXT_REG` header says five values where one belongs, and the next packets' headers follow inside it: ```text [gpu] at DWORD 32694 header 0xc0056900 SET_CONTEXT_REG 7 dwords: 000002df 0000002e c0004600 0000002c c0064900 0040c514 agc_frame_replay: AGC driver: unsupported PM4 packet type: header 0x23000000 at DWORD 32701 of 33217 ``` The comment in `WriteLabelOnGpu` describes this case: a write-back that the CPU runs at the reap lands after a label that the GPU already made visible, so "a title that rebuilds its command buffer there sees a stale packet". The guard holds a label of 8 bytes or less behind the completions only while a copied writer is listed. `APS5_DRAIN_COMPLETION_LABELS` drains only under that same condition, and it does not fix the frames here. My guess is that another write-back that the CPU makes after the batch (storage image results, target or depth plane stores) can land after one of these fences is visible. I have not found which one.
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#11562
No description provided.