feat(libSceAgc): ignore address argument on non-sample-dump events in sceAgcDcbEventWrite #5219

Merged
pushkarreddyy merged 1 commit from upstream-pr/5219 into main 2026-10-14 02:54:23 +00:00
pushkarreddyy commented 2026-10-13 14:59:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T14:59:58Z.


What

In libSceAgc's sceAgcDcbEventWrite, non-sample-dump event types (events other than 0x38 and 0x39) emit a 2-dword PM4 packet 0x46 (IT_EVENT_WRITE) without trailing address dwords. Previously, sceAgcDcbEventWrite asserted address == nullptr for all such event types, throwing std::runtime_error("sceAgcDcbEventWrite: this event does not use an address") when passed a non-null address.

Retail titles such as Void Terrarium (PPSA03061) call sceAgcDcbEventWrite passing a non-null address buffer (0x00000002d2a10000) alongside cache-flush event type 0x16. On hardware, this event does not consume an address in the PM4 command stream and eventIndex remains 0u, so requiring address == nullptr in guest user-space artificially halts execution.

This change:

  • Removes the artificial address == nullptr requirement in sceAgcDcbEventWrite for non-sample-dump events, allowing titles to pass unused address buffers without throwing.
  • Preserves the 4-dword packet emission and 8-byte alignment verification for sample dump events 0x38 and 0x39.
  • Preserves partial-flush event index 0x400u for events 7, 15, and 16, while emitting index 0u for cache-flush and other general events.
  • Adds comprehensive unit tests in core/libs/prx/libSceAgc/tests/Commands.cpp verifying packet emission, size queries, and null/non-null address tolerance across all event classes.
  • Documents technical debt and platform behavior in docs/dev/debt/libSceAgc.md.

Tested

  • Automated unit tests in core/libs/prx/libSceAgc/tests/Commands.cpp (testEventWrite):
    • Verified sample dump events 0x38 and 0x39 emit 4 dwords (16 bytes) with {0x100u | eventType, addrLo, addrHi}.
    • Verified rejection of misaligned addresses on event 0x38 and out-of-range event types (0x40).
    • Verified partial flush events 7, 15, 16 emit 2 dwords (8 bytes) with index 0x400u.
    • Verified cache-flush event 0x16 emits 2 dwords (8 bytes) with index 0u both with null and non-null addresses.
  • Runtime evidence: Void Terrarium (PPSA03061, #5055) halts on origin/main at:
    sceAgcDcbEventWrite: eventType=0x16, address=00000002d2a10000
    what(): sceAgcDcbEventWrite: this event does not use an address
    
    With this change applied, the title progresses past sceAgcDcbEventWrite and continues into shader execution and presentation.

Checklist

  • Matches hardware implementation
  • Added automated unit tests
  • Documented in technical debt files
  • Verified zero conventions errors via tools/check_conventions.py
  • Depends on: none
  • AI-assisted: yes
  • Unblocks: PPSA03061 #5055
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4845191326 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5219). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-13T14:59:58Z. --- ### What In `libSceAgc`'s `sceAgcDcbEventWrite`, non-sample-dump event types (events other than `0x38` and `0x39`) emit a 2-dword PM4 packet `0x46` (`IT_EVENT_WRITE`) without trailing address dwords. Previously, `sceAgcDcbEventWrite` asserted `address == nullptr` for all such event types, throwing `std::runtime_error("sceAgcDcbEventWrite: this event does not use an address")` when passed a non-null address. Retail titles such as *Void Terrarium* (`PPSA03061`) call `sceAgcDcbEventWrite` passing a non-null address buffer (`0x00000002d2a10000`) alongside cache-flush event type `0x16`. On hardware, this event does not consume an address in the PM4 command stream and `eventIndex` remains `0u`, so requiring `address == nullptr` in guest user-space artificially halts execution. This change: - Removes the artificial `address == nullptr` requirement in `sceAgcDcbEventWrite` for non-sample-dump events, allowing titles to pass unused address buffers without throwing. - Preserves the 4-dword packet emission and 8-byte alignment verification for sample dump events `0x38` and `0x39`. - Preserves partial-flush event index `0x400u` for events 7, 15, and 16, while emitting index `0u` for cache-flush and other general events. - Adds comprehensive unit tests in `core/libs/prx/libSceAgc/tests/Commands.cpp` verifying packet emission, size queries, and null/non-null address tolerance across all event classes. - Documents technical debt and platform behavior in `docs/dev/debt/libSceAgc.md`. ### Tested - Automated unit tests in `core/libs/prx/libSceAgc/tests/Commands.cpp` (`testEventWrite`): - Verified sample dump events `0x38` and `0x39` emit 4 dwords (`16` bytes) with `{0x100u | eventType, addrLo, addrHi}`. - Verified rejection of misaligned addresses on event `0x38` and out-of-range event types (`0x40`). - Verified partial flush events `7`, `15`, `16` emit 2 dwords (`8` bytes) with index `0x400u`. - Verified cache-flush event `0x16` emits 2 dwords (`8` bytes) with index `0u` both with null and non-null addresses. - Runtime evidence: *Void Terrarium* (`PPSA03061`, #5055) halts on `origin/main` at: ```text sceAgcDcbEventWrite: eventType=0x16, address=00000002d2a10000 what(): sceAgcDcbEventWrite: this event does not use an address ``` With this change applied, the title progresses past `sceAgcDcbEventWrite` and continues into shader execution and presentation. ### Checklist - [x] Matches hardware implementation - [x] Added automated unit tests - [x] Documented in technical debt files - [x] Verified zero conventions errors via `tools/check_conventions.py` - [x] Depends on: none - [x] AI-assisted: yes - [x] Unblocks: PPSA03061 #5055
p3n1cillin commented 2026-10-13 20:04:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T20:04:45Z.


