feat(agc): copy the GPU clock counter with COPY_DATA #1122

Merged
TideOPL merged 2 commits from upstream-pr/1122 into main 2026-10-08 08:12:18 +00:00
TideOPL commented 2026-10-07 13:13:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-07T13:13:54Z.


What

COPY_DATA rejected source select 9 (GPU clock count) and any cache-policy bits. PPSA16064 (Minecraft Dungeons II, Unreal Engine) calibrates its GPU timer at start-up with a submission of five COPY_DATA packets, control 0x06016209 (GPU clock source, memory destination, 64-bit count, source and destination cache policy 3), so the submission was rejected.

  • The clock source writes the same counter as a RELEASE_MEM timestamp (the host steady clock in 10 ns ticks), read when the packet runs. This works through the direct execute path and through ResolveStore for stores recorded on the GPU. A 32-bit count writes its low half.
  • The source and destination cache policy fields are accepted and ignored, as for WRITE_DATA and DMA_DATA.
  • The reference clock (source select 10) and the other unimplemented sources still throw.

Tested

  • Windows 11, NVIDIA GeForce RTX 5070, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7). Full ctest: 393/393.
  • agc_driver_pm4: runs the title's packet twice and checks a nonzero, non-decreasing counter, an 8-byte resolved store, and that source select 10 is still rejected. Fails on main.
  • PPSA16064: the calibration submission runs.

Asking for ideas

Sharing the RELEASE_MEM clock keeps GPU timestamps self-consistent. If someone knows whether titles compare this counter against the CPU's sceKernelGetProcessTimeCounter (and would need a common base), I'd like to hear it. TechnicalDebt records the choice.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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:4773171035 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1122). Originally posted by [TideOPL](https://github.com/TideOPL) on 2026-10-07T13:13:54Z. --- ### What `COPY_DATA` rejected source select 9 (GPU clock count) and any cache-policy bits. PPSA16064 (Minecraft Dungeons II, Unreal Engine) calibrates its GPU timer at start-up with a submission of five `COPY_DATA` packets, control `0x06016209` (GPU clock source, memory destination, 64-bit count, source and destination cache policy 3), so the submission was rejected. - The clock source writes the same counter as a `RELEASE_MEM` timestamp (the host steady clock in 10 ns ticks), read when the packet runs. This works through the direct execute path and through `ResolveStore` for stores recorded on the GPU. A 32-bit count writes its low half. - The source and destination cache policy fields are accepted and ignored, as for `WRITE_DATA` and `DMA_DATA`. - The reference clock (source select 10) and the other unimplemented sources still throw. ### Tested - Windows 11, NVIDIA GeForce RTX 5070, MinGW-w64 GCC 15.2.0 (WinLibs UCRT r7). Full `ctest`: 393/393. - `agc_driver_pm4`: runs the title's packet twice and checks a nonzero, non-decreasing counter, an 8-byte resolved store, and that source select 10 is still rejected. Fails on `main`. - PPSA16064: the calibration submission runs. ### Asking for ideas Sharing the `RELEASE_MEM` clock keeps GPU timestamps self-consistent. If someone knows whether titles compare this counter against the CPU's `sceKernelGetProcessTimeCounter` (and would need a common base), I'd like to hear it. TechnicalDebt records the choice. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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
github-actions[bot] commented 2026-10-07 13:54:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T13:54:52Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#1058 docs/dev/TechnicalDebt.md L256
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6039473195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1122#issuecomment-6039473195). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-07T13:54:52Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #1058 | `docs/dev/TechnicalDebt.md` [L256](https://github.com/boykopovar/AnyPS5/blob/df16c4c256be3c44e03eb9149a6ce5f8e8a038b2/docs/dev/TechnicalDebt.md#L256) | | |
adriadam10 commented 2026-10-08 07:59:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T07:59:02Z.


Checked: build + full ctest on current main (424/424), agc_driver_pm4 fails without the change, the GPU clock formula is the same as the RELEASE_MEM timestamp (Pm4.cpp lines 540 and 819), and the cache policy mask matches the SRC/DST cache policy fields. The source select 10 (system clock) packet is still rejected.

Added on top of your commit:

  • Rebased on main (only the TechnicalDebt.md adjacency with the 8_SRGB lines conflicted).
  • A 32-bit COPY_DATA assertion in agc_driver_pm4: the low half is written and the upper half is left untouched, which the PR text claimed but no test pinned.

Not verified here: that PPSA16064 only needs this counter (can't run the title), and whether titles compare it with sceKernelGetProcessTimeCounter. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055454458 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1122#issuecomment-6055454458). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T07:59:02Z. --- Checked: build + full ctest on current `main` (424/424), `agc_driver_pm4` fails without the change, the GPU clock formula is the same as the `RELEASE_MEM` timestamp (`Pm4.cpp` lines 540 and 819), and the cache policy mask matches the SRC/DST cache policy fields. The source select 10 (system clock) packet is still rejected. Added on top of your commit: - Rebased on `main` (only the `TechnicalDebt.md` adjacency with the 8_SRGB lines conflicted). - A 32-bit `COPY_DATA` assertion in `agc_driver_pm4`: the low half is written and the upper half is left untouched, which the PR text claimed but no test pinned. Not verified here: that PPSA16064 only needs this counter (can't run the title), and whether titles compare it with `sceKernelGetProcessTimeCounter`. Merging once CI is green.
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!1122
No description provided.