feat(libSceFreeType): decompose guest outlines #9560

Merged
Ondra97 merged 1 commit from upstream-pr/9560 into main 2026-10-25 08:15:18 +00:00
Ondra97 commented 2026-10-22 02:20:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T02:20:11Z.


What

Add FT_Outline_Decompose (NID ++lgV9pRsO4) so callers can consume guest outlines through move, line, quadratic and cubic callbacks. The existing bridge can load and render an outline but has no entry point for callers that need its path segments.

Describe the 48-byte LP64 callback table and invoke its System V callbacks directly with 64-bit guest vectors. Walk guest coordinates without narrowing them through Windows' 32-bit native FT_Pos. Preserve implicit on-curve midpoints, contour closure, degenerate segments, low tag bits, partial callback sequences on invalid outlines, and the exact nonzero value returned by a callback. Each call has local traversal state; callback changes to the emitter table take effect, while shift/delta and the current contour's array pointers retain the native snapshot behavior.

The name/NID comes from the pinned PS5 3.20 inventory. The layout and behavior follow bundled FreeType 2.13.3 ftoutln.c and ftimage.h. Console ABI and version equivalence remain unverified. The debt entry also records throwing paths for undefined signed overflow and nonempty outlines with shifts outside 0-62. Valid arrays and the callbacks a contour uses remain caller requirements.

Merge after #9465 for the shared guest-record/debt insertion, retaining the existing insertion-order prerequisite previously declared through #9519. #9519 is now merged into main; its outline-copy implementation, public declaration, debt entry and regressions remain included alongside decomposition. #9530, #9574, #9054, #9309 and #9329 are also merged. #9588 includes the glyph records from #9465 and implements a separate control-box query; preserve those records alongside GuestOutlineFuncs. The decomposition implementation is independent. No other open PR adds this decomposition export.

No title unblock or performance improvement is claimed.

Tested

Rebased on upstream main 52a8bed576e5c54a7f443728cdf663a080f8f9ed; tested PR head 110f43a331d865b126e09e29e713f43c42176437. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, BUILD_TESTING=ON, pinned bundled dependencies. These FreeType/font tests use the CPU.

  • cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8: production relinker, patched libraries and all selected fixtures built successfully from the rebased source.
  • ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error: 18/18 passed, zero skips; 368 patched libraries loaded, none failed. Decomposition performed 49,416 native comparisons, 72,732 callbacks and eight rendered glyphs, including wide coordinates and callback mutation. The merged outline-copy regression also passed 178 cases and three rendered copies; main's Gasp, trigonometry, orientation and CID regressions remain executed.
  • ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 4 --output-on-failure --no-tests=error: 65/65 passed, zero skips. Both outline exports retain their separate public declarations in Api.hpp; the test uses the public declaration and GuestLibrary* type.
  • objdump -p <build>/core/libs/libs/libSceFreeType.prx confirms packaged NID ++lgV9pRsO4. OutlineDecompose.cpp is byte-identical to the previous submitted implementation. git range-diff retains the single feature commit and its substantive test assertions; conflict resolutions preserve both outline exports and their debt entries, and the automatic test merge retains CheckOutlineCopies() alongside OutlineDecomposition().
  • python tools/check_conventions.py --base origin/main, python tools/check_main_sync.py --base origin/main --strict, git diff origin/main...HEAD --check and python tools/check_test_registration.py <build>: passed. python tools/pr_overlap.py --branch codex/pr9560-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12 completed. #9465 remains the insertion-order prerequisite; #9588 includes the same glyph records and adds a distinct query. Manual inspection of the shared files in conflicting #9848 and #10593 found separate macOS symbol-visibility and glyph-slot-synthesis changes. The old hosted #9560 head is the expected self-match. No other open PR duplicates the decomposition export.

