fix(agc): accept WRITE_DATA destination 3 for memory fences #3539

Merged
MarcZX10 merged 1 commit from upstream-pr/3539 into main 2026-10-11 21:36:58 +00:00
MarcZX10 commented 2026-10-11 12:42:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:42:29Z.


What

Allow WRITE_DATA with DST_SEL 3 to write to guest memory. Packet execution and label resolution already handle accepted WRITE_DATA destinations as memory; validation was the part rejecting destination 3 as GDS. The PM4 tests now cover a normal memory write, resolving a one-dword write as a label, and continued rejection of register destination 0. TechnicalDebt.md records the reported evidence and that the console's internal routing remains unknown.

This carries the fix commit from the issue reporter, Mouad, with the original authorship preserved.

Closes #3534.

Tested

Linux x86-64, GCC 12.2, Release:

  • Full CMake build passed.
  • agc_driver_pm4 passed three consecutive CTest runs.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD passed.

The issue reporter separately reports a Fedora/Intel Arc title run reaching Killzone: Liberation's controls screen and running for 120 seconds. I did not independently run that title or test on Windows/console hardware.

Checklist

  • Based on current main; no other open PR implements the same behavior
  • 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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819125440 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3539). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T12:42:29Z. --- ### What Allow `WRITE_DATA` with `DST_SEL 3` to write to guest memory. Packet execution and label resolution already handle accepted `WRITE_DATA` destinations as memory; validation was the part rejecting destination 3 as GDS. The PM4 tests now cover a normal memory write, resolving a one-dword write as a label, and continued rejection of register destination 0. `TechnicalDebt.md` records the reported evidence and that the console's internal routing remains unknown. This carries the fix commit from the issue reporter, Mouad, with the original authorship preserved. Closes #3534. ### Tested Linux x86-64, GCC 12.2, Release: - Full CMake build passed. - `agc_driver_pm4` passed three consecutive CTest runs. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` passed. The issue reporter separately reports a Fedora/Intel Arc title run reaching Killzone: Liberation's controls screen and running for 120 seconds. I did not independently run that title or test on Windows/console hardware. ### Checklist - [x] Based on current `main`; no other open PR implements the same behavior - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
MarcZX10 commented 2026-10-11 12:52:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:52:57Z.


The current CI run has finished: conventions, eligibility/report, Ubuntu and Intel macOS register-context/write-watch, and all three relinker jobs pass. Full Linux/Windows builds are skipped by the contributor workflow. The local Release build and agc_driver_pm4 CTest passed 3/3 on this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109222914 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3539#issuecomment-6109222914). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T12:52:57Z. --- The current CI run has finished: conventions, eligibility/report, Ubuntu and Intel macOS register-context/write-watch, and all three relinker jobs pass. Full Linux/Windows builds are skipped by the contributor workflow. The local Release build and `agc_driver_pm4` CTest passed 3/3 on this head.
JAB-dev commented 2026-10-11 13:20:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-11T13:20:36Z.


Hit the same packet from another title, in case it helps as evidence: Hot Shots Golf 2 (PPSA06699, PS1HD) calls sceAgcDcbWriteData with destination 6, which the builder emits as DST_SEL 3 from the ME. It writes 0 to a label, a RELEASE_MEM then sets that label to 1, and a WAIT_REG_MEM_64 waits on it, so the 64-bit address is guest memory there too, not a GDS offset.

KytyPS5 does the same: src/graphics/guest_gpu/graphicsRun.cpp L328-351 computes dst_sel = bit30 | ((ctrl >> 7) & 0x1e) and writes memory for 6 (7 is not accepted). It is the only reference that accepts it; shadPS4 (liverpool.cpp:731) and sharpemu (GpuCommandInterpreter.Memory.cs) reject DST_SEL 3.

I had a branch with the same change, so I'm dropping it in favour of this one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109457910 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3539#issuecomment-6109457910). Originally posted by [JAB-dev](https://github.com/JAB-dev) on 2026-10-11T13:20:36Z. --- Hit the same packet from another title, in case it helps as evidence: Hot Shots Golf 2 (PPSA06699, PS1HD) calls `sceAgcDcbWriteData` with destination 6, which the builder emits as DST_SEL 3 from the ME. It writes 0 to a label, a RELEASE_MEM then sets that label to 1, and a WAIT_REG_MEM_64 waits on it, so the 64-bit address is guest memory there too, not a GDS offset. KytyPS5 does the same: `src/graphics/guest_gpu/graphicsRun.cpp` L328-351 computes `dst_sel = bit30 | ((ctrl >> 7) & 0x1e)` and writes memory for 6 (7 is not accepted). It is the only reference that accepts it; shadPS4 (`liverpool.cpp:731`) and sharpemu (`GpuCommandInterpreter.Memory.cs`) reject DST_SEL 3. I had a branch with the same change, so I'm dropping it in favour of this one.
adriadam10 commented 2026-10-11 21:36:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:36:54Z.


Checked: build + ctest of libSceAgcDriver green (agc_driver_pm4 included), and the new PM4 checks fail without the Pm4.cpp change. DST_SEL 3 already executed and resolved as a label as memory; only validation rejected it, and the register destination is still rejected. The Killzone: Liberation and Hot Shots Golf 2 evidence, plus the independent Linux run, covers what we can't run here. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114047850 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3539#issuecomment-6114047850). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:36:54Z. --- Checked: build + ctest of libSceAgcDriver green (`agc_driver_pm4` included), and the new PM4 checks fail without the `Pm4.cpp` change. DST_SEL 3 already executed and resolved as a label as memory; only validation rejected it, and the register destination is still rejected. The Killzone: Liberation and Hot Shots Golf 2 evidence, plus the independent Linux run, covers what we can't run here. Merging.
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!3539
No description provided.