feat(agc): implement sceAgcDriverGetTFRing #1978

Merged
LuisBiceps merged 2 commits from upstream-pr/1978 into main 2026-10-09 21:53:53 +00:00
LuisBiceps commented 2026-10-09 03:37:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LuisBiceps on 2026-10-09T03:37:50Z.


What

Implements sceAgcDriverGetTFRing (NID e-YMQ+2tj9M) in libSceAgcDriver. sceAgcDriverSetTFRing now records the ring it receives, so Get reports it.

  • int sceAgcDriverGetTFRing(uintptr_t* base, uint32_t* size) writes the ring's base address and its size in bytes, and returns 0.
  • Before a title sets a ring, Get reports the console's default, 0xFF0000000 and 128 KiB. Source: PS5_Vulkan's hardware findings: "sceAgcDriverGetTFRing reports AGC's default, 0xF_F000_0000 and 128 KiB; sceAgcDriverSetTFRing(address, size) moves it".
  • The signature and the set-then-read behaviour follow ps5-opengl's AGC runtime, a console homebrew. It sets the ring, reads it back, and requires the same address and size (L3890-L3896).
  • A null output pointer throws, since its result on the console is unknown. sceAgcDriverSetTFRing still throws for a null base or a zero size.
  • Nothing is written to the recorded ring: tessellated draws run as Vulkan tessellation stages, which keep their factors on the host, so a title that reads tessellation factors from the ring finds none. TechnicalDebt records this, and also sceAgcDriverSetTFRing(0, 0), which ps5-opengl's runtime calls in its cleanup and whose effect on the console is unknown.