No title/homebrew run or complete CTest suite is claimed on this rebased head. Console callback ABI/version equivalence remains unverified as recorded in debt.

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: #9465
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4961119600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T02:20:11Z. --- ### What Add `FT_Outline_Decompose` (NID `++lgV9pRsO4`) so callers can consume guest outlines through move, line, quadratic and cubic callbacks. The existing bridge can load and render an outline but has no entry point for callers that need its path segments. Describe the 48-byte LP64 callback table and invoke its System V callbacks directly with 64-bit guest vectors. Walk guest coordinates without narrowing them through Windows' 32-bit native `FT_Pos`. Preserve implicit on-curve midpoints, contour closure, degenerate segments, low tag bits, partial callback sequences on invalid outlines, and the exact nonzero value returned by a callback. Each call has local traversal state; callback changes to the emitter table take effect, while shift/delta and the current contour's array pointers retain the native snapshot behavior. The name/NID comes from the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). The layout and behavior follow bundled [FreeType 2.13.3 ftoutln.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftoutln.c) and [ftimage.h](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/include/freetype/ftimage.h). Console ABI and version equivalence remain unverified. The debt entry also records throwing paths for undefined signed overflow and nonempty outlines with shifts outside 0-62. Valid arrays and the callbacks a contour uses remain caller requirements. Merge after #9465 for the shared guest-record/debt insertion, retaining the existing insertion-order prerequisite previously declared through #9519. #9519 is now merged into main; its outline-copy implementation, public declaration, debt entry and regressions remain included alongside decomposition. #9530, #9574, #9054, #9309 and #9329 are also merged. #9588 includes the glyph records from #9465 and implements a separate control-box query; preserve those records alongside GuestOutlineFuncs. The decomposition implementation is independent. No other open PR adds this decomposition export. No title unblock or performance improvement is claimed. ### Tested Rebased on upstream `main` `52a8bed576e5c54a7f443728cdf663a080f8f9ed`; tested PR head `110f43a331d865b126e09e29e713f43c42176437`. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, `BUILD_TESTING=ON`, pinned bundled dependencies. These FreeType/font tests use the CPU. - `cmake --build <build> --target relinker libs patched_libraries_tests guest_freetype_tests guest_freetype_bitmap_tests guest_freetype_request_size_tests guest_freetype_outline_tests guest_freetype_outline_mutations_tests guest_freetype_charmap_tests guest_freetype_charmap_info_tests guest_freetype_face_info_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_list_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests --parallel 8`: production relinker, patched libraries and all selected fixtures built successfully from the rebased source. - `ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V --output-on-failure --no-tests=error`: 18/18 passed, zero skips; 368 patched libraries loaded, none failed. Decomposition performed 49,416 native comparisons, 72,732 callbacks and eight rendered glyphs, including wide coordinates and callback mutation. The merged outline-copy regression also passed 178 cases and three rendered copies; main's Gasp, trigonometry, orientation and CID regressions remain executed. - `ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 4 --output-on-failure --no-tests=error`: 65/65 passed, zero skips. Both outline exports retain their separate public declarations in `Api.hpp`; the test uses the public declaration and `GuestLibrary*` type. - `objdump -p <build>/core/libs/libs/libSceFreeType.prx` confirms packaged NID `++lgV9pRsO4`. `OutlineDecompose.cpp` is byte-identical to the previous submitted implementation. `git range-diff` retains the single feature commit and its substantive test assertions; conflict resolutions preserve both outline exports and their debt entries, and the automatic test merge retains `CheckOutlineCopies()` alongside `OutlineDecomposition()`. - `python tools/check_conventions.py --base origin/main`, `python tools/check_main_sync.py --base origin/main --strict`, `git diff origin/main...HEAD --check` and `python tools/check_test_registration.py <build>`: passed. `python tools/pr_overlap.py --branch codex/pr9560-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12` completed. #9465 remains the insertion-order prerequisite; #9588 includes the same glyph records and adds a distinct query. Manual inspection of the shared files in conflicting #9848 and #10593 found separate macOS symbol-visibility and glyph-slot-synthesis changes. The old hosted #9560 head is the expected self-match. No other open PR duplicates the decomposition export. No title/homebrew run or complete CTest suite is claimed on this rebased head. Console callback ABI/version equivalence remains unverified as recorded in debt. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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: #9465 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
Ondra97 commented 2026-10-22 02:48:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T02:48:34Z.