Confirmed on Void Terrarium (PPSA03061): without this PR the game stops on sceAgcDcbEventWrite: this event does not use an address. With it (plus #5153, #5425 and #5140) the game runs for 150 s with no library stop. Details in https://github.com/boykopovar/AnyPS5/issues/5055#issuecomment-6154121860

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6154124380 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5219#issuecomment-6154124380). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T20:04:45Z. --- Confirmed on Void Terrarium (PPSA03061): without this PR the game stops on `sceAgcDcbEventWrite: this event does not use an address`. With it (plus #5153, #5425 and #5140) the game runs for 150 s with no library stop. Details in https://github.com/boykopovar/AnyPS5/issues/5055#issuecomment-6154121860
xXPBSXx commented 2026-10-13 23:04:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T23:04:05Z.


agc_commands fails on Windows with this PR's new testEventWrite: incorrect event 0x38 return pointer. The check is samplePacket == storage.words.data() + 4 (tests/Commands.cpp, first check of testEventWrite), but Agc::Command::Emit returns the start of the packet (return packet; after Allocate, Packet.cpp), which is storage.words.data() for a fresh buffer. The same test passes on main without this PR (3 of 3 runs); with this PR on its own it fails in 3 of 3 runs, and also in 3 of 3 runs in a build together with thirteen other PRs.

I have not tried changing the expectation to storage.words.data(). Windows 10 (19045), MinGW-w64 GCC 15.2, Release, NVIDIA GeForce RTX 4080 SUPER (driver 610.74). Not tested: Linux, AMD.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157057698 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5219#issuecomment-6157057698). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T23:04:05Z. --- `agc_commands` fails on Windows with this PR's new `testEventWrite`: `incorrect event 0x38 return pointer`. The check is `samplePacket == storage.words.data() + 4` (`tests/Commands.cpp`, first check of `testEventWrite`), but `Agc::Command::Emit` returns the start of the packet (`return packet;` after `Allocate`, `Packet.cpp`), which is `storage.words.data()` for a fresh buffer. The same test passes on `main` without this PR (3 of 3 runs); with this PR on its own it fails in 3 of 3 runs, and also in 3 of 3 runs in a build together with thirteen other PRs. I have not tried changing the expectation to `storage.words.data()`. Windows 10 (19045), MinGW-w64 GCC 15.2, Release, NVIDIA GeForce RTX 4080 SUPER (driver 610.74). Not tested: Linux, AMD. AI-assisted (Claude Code).
pushkarreddyy commented 2026-10-14 02:07:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-14T02:07:23Z.


@xXPBSXx Good catch on the return pointer assertion! Updated the test check to samplePacket == storage.words.data() (matching Agc::Command::Emit returning the packet start) and rebased cleanly on latest origin/main.

Calling on @MarcZX100 for review / merge clearance alongside #5140.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159290273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5219#issuecomment-6159290273). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-14T02:07:23Z. --- @xXPBSXx Good catch on the return pointer assertion! Updated the test check to samplePacket == storage.words.data() (matching Agc::Command::Emit returning the packet start) and rebased cleanly on latest origin/main. Calling on @MarcZX100 for review / merge clearance alongside #5140.
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!5219
No description provided.