feat(libSceFreeType): implement FT_Set_Renderer #10611

Merged
MarcZX10 merged 8 commits from upstream-pr/10611 into main 2026-11-12 04:20:26 +00:00
MarcZX10 commented 2026-10-24 12:41:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:41:49Z.


What

Adds FT_Set_Renderer to libSceFreeType, following the bundled FreeType 2.13.3 (ftobjs.c). The guest passes the renderer handle returned by FT_Get_Renderer and an array of 16-byte LP64 FT_Parameter records (new GuestParameter, with a layout assertion); the adapter converts the tags to the host type, passes the data pointers through unchanged and forwards to the native call, so the argument checks, renderer-list reordering and error codes are the native ones. A tag above the host FT_ULong range throws, which only matters where the native type is 32 bits (Windows). Console signature and parameter layout are unverified; the debt entry says so.

Commits: implementation, test, debt entry.

Tested

Linux x86-64, GCC, full CMake build (Ninja, Release). guest_freetype_set_renderer compares the guest call with the native one for the outline and bitmap renderers: no parameters, one and two parameters with arbitrary tags, a missing parameter array, a null renderer, a null library and a renderer that belongs to another library, and checks the renderer lookup afterwards; it also passes a tag with every bit set where the host FT_ULong is 64-bit. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran the test with that check disabled in a local, uncommitted edit; it exits 0. Windows was not run. tools/check_conventions.py and git diff --check pass. No title or GPU involved.

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: #10602
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4995469135 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10611). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:41:49Z. --- ### What Adds `FT_Set_Renderer` to libSceFreeType, following the bundled FreeType 2.13.3 ([ftobjs.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftobjs.c)). The guest passes the renderer handle returned by `FT_Get_Renderer` and an array of 16-byte LP64 `FT_Parameter` records (new `GuestParameter`, with a layout assertion); the adapter converts the tags to the host type, passes the data pointers through unchanged and forwards to the native call, so the argument checks, renderer-list reordering and error codes are the native ones. A tag above the host `FT_ULong` range throws, which only matters where the native type is 32 bits (Windows). Console signature and parameter layout are unverified; the debt entry says so. Commits: implementation, test, debt entry. ### Tested Linux x86-64, GCC, full CMake build (Ninja, Release). `guest_freetype_set_renderer` compares the guest call with the native one for the outline and bitmap renderers: no parameters, one and two parameters with arbitrary tags, a missing parameter array, a null renderer, a null library and a renderer that belongs to another library, and checks the renderer lookup afterwards; it also passes a tag with every bit set where the host `FT_ULong` is 64-bit. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran the test with that check disabled in a local, uncommitted edit; it exits 0. Windows was not run. `tools/check_conventions.py` and `git diff --check` pass. No title or GPU involved. ### 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 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: #10602 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
harisibrar1 commented 2026-10-24 15:46:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:46:13Z.

Review: COMMENTED


Checked against main c9b75825f3 and FreeType 2.13.3 (42608f77) src/base/ftobjs.c, src/smooth/ftgrays.c, src/raster/ftraster.c, src/sdf/ftsdf.c:

  • NID Yu9oXRVmTTo matches the name, and the branch still merges cleanly into current main.
  • Native FT_Set_Renderer checks the library, the renderer, num_params && !parameters and list membership before it reads parameters, but the adapter converts every entry first (RendererSelection.cpp:18-26). So on Windows (32-bit FT_ULong), FT_Set_Renderer(lib, nullptr, 1, &p) with p.tag = 0x100000000 throws, while the bundled build returns FT_Err_Invalid_Argument; a null library or a foreign renderer behaves the same way, and it reads count guest entries in cases where native never touches them. Could the null/argument cases return the native result before the conversion loop?
  • The set_mode of every bundled renderer (smooth, raster1, sdf/bsdf) ignores tag and data, so the data pass-through is safe and the tag throw is purely conservative. The Windows throw path isn't covered by the test, since the wide case only runs with a 64-bit FT_ULong.
  • Heads-up: #10604 and #10609 add structs and static_asserts at the same two places in GuestFreeType.hpp, so the later one will need a small rebase.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638834798 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10611#pullrequestreview-5638834798). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:46:13Z. **Review:** COMMENTED --- Checked against main c9b75825f3 and FreeType 2.13.3 (42608f77) `src/base/ftobjs.c`, `src/smooth/ftgrays.c`, `src/raster/ftraster.c`, `src/sdf/ftsdf.c`: - NID `Yu9oXRVmTTo` matches the name, and the branch still merges cleanly into current main. - Native `FT_Set_Renderer` checks the library, the renderer, `num_params && !parameters` and list membership before it reads `parameters`, but the adapter converts every entry first (`RendererSelection.cpp:18-26`). So on Windows (32-bit `FT_ULong`), `FT_Set_Renderer(lib, nullptr, 1, &p)` with `p.tag = 0x100000000` throws, while the bundled build returns `FT_Err_Invalid_Argument`; a null library or a foreign renderer behaves the same way, and it reads `count` guest entries in cases where native never touches them. Could the null/argument cases return the native result before the conversion loop? - The `set_mode` of every bundled renderer (smooth, raster1, sdf/bsdf) ignores tag and data, so the data pass-through is safe and the tag throw is purely conservative. The Windows throw path isn't covered by the test, since the `wide` case only runs with a 64-bit `FT_ULong`. - Heads-up: #10604 and #10609 add structs and static_asserts at the same two places in `GuestFreeType.hpp`, so the later one will need a small rebase. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10 commented 2026-11-02 04:57:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:57:43Z.