I opened #9574 for FT_Cos, FT_Sin, FT_Tan, FT_Vector_Unit and FT_Angle_Diff. I declared #9560 for merge order because the patches share CMake, prototype, helper, test-call and debt insertion points. Retain both OutlineDecompose.cpp and Trigonometry.cpp, their declarations, tests and debt entries. The implementations are independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331465309 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560#issuecomment-6331465309). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T02:48:34Z. --- I opened #9574 for FT_Cos, FT_Sin, FT_Tan, FT_Vector_Unit and FT_Angle_Diff. I declared #9560 for merge order because the patches share CMake, prototype, helper, test-call and debt insertion points. Retain both OutlineDecompose.cpp and Trigonometry.cpp, their declarations, tests and debt entries. The implementations are independent.
MarcZX10 commented 2026-10-22 04:15:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:15:01Z.

Review: CHANGES_REQUESTED


The LP64 adapter, callback behavior, bounded-arithmetic exceptions, and native-comparison coverage are documented in unusually useful detail; I found no code-level blocker in the reviewed diff. The remaining repository requirement is base freshness: this branch is based on 8c26eac3, while current upstream main is dce41a89478876a8e3ea9c346b1dac00bb31c8cd (23 commits ahead). Please update from current main and rerun the focused FreeType tests/convention and overlap checks on the resulting head. I checked the intervening commits and none touch the FreeType implementation, tests, or debt files, but the repo still requires branches to be based on current main. The declared dependencies #9054, #9519, #9530 and #9329 are open and their merge order is clearly described; preserve those insertions when rebasing. Hosted eligibility, conventions, intake, labels and report checks pass; product/relinker jobs are skipped. Windows testing in the body is author-reported; I did not run tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609185029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560#pullrequestreview-5609185029). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:15:01Z. **Review:** CHANGES_REQUESTED --- The LP64 adapter, callback behavior, bounded-arithmetic exceptions, and native-comparison coverage are documented in unusually useful detail; I found no code-level blocker in the reviewed diff. The remaining repository requirement is base freshness: this branch is based on `8c26eac3`, while current upstream main is `dce41a89478876a8e3ea9c346b1dac00bb31c8cd` (23 commits ahead). Please update from current main and rerun the focused FreeType tests/convention and overlap checks on the resulting head. I checked the intervening commits and none touch the FreeType implementation, tests, or debt files, but the repo still requires branches to be based on current main. The declared dependencies #9054, #9519, #9530 and #9329 are open and their merge order is clearly described; preserve those insertions when rebasing. Hosted eligibility, conventions, intake, labels and report checks pass; product/relinker jobs are skipped. Windows testing in the body is author-reported; I did not run tests locally.
jotitadev commented 2026-10-22 07:42:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:42:20Z.

Review: COMMENTED


Linux run, since the description only covers Windows, where native FT_Pos is 32-bit. On Linux, native FT_Pos is 64-bit, the other side of the narrowing the description talks about. It passes, and runs clean under ASan and UBSan.