Titles, from the homebrew catalog: VITA5 (PPSA39410) 1.0.0, Homebrew UI Lab (PPSA99050) 01.000.010 and Cloud Play (PPSA99600) 1.0.0. Each was relinked with --windows on main f1451396 and run on Windows 10. Where each stops:

  • VITA5 and Homebrew UI Lab:
    • main: 6kPnj51T62Y (sceVideoOutGetResolutionStatus, #1714)
    • main + #1714: e-YMQ+2tj9M (sceAgcDriverGetTFRing)
    • main + #1714 + this PR: Jc6E7N+dHz0 (system, #1859)
  • Cloud Play:

Each stop is the first line of the run, for example FAIL: unresolved ELF import e-YMQ+2tj9M from libSceAgcDriver.prx.

Tested

  • New agc_tessellation_factor_ring test, registered in ctest:
    • the default ring before any set;
    • sets read back, including ps5-opengl's size of 0x1b000;
    • a ring set on one thread is read on another;
    • a null base or a zero size is rejected and leaves the ring unchanged;
    • null output pointers are rejected;
    • a canary after the outputs stays intact.
  • Windows 10, MinGW-w64 GCC 15.2.0 (WinLibs 15.2.0posix-14.0.0-ucrt-r7), Release: agc_tessellation_factor_ring passes (--repeat until-fail:3). The NID-patched libSceAgcDriver.prx exports e-YMQ+2tj9M.
  • Ubuntu 26.04.1 (WSL2), GCC 15.2.0, Release, ANYPS5_ENABLE_SPIRV_TOOLS=ON: agc_tessellation_factor_ring passes (--repeat until-fail:3).
  • The test fails against 12 deliberate breakages:
    • a wrong default address or size;
    • a set that stores nothing, only the address, or the size cut to 16 bits;
    • per-thread instead of shared state;
    • a get that always reports the default, writes a 64-bit size, or returns nonzero;
    • a set that accepts a null base or stores before rejecting;
    • a get that dereferences a null output.
  • Titles: see the table above.
  • tools/check_conventions.py and tools/check_test_registration.py pass.

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:4795664801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1978). Originally posted by [LuisBiceps](https://github.com/LuisBiceps) on 2026-10-09T03:37:50Z. --- ### What Implements `sceAgcDriverGetTFRing` (NID `e-YMQ+2tj9M`) in libSceAgcDriver. `sceAgcDriverSetTFRing` now records the ring it receives, so Get reports it. - `int sceAgcDriverGetTFRing(uintptr_t* base, uint32_t* size)` writes the ring's base address and its size in bytes, and returns 0. - Before a title sets a ring, Get reports the console's default, 0xFF0000000 and 128 KiB. Source: [PS5_Vulkan's hardware findings](https://github.com/mihawk-99/PS5_Vulkan/blob/fde9e3798c2ec1d8fccc90d5067cd6060490607f/docs/HARDWARE_FINDINGS.md#L3415-L3422): "`sceAgcDriverGetTFRing` reports AGC's default, 0xF_F000_0000 and 128 KiB; `sceAgcDriverSetTFRing(address, size)` moves it". - The signature and the set-then-read behaviour follow [ps5-opengl's AGC runtime](https://github.com/blackbearreloaded/ps5-opengl/blob/67c873f985eaefe0a72f713529e5632eaa01139c/src/platform/ps5_agc_native_runtime.c#L2953-L2954), a console homebrew. It sets the ring, reads it back, and requires the same address and size ([L3890-L3896](https://github.com/blackbearreloaded/ps5-opengl/blob/67c873f985eaefe0a72f713529e5632eaa01139c/src/platform/ps5_agc_native_runtime.c#L3890-L3896)). - A null output pointer throws, since its result on the console is unknown. `sceAgcDriverSetTFRing` still throws for a null base or a zero size. - Nothing is written to the recorded ring: tessellated draws run as Vulkan tessellation stages, which keep their factors on the host, so a title that reads tessellation factors from the ring finds none. TechnicalDebt records this, and also `sceAgcDriverSetTFRing(0, 0)`, which ps5-opengl's runtime calls in its [cleanup](https://github.com/blackbearreloaded/ps5-opengl/blob/67c873f985eaefe0a72f713529e5632eaa01139c/src/platform/ps5_agc_native_runtime.c#L5419-L5420) and whose effect on the console is unknown. Titles, from the [homebrew catalog](https://github.com/blackbearreloaded/ps5-homebrew-catalog): VITA5 (PPSA39410) 1.0.0, Homebrew UI Lab (PPSA99050) 01.000.010 and Cloud Play (PPSA99600) 1.0.0. Each was relinked with `--windows` on `main` f1451396 and run on Windows 10. Where each stops: - VITA5 and Homebrew UI Lab: - `main`: `6kPnj51T62Y` (`sceVideoOutGetResolutionStatus`, #1714) - `main` + #1714: **`e-YMQ+2tj9M` (`sceAgcDriverGetTFRing`)** - `main` + #1714 + this PR: `Jc6E7N+dHz0` (`system`, #1859) - Cloud Play: - `main`: `6kPnj51T62Y` - `main` + #1714: `j-gWL6wDros` (`getifaddrs`, #1772) - `main` + #1714 + #1772: **`e-YMQ+2tj9M`** - `main` + #1714 + #1772 + this PR: `Jc6E7N+dHz0` Each stop is the first line of the run, for example `FAIL: unresolved ELF import e-YMQ+2tj9M from libSceAgcDriver.prx`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. --> - New `agc_tessellation_factor_ring` test, registered in ctest: - the default ring before any set; - sets read back, including ps5-opengl's size of 0x1b000; - a ring set on one thread is read on another; - a null base or a zero size is rejected and leaves the ring unchanged; - null output pointers are rejected; - a canary after the outputs stays intact. - Windows 10, MinGW-w64 GCC 15.2.0 (WinLibs `15.2.0posix-14.0.0-ucrt-r7`), Release: `agc_tessellation_factor_ring` passes (`--repeat until-fail:3`). The NID-patched `libSceAgcDriver.prx` exports `e-YMQ+2tj9M`. - Ubuntu 26.04.1 (WSL2), GCC 15.2.0, Release, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`: `agc_tessellation_factor_ring` passes (`--repeat until-fail:3`). - The test fails against 12 deliberate breakages: - a wrong default address or size; - a set that stores nothing, only the address, or the size cut to 16 bits; - per-thread instead of shared state; - a get that always reports the default, writes a 64-bit size, or returns nonzero; - a set that accepts a null base or stores before rejecting; - a get that dereferences a null output. - Titles: see the table above. - `tools/check_conventions.py` and `tools/check_test_registration.py` pass. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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-09 08:55:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T08:55:49Z.


Progress report (f145139 → b38c8d6)

➖ System libraries: 84.76% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceAgcDriver sceAgcDriverGetTFRing
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6077720916 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1978#issuecomment-6077720916). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T08:55:49Z. --- <!-- progress-report --> ### Progress report (f145139 → b38c8d6) ➖ **System libraries**: 84.76% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceAgcDriver | `sceAgcDriverGetTFRing` | </details>
adriadam10 commented 2026-10-09 21:53:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:53:50Z.


Checked on Linux (merged onto current main): build, full ctest (525/525) and agc_tessellation_factor_ring. The test doesn't link without the change. The NID and the default ring (0xFF0000000, 128 KiB) match the cited PS5_Vulkan findings and ps5-opengl's runtime at the pinned commits; TechnicalDebt records what isn't modelled. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6089889203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1978#issuecomment-6089889203). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T21:53:50Z. --- Checked on Linux (merged onto current main): build, full ctest (525/525) and `agc_tessellation_factor_ring`. The test doesn't link without the change. The NID and the default ring (0xFF0000000, 128 KiB) match the cited PS5_Vulkan findings and ps5-opengl's runtime at the pinned commits; TechnicalDebt records what isn't modelled. 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!1978
No description provided.