Review: COMMENTED


Reviewed — rebase done, three replies still open

The rebase conflicts are gone at this head, but the parameter-order fix, the unreadable-array regression and the debt wording requested on 28 and 29 Oct are not in the branch.

What I ran

Live head a53e3648520ada06c3c71e03f242a6904b69d926 (matches batch). gh pr view for state, mergeability and statusCheckRollup; gh api reads of comments, review comments and reviews; git show <head>:<path> on RendererSelection.cpp, Api.hpp, GuestFreeTypeSetRenderer.cpp and both debt docs; grep counts on Export.cpp. Nothing was built or run.

Results

Check Result Note
mergeability MERGEABLE, CLEAN the 28 Oct conflicts are gone
windows SUCCESS hosted
conventions SUCCESS hosted
linux SKIPPED hosted skip

Findings

  • Rebase (28 Oct): done. Api.hpp:100 declares FT_Set_Renderer_nid_postfix.
  • Parameter order (28 and 29 Oct): not done. RendererSelection.cpp:19-26 converts the parameters before any check of library, renderer or same-library membership. The tag check at :22-24 throws instead of returning FT_Err_Invalid_Argument.
  • Unreadable-array regressions (29 Oct): not present. GuestFreeTypeSetRenderer.cpp:47-48 and :54 pass nullptr parameters. No case passes an unreadable array.
  • Debt wording (28 Oct): not done. libSceFreeType.md:3 still says the handle "must come from FT_Get_Renderer", with no statement that the guest cannot obtain one. No FT_Get_Renderer declaration is in Api.hpp, so the reviewer's premise holds at this head.
  • Provider lists (29 Oct): not done. libSceFreeTypeOt.md:3-6 keeps two lists with 139 and 129. Export.cpp has 123 unique sceFreeTypeOtUnknown_ names at head, matching the reviewer's count.

Sources

Not verified

  • The reviewer's requested public_headers and guest_freetype_set_renderer runs: not run, no build.
  • The Windows behavior for tags above 32 bits: not run.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5732250627 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10611#pullrequestreview-5732250627). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-02T04:57:43Z. **Review:** COMMENTED --- # Reviewed — rebase done, three replies still open The rebase conflicts are gone at this head, but the parameter-order fix, the unreadable-array regression and the debt wording requested on 28 and 29 Oct are not in the branch. ## What I ran Live head `a53e3648520ada06c3c71e03f242a6904b69d926` (matches batch). `gh pr view` for state, mergeability and `statusCheckRollup`; `gh api` reads of comments, review comments and reviews; `git show <head>:<path>` on `RendererSelection.cpp`, `Api.hpp`, `GuestFreeTypeSetRenderer.cpp` and both debt docs; `grep` counts on `Export.cpp`. Nothing was built or run. ## Results | Check | Result | Note | |---|---|---| | mergeability | MERGEABLE, CLEAN | the 28 Oct conflicts are gone | | windows | SUCCESS | hosted | | conventions | SUCCESS | hosted | | linux | SKIPPED | hosted skip | ## Findings - Rebase (28 Oct): done. `Api.hpp:100` declares `FT_Set_Renderer_nid_postfix`. - Parameter order (28 and 29 Oct): not done. `RendererSelection.cpp:19-26` converts the parameters before any check of library, renderer or same-library membership. The tag check at `:22-24` throws instead of returning `FT_Err_Invalid_Argument`. - Unreadable-array regressions (29 Oct): not present. `GuestFreeTypeSetRenderer.cpp:47-48` and `:54` pass `nullptr` parameters. No case passes an unreadable array. - Debt wording (28 Oct): not done. `libSceFreeType.md:3` still says the handle "must come from `FT_Get_Renderer`", with no statement that the guest cannot obtain one. No `FT_Get_Renderer` declaration is in `Api.hpp`, so the reviewer's premise holds at this head. - Provider lists (29 Oct): not done. `libSceFreeTypeOt.md:3-6` keeps two lists with 139 and 129. `Export.cpp` has 123 unique `sceFreeTypeOtUnknown_` names at head, matching the reviewer's count. ## Sources - https://github.com/boykopovar/AnyPS5/blob/a53e3648520ada06c3c71e03f242a6904b69d926/core/libs/prx/libSceFreeType/src/RendererSelection.cpp#L17-L28 - https://github.com/boykopovar/AnyPS5/blob/a53e3648520ada06c3c71e03f242a6904b69d926/core/libs/tests/GuestFreeTypeSetRenderer.cpp#L47-L54 - https://github.com/boykopovar/AnyPS5/blob/a53e3648520ada06c3c71e03f242a6904b69d926/docs/dev/debt/libSceFreeType.md#L3 - https://github.com/boykopovar/AnyPS5/blob/a53e3648520ada06c3c71e03f242a6904b69d926/docs/dev/debt/libSceFreeTypeOt.md#L3-L6 ## Not verified - The reviewer's requested `public_headers` and `guest_freetype_set_renderer` runs: not run, no build. - The Windows behavior for tags above 32 bits: not run.
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!10611
No description provided.