Machine: Linux, Ubuntu 26.04, GCC 15.2.0, x86-64. Head be5a985f8 merged with git merge --no-commit onto current main d6eafa54d (clean).

  • Release (Ninja, BUILD_TESTING=ON, ANYPS5_RELINKER_ONLY=OFF): guest_freetype passes.
  • ASan + UBSan (-fsanitize=address,undefined -fno-sanitize-recover=undefined -O1 -g, ANYPS5_ENABLE_ASAN=ON, leak detection off): guest_freetype_tests exits 0 with no reports: FreeType outline decomposition: 49416 native comparisons, 72732 callbacks, 8 rendered glyphs, wide coordinates and callback mutation.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5610778514 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560#pullrequestreview-5610778514). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T07:42:20Z. **Review:** COMMENTED --- Linux run, since the description only covers Windows, where native `FT_Pos` is 32-bit. On Linux, native `FT_Pos` is 64-bit, the other side of the narrowing the description talks about. It passes, and runs clean under ASan and UBSan. **Machine:** Linux, Ubuntu 26.04, GCC 15.2.0, x86-64. Head `be5a985f8` merged with `git merge --no-commit` onto current `main` `d6eafa54d` (clean). - **Release** (Ninja, `BUILD_TESTING=ON`, `ANYPS5_RELINKER_ONLY=OFF`): `guest_freetype` passes. - **ASan + UBSan** (`-fsanitize=address,undefined -fno-sanitize-recover=undefined -O1 -g`, `ANYPS5_ENABLE_ASAN=ON`, leak detection off): `guest_freetype_tests` exits 0 with no reports: `FreeType outline decomposition: 49416 native comparisons, 72732 callbacks, 8 rendered glyphs, wide coordinates and callback mutation`. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-22 11:22:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:22:09Z.


The new Linux independent run adds useful evidence, including sanitizer coverage and native 64-bit FT_Pos comparison. The declared dependency chain and the follow-up #9574 merge-order note are explicit. I checked the current head against upstream/main: the merge is clean and the only intervening FreeType-path change is the unrelated #7961 merge, but the branch is still 2 ahead/11 behind (merge base d6eafa54d) while current main is 4777caca34. CONTRIBUTING requires the branch to stay current. Please update from current main, rerun the focused FreeType suite and convention/overlap checks, and refresh Tested on that head. I did not run the tests locally due to the full filesystem; the Windows and Linux reports are by the PR author and another reviewer.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339515086 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560#issuecomment-6339515086). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:22:09Z. --- The new Linux independent run adds useful evidence, including sanitizer coverage and native 64-bit FT_Pos comparison. The declared dependency chain and the follow-up #9574 merge-order note are explicit. I checked the current head against upstream/main: the merge is clean and the only intervening FreeType-path change is the unrelated #7961 merge, but the branch is still 2 ahead/11 behind (merge base d6eafa54d) while current main is 4777caca34. CONTRIBUTING requires the branch to stay current. Please update from current main, rerun the focused FreeType suite and convention/overlap checks, and refresh Tested on that head. I did not run the tests locally due to the full filesystem; the Windows and Linux reports are by the PR author and another reviewer.
MarcZX10 commented 2026-10-22 11:22:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:22:11Z.

Review: DISMISSED


No code-level blocker surfaced in the reviewed diff, and the PR now has strong Windows and independent Linux evidence. I am retaining changes requested solely for the repository freshness requirement: the head is 2 ahead/11 behind current upstream/main 4777caca34 (merge base d6eafa54d). Please update and rerun focused FreeType tests plus convention/overlap checks on that head, preserving the declared prerequisites #9054, #9519, #9530 and #9329 and the recorded #9574 insertion order. I did not run tests locally; the filesystem is full.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613371261 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9560#pullrequestreview-5613371261). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:22:11Z. **Review:** DISMISSED --- No code-level blocker surfaced in the reviewed diff, and the PR now has strong Windows and independent Linux evidence. I am retaining changes requested solely for the repository freshness requirement: the head is 2 ahead/11 behind current upstream/main 4777caca34 (merge base d6eafa54d). Please update and rerun focused FreeType tests plus convention/overlap checks on that head, preserving the declared prerequisites #9054, #9519, #9530 and #9329 and the recorded #9574 insertion order. I did not run tests locally; the filesystem is full.
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!9560
No description provided.