feat(libSceFreeType): manage multiple size objects #9550

Merged
Ondra97 merged 4 commits from upstream-pr/9550 into main 2026-10-25 22:49:06 +00:00
Ondra97 commented 2026-10-22 01:54:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T01:54:54Z.


What

A face can have several independently configured pixel sizes, but the guest bridge previously had only one embedded size record and no size-object entry points. Add FT_New_Size, FT_Activate_Size and FT_Done_Size, with NIDs zyezaHweY3U, EBvr2CZnjVo and -2rnxRCeHMs.

Keep stable guest records for additional native sizes, retain the existing default record, and synchronize the active pointer and LP64 metrics without refreshing the glyph slot or overwriting guest outline edits. Deleting an active size selects the same surviving native size; deleting the last one clears face->size. Size finalizers receive the corresponding record and observe the native active-size selection. Face/library teardown keeps those records alive through all size callbacks and clears the pointer before the face callback. The review follow-up pins this behavior with an active additional size destroyed before later size callbacks; each callback checks its owned guest record, complete current-size metrics and the active pointer against native FreeType.

Preserve native error ordering, untouched outputs on precondition failures, output clearing on allocation failure, and the behavior of FT_New_Size(face, &face->size). Allocate guest storage before native creation so a wrapper allocation failure cannot leak a native size. Native size/list/internal allocation failures are exercised through the public FreeType memory allocator.

The names/NIDs match the pinned PS5 3.20 inventory. Contracts and destruction order follow bundled FreeType 2.13.3 ftobjs.c and ftsizes.h. Console ABI/version and finalizer equivalence remain unverified and are recorded in debt.

Depends on #9437 for the native face-lifetime fix; its implementation and regression coverage remain included, with the current #9437 head 60a0f0f5e2ef9ee462718108dd3a27a8a1c495bd used for comparison. #9437 declares #9419 for debt insertion order. #8286, #9545, #9574 and #9384 have merged; their bitmap, CID, trigonometry and strike-selection implementation/tests remain in this rebased tree, along with main's outline-copy/decomposition coverage. No title unblock or performance improvement is claimed.

Tested

Rebased on upstream main 0119103fa9ed65a894a931da02b6510669991b45; tested PR head 85e43880cf84adbd140203e09ff58e3a1b34d918. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, BUILD_TESTING=ON, pinned bundled dependencies (FreeType 2.13.3). These tests used the CPU.

  • cmake --build <build> --target libSceFreeType 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, followed by cmake --build <build> --target guest_font_metrics_tests guest_font_style_information_tests guest_font_outline_profile_tests --parallel 8: production FreeType and all focused fixtures built successfully without a source overlay.
  • ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*)$' -V --output-on-failure --no-tests=error: 20/20 passed, zero skips. Size regression: 24 lifecycles, 468 rendered glyphs and 48 injected allocation failures compared with native FreeType. Included #9437 regression: 28 retains, 24 non-final releases and eight finalized faces, including reentrant callbacks and owned file bytes. Main's FT_Select_Size regression also passed (26 native request comparisons and 18 bitmap glyph comparisons), alongside its outline, CID and trigonometry coverage and the three new font tests.
  • ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 8 --output-on-failure --no-tests=error: 65/65 passed, zero skips. The conflict in Api.hpp was resolved by retaining both main's FT_Select_Size declaration and this PR's face-reference/size-object declarations.
  • git range-diff 50a4f824fc3ee23177d8e1effbe306e50150187f..d32f20c97e5188902f77ff525303f7252e4071d0 0119103fa9ed65a894a931da02b6510669991b45..85e43880cf84adbd140203e09ff58e3a1b34d918: all three commits retained; changes are API declaration integration and surrounding context, with the teardown regression unchanged.
  • 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/pr9550-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12 completed against the same main. #9437 is the inherited face-reference implementation and #9419 its documentation-order predecessor; old #9550 is the expected self-match. Manual shared-file comparisons confirmed #10604 (FT_Open_Face), #10606 (library references), #10616 (FT_Attach_File), #9465 (glyph debt) and #9848 (macOS debt cleanup) change distinct behavior. Adjacent insertions must retain both changes during later rebases.

The baseline lacks the guest size exports required by the size regression. Console ABI/version, title impact and generic-finalizer equivalence remain unverified as recorded in debt. The complete all-target build, patched-libraries loader, complete CTest suite and a title run were not performed on this rebased head; earlier full-build/loader results are historical evidence only.

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: #9437
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960914005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T01:54:54Z. --- ### What A face can have several independently configured pixel sizes, but the guest bridge previously had only one embedded size record and no size-object entry points. Add `FT_New_Size`, `FT_Activate_Size` and `FT_Done_Size`, with NIDs `zyezaHweY3U`, `EBvr2CZnjVo` and `-2rnxRCeHMs`. Keep stable guest records for additional native sizes, retain the existing default record, and synchronize the active pointer and LP64 metrics without refreshing the glyph slot or overwriting guest outline edits. Deleting an active size selects the same surviving native size; deleting the last one clears `face->size`. Size finalizers receive the corresponding record and observe the native active-size selection. Face/library teardown keeps those records alive through all size callbacks and clears the pointer before the face callback. The review follow-up pins this behavior with an active additional size destroyed before later size callbacks; each callback checks its owned guest record, complete current-size metrics and the active pointer against native FreeType. Preserve native error ordering, untouched outputs on precondition failures, output clearing on allocation failure, and the behavior of `FT_New_Size(face, &face->size)`. Allocate guest storage before native creation so a wrapper allocation failure cannot leak a native size. Native size/list/internal allocation failures are exercised through the public FreeType memory allocator. The names/NIDs match the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). Contracts and destruction order follow bundled [FreeType 2.13.3 ftobjs.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftobjs.c) and [ftsizes.h](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/include/freetype/ftsizes.h). Console ABI/version and finalizer equivalence remain unverified and are recorded in debt. Depends on #9437 for the native face-lifetime fix; its implementation and regression coverage remain included, with the current #9437 head `60a0f0f5e2ef9ee462718108dd3a27a8a1c495bd` used for comparison. #9437 declares #9419 for debt insertion order. #8286, #9545, #9574 and #9384 have merged; their bitmap, CID, trigonometry and strike-selection implementation/tests remain in this rebased tree, along with main's outline-copy/decomposition coverage. No title unblock or performance improvement is claimed. ### Tested Rebased on upstream `main` `0119103fa9ed65a894a931da02b6510669991b45`; tested PR head `85e43880cf84adbd140203e09ff58e3a1b34d918`. Windows 11 Pro 10.0.26300, Ryzen 9 7900X, 31.7 GiB RAM, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release, `BUILD_TESTING=ON`, pinned bundled dependencies (FreeType 2.13.3). These tests used the CPU. - `cmake --build <build> --target libSceFreeType 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`, followed by `cmake --build <build> --target guest_font_metrics_tests guest_font_style_information_tests guest_font_outline_profile_tests --parallel 8`: production FreeType and all focused fixtures built successfully without a source overlay. - `ctest --test-dir <build> -R '^(guest_freetype.*|guest_.*font.*|font_.*)$' -V --output-on-failure --no-tests=error`: 20/20 passed, zero skips. Size regression: 24 lifecycles, 468 rendered glyphs and 48 injected allocation failures compared with native FreeType. Included #9437 regression: 28 retains, 24 non-final releases and eight finalized faces, including reentrant callbacks and owned file bytes. Main's `FT_Select_Size` regression also passed (26 native request comparisons and 18 bitmap glyph comparisons), alongside its outline, CID and trigonometry coverage and the three new font tests. - `ctest --test-dir <build> -R '^public_headers($|_compile_)' -j 8 --output-on-failure --no-tests=error`: 65/65 passed, zero skips. The conflict in `Api.hpp` was resolved by retaining both main's `FT_Select_Size` declaration and this PR's face-reference/size-object declarations. - `git range-diff 50a4f824fc3ee23177d8e1effbe306e50150187f..d32f20c97e5188902f77ff525303f7252e4071d0 0119103fa9ed65a894a931da02b6510669991b45..85e43880cf84adbd140203e09ff58e3a1b34d918`: all three commits retained; changes are API declaration integration and surrounding context, with the teardown regression unchanged. - `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/pr9550-rebase-20261024 --repo boykopovar/AnyPS5 --jobs 12` completed against the same main. #9437 is the inherited face-reference implementation and #9419 its documentation-order predecessor; old #9550 is the expected self-match. Manual shared-file comparisons confirmed #10604 (`FT_Open_Face`), #10606 (library references), #10616 (`FT_Attach_File`), #9465 (glyph debt) and #9848 (macOS debt cleanup) change distinct behavior. Adjacent insertions must retain both changes during later rebases. The baseline lacks the guest size exports required by the size regression. Console ABI/version, title impact and generic-finalizer equivalence remain unverified as recorded in debt. The complete all-target build, patched-libraries loader, complete CTest suite and a title run were not performed on this rebased head; earlier full-build/loader results are historical evidence only. <!-- 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: #9437 <!-- #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 -->
MarcZX10 commented 2026-10-22 01:58:10 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The size creation and activation paths are narrowly scoped and have strong native-reference lifecycle coverage. The PR declares its #9437 and FreeType insertion-order dependencies, and the hosted eligibility, intake, labels and report checks pass. The convention check and product/relinker builds are still pending/skipped; I did not run local tests.

I’m requesting changes for one destruction-path issue in the submitted head:

FT_Done_FreeType destroys a face by calling FT_List_Finalize on face->sizes_list. That routine saves cur->next, invokes the size destructor, then proceeds to the saved node. In FinalizeSize, the adapter calls SyncSizePointer_nid_no_patch, which searches face.sizes for host->face->size and throws if it cannot find it. This makes library teardown depend on whether the active native size is still represented in the guest list at each callback. Please add a regression that forces library teardown with several guest sizes and the active size positioned so its guest owner is removed before later size callbacks, and make the callback/teardown path tolerate FreeType's list-finalization order while keeping every callback's guest size record valid. Also verify callbacks still see the expected active-size pointer and metrics where that state is available.

This is based on the bundled FreeType 2.13.3 destroy_face/FT_List_Finalize order and the current callback's lookup/throw behavior; I have not run a local reproduction. Please report the focused test and rerun convention checks after fixing it.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608399308 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550#pullrequestreview-5608399308). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:58:10Z. **Review:** CHANGES_REQUESTED --- The size creation and activation paths are narrowly scoped and have strong native-reference lifecycle coverage. The PR declares its #9437 and FreeType insertion-order dependencies, and the hosted eligibility, intake, labels and report checks pass. The convention check and product/relinker builds are still pending/skipped; I did not run local tests. I’m requesting changes for one destruction-path issue in the submitted head: `FT_Done_FreeType` destroys a face by calling `FT_List_Finalize` on `face->sizes_list`. That routine saves `cur->next`, invokes the size destructor, then proceeds to the saved node. In `FinalizeSize`, the adapter calls `SyncSizePointer_nid_no_patch`, which searches `face.sizes` for `host->face->size` and throws if it cannot find it. This makes library teardown depend on whether the active native size is still represented in the guest list at each callback. Please add a regression that forces library teardown with several guest sizes and the active size positioned so its guest owner is removed before later size callbacks, and make the callback/teardown path tolerate FreeType's list-finalization order while keeping every callback's guest size record valid. Also verify callbacks still see the expected active-size pointer and metrics where that state is available. This is based on the bundled FreeType 2.13.3 `destroy_face`/`FT_List_Finalize` order and the current callback's lookup/throw behavior; I have not run a local reproduction. Please report the focused test and rerun convention checks after fixing it.
MarcZX10 commented 2026-10-22 01:58:11 +00:00 (Migrated from github.com)

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


The size creation and activation paths are narrowly scoped and have strong native-reference lifecycle coverage. The PR declares its #9437 and FreeType insertion-order dependencies, and the hosted eligibility, intake, labels and report checks pass. The convention check and product/relinker builds are still pending/skipped; I did not run local tests.

I’m requesting changes for one destruction-path issue in the submitted head:

FT_Done_FreeType destroys a face by calling FT_List_Finalize on face->sizes_list. That routine saves cur->next, invokes the size destructor, then proceeds to the saved node. In FinalizeSize, the adapter calls SyncSizePointer_nid_no_patch, which searches face.sizes for host->face->size and throws if it cannot find it. This makes library teardown depend on whether the active native size is still represented in the guest list at each callback. Please add a regression that forces library teardown with several guest sizes and the active size positioned so its guest owner is removed before later size callbacks, and make the callback/teardown path tolerate FreeType's list-finalization order while keeping every callback's guest size record valid. Also verify callbacks still see the expected active-size pointer and metrics where that state is available.

This is based on the bundled FreeType 2.13.3 destroy_face/FT_List_Finalize order and the current callback's lookup/throw behavior; I have not run a local reproduction. Please report the focused test and rerun convention checks after fixing it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330838723 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550#issuecomment-6330838723). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:58:11Z. --- The size creation and activation paths are narrowly scoped and have strong native-reference lifecycle coverage. The PR declares its #9437 and FreeType insertion-order dependencies, and the hosted eligibility, intake, labels and report checks pass. The convention check and product/relinker builds are still pending/skipped; I did not run local tests. I’m requesting changes for one destruction-path issue in the submitted head: `FT_Done_FreeType` destroys a face by calling `FT_List_Finalize` on `face->sizes_list`. That routine saves `cur->next`, invokes the size destructor, then proceeds to the saved node. In `FinalizeSize`, the adapter calls `SyncSizePointer_nid_no_patch`, which searches `face.sizes` for `host->face->size` and throws if it cannot find it. This makes library teardown depend on whether the active native size is still represented in the guest list at each callback. Please add a regression that forces library teardown with several guest sizes and the active size positioned so its guest owner is removed before later size callbacks, and make the callback/teardown path tolerate FreeType's list-finalization order while keeping every callback's guest size record valid. Also verify callbacks still see the expected active-size pointer and metrics where that state is available. This is based on the bundled FreeType 2.13.3 `destroy_face`/`FT_List_Finalize` order and the current callback's lookup/throw behavior; I have not run a local reproduction. Please report the focused test and rerun convention checks after fixing it.
Ondra97 commented 2026-10-22 02:48:33 +00:00 (Migrated from github.com)

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


I opened #9574 for FT_Cos, FT_Sin, FT_Tan, FT_Vector_Unit and FT_Angle_Diff. I declared #9550 for merge order because both patches add different FreeType API includes in GuestFreeType.cpp; its declared chain covers the earlier include insertions. Retain both FT_SIZES_H and FT_TRIGONOMETRY_H. The implementations are independent.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6331465068 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550#issuecomment-6331465068). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T02:48:33Z. --- I opened #9574 for FT_Cos, FT_Sin, FT_Tan, FT_Vector_Unit and FT_Angle_Diff. I declared #9550 for merge order because both patches add different FreeType API includes in GuestFreeType.cpp; its declared chain covers the earlier include insertions. Retain both FT_SIZES_H and FT_TRIGONOMETRY_H. The implementations are independent.
MarcZX10 commented 2026-10-22 11:27:41 +00:00 (Migrated from github.com)

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


The new teardown-order regression in the description addresses the earlier review concern: the finalizer cases now check each owned guest size record, active pointer and metrics while earlier sizes are finalized. The reported full Windows build and focused native comparisons are detailed. I checked current upstream/main: diff-check and conventions pass, and the merge is clean. This head is 7 ahead/16 behind current main 4777caca34 (merge base d6732b51a); the reported full build used that older base. Please update from current main, rerun the focused FreeType tests/checks on the resulting head, and refresh the Tested commit. Preserve the declared #9437/#8286/#9329/#9545 dependency and #9574 insertion order. I did not run local C++ tests because the root filesystem is full; hosted product/relinker jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339614395 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550#issuecomment-6339614395). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:27:41Z. --- The new teardown-order regression in the description addresses the earlier review concern: the finalizer cases now check each owned guest size record, active pointer and metrics while earlier sizes are finalized. The reported full Windows build and focused native comparisons are detailed. I checked current upstream/main: diff-check and conventions pass, and the merge is clean. This head is 7 ahead/16 behind current main 4777caca34 (merge base d6732b51a); the reported full build used that older base. Please update from current main, rerun the focused FreeType tests/checks on the resulting head, and refresh the Tested commit. Preserve the declared #9437/#8286/#9329/#9545 dependency and #9574 insertion order. I did not run local C++ tests because the root filesystem is full; hosted product/relinker jobs are skipped.
MarcZX10 commented 2026-10-22 11:27:42 +00:00 (Migrated from github.com)

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

Review: DISMISSED


The updated implementation and test description appear to resolve my earlier finalizer-order concern. I am retaining changes requested only for current-main freshness: this head is 7 ahead/16 behind upstream/main 4777caca34 (merge base d6732b51a), so update and rerun the focused FreeType suite and convention/overlap checks on the resulting head. The merge is clean and conventions pass on the present head. Keep the declared prerequisite chain (#9437, #8286, #9329, #9545) and #9574 insertion order intact. I did not run tests locally; the filesystem is full.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5613431340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9550#pullrequestreview-5613431340). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:27:42Z. **Review:** DISMISSED --- The updated implementation and test description appear to resolve my earlier finalizer-order concern. I am retaining changes requested only for current-main freshness: this head is 7 ahead/16 behind upstream/main 4777caca34 (merge base d6732b51a), so update and rerun the focused FreeType suite and convention/overlap checks on the resulting head. The merge is clean and conventions pass on the present head. Keep the declared prerequisite chain (#9437, #8286, #9329, #9545) and #9574 insertion order intact. 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!9550
No description provided.