feat(libSceFont): graphics services and surface textures through the Gnm backend #16199

Merged
ntamas94 merged 10 commits from upstream-pr/16199 into main 2026-11-14 19:59:59 +00:00
ntamas94 commented 2026-11-05 20:39:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ntamas94 on 2026-11-05T20:39:45Z.


What

Start porting the PS4 libSceFontGs Gnm rendering backend that sceFontSelectGraphicsGnm(0) returns, together with the libSceFont side that consumes it. Stacked on #16125: only the last two commits are new here.

  • sceFontSelectGraphicsGnm(0) returns a host table with the PS4 10.71 layout: header (tag 0x0e08, instance slot, 0x20000-byte instance size, enumerate function), the 21 opcode entries in module order and the list descriptor. Opcode 02 is the original no-op, 03/04 keep their values, opcode 05 is ported, and the other 17 handlers (init 01 included) throw through NotImplemented_nid_no_patch until ported.
  • sceFontCreateGraphicsService, sceFontCreateGraphicsServiceWithEdition and sceFontDestroyGraphicsService follow the PS4 bodies: validation order and codes reported through the graphics error callback, the 0x100-byte service, the direct-memory instance, the slot spin-lock, the refcount and the opcode dispatch fill. A Gnm-backed service still throws at the opcode 01 init.
  • Opcode 05 (libSceFontGs 0xdf40) builds the 8-dword T# of a surface texture object from a surface copy. sceFontGraphicsStructureSurfaceTexture, sceFontGraphicsTextureRefersSurface and the surface-texture case of sceFontGraphicsRelease reach it.
  • The drawup pool entries start at +0x20, as in PS4 10.71 (the host used +0x18).

The debt files list what still throws: the device heap path for a surface without a base address, the other sceFontGraphicsRelease tags, and every unported backend handler. sceFontCreateGraphicsDevice is not ported yet, so the surface-texture exports are tested with constructed devices.

Tested

Windows (MSYS2 UCRT64): all 16 guest_font* tests and public_headers pass; check_conventions.py passes. Off-console, the decrypted PS4 10.71 libSceFont and libSceFontGs code was loaded with its relocations and run against the host: the backend table and dispatch fill, 26 service create/destroy cases, opcode 05 on 3,000,000 random and 200,000 SurfaceInit-built inputs, and 250,143 steps of StructureSurfaceTexture, RefersSurface and Release over 20,000 random device and pool shapes all matched byte for byte. Nothing in this PR was measured on a console, and no title was tested.

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 under Silent stubs in their library's technical debt file
  • 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: #16125
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5178374008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16199). Originally posted by [ntamas94](https://github.com/ntamas94) on 2026-11-05T20:39:45Z. --- ### What Start porting the PS4 libSceFontGs Gnm rendering backend that `sceFontSelectGraphicsGnm(0)` returns, together with the libSceFont side that consumes it. Stacked on #16125: only the last two commits are new here. - `sceFontSelectGraphicsGnm(0)` returns a host table with the PS4 10.71 layout: header (tag 0x0e08, instance slot, 0x20000-byte instance size, enumerate function), the 21 opcode entries in module order and the list descriptor. Opcode 02 is the original no-op, 03/04 keep their values, opcode 05 is ported, and the other 17 handlers (init 01 included) throw through `NotImplemented_nid_no_patch` until ported. - `sceFontCreateGraphicsService`, `sceFontCreateGraphicsServiceWithEdition` and `sceFontDestroyGraphicsService` follow the PS4 bodies: validation order and codes reported through the graphics error callback, the 0x100-byte service, the direct-memory instance, the slot spin-lock, the refcount and the opcode dispatch fill. A Gnm-backed service still throws at the opcode 01 init. - Opcode 05 (libSceFontGs 0xdf40) builds the 8-dword T# of a surface texture object from a surface copy. `sceFontGraphicsStructureSurfaceTexture`, `sceFontGraphicsTextureRefersSurface` and the surface-texture case of `sceFontGraphicsRelease` reach it. - The drawup pool entries start at +0x20, as in PS4 10.71 (the host used +0x18). The debt files list what still throws: the device heap path for a surface without a base address, the other `sceFontGraphicsRelease` tags, and every unported backend handler. `sceFontCreateGraphicsDevice` is not ported yet, so the surface-texture exports are tested with constructed devices. ### Tested Windows (MSYS2 UCRT64): all 16 `guest_font*` tests and `public_headers` pass; `check_conventions.py` passes. Off-console, the decrypted PS4 10.71 libSceFont and libSceFontGs code was loaded with its relocations and run against the host: the backend table and dispatch fill, 26 service create/destroy cases, opcode 05 on 3,000,000 random and 200,000 SurfaceInit-built inputs, and 250,143 steps of StructureSurfaceTexture, RefersSurface and Release over 20,000 random device and pool shapes all matched byte for byte. Nothing in this PR was measured on a console, and no title was tested. ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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: #16125 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!16199
No description provided.