feat(libSceFreeType): implement outline orientation #9538

Merged
Ondra97 merged 3 commits from upstream-pr/9538 into main 2026-10-23 03:43:07 +00:00
Ondra97 commented 2026-10-22 00:49:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T00:49:59Z.


What

Implement FT_Outline_Get_Orientation (weVsBCT+TTQ) for the existing LP64 guest outline. Compute the bounding box, apply the bundled FreeType coordinate limits and normalization shifts, and integrate the control-point polygons with a signed 64-bit area accumulator. The query leaves points, tags, contours, flags and descriptor pointers unchanged.

The name/NID matches the pinned PS5 3.20 inventory. Behavior follows bundled FreeType 2.13.3 ftoutln.c and the bridge's existing 64-bit coordinates and unsigned counts. Console ABI/version and large-outline equivalence remain unverified and are recorded in debt.

Delegating directly to the Windows native routine would use its 32-bit FT_Pos area: two equally oriented 32767-by-32767 rectangles produce a negative wrapped sum there, while the LP64 sum is positive. The adapter preserves the LP64 result. After the reference normalization, each edge contribution is bounded by 2^31; at most 65,535 points fit comfortably in the 64-bit accumulator. Valid outline arrays and contour indices remain the caller's precondition, as in native FreeType.

Merge after #9530 for the shared include/debt insertions; #9530 already declares #9309. These are merge-order dependencies, not shared implementations or runtime requirements. No title unblock or performance improvement is claimed.

Tested

Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering is on the CPU; GPUs tested: n/a.

Base: a6dcea9279b53b3a39c13695eac66f7c8b5b503c. Head: 29eab421d93bf3383b7385940d9f5e21e731867b.

  • The new behavioral regression cannot link against unchanged base because the guest orientation export is absent. This is a missing-feature baseline, not an observed game failure.
  • cmake --build build --parallel 10: full all-target integration build passed with the previously reviewed temporary test-only #8310 source at ca55e46f98ad85861dd7567abad0c028274daca1. That source was restored byte-for-byte and is excluded from this PR. This is an overlay-qualified build, not a standalone clean-main all-target pass.
  • After restoration, cmake --build build --target libs guest_freetype_tests guest_freetype_charmap_tests patched_libraries_tests --parallel 8: passed with submitted sources.
  • ctest --test-dir build -R '^(guest_freetype(_charmap)?|patched_libraries)$' -V: 3/3 passed, no skips, 0.26 s. 360 patched libraries loaded, 0 failed.
  • The existing guest_freetype test now checks 1,555 polygon cases, null/empty/degenerate inputs, holes and cancellation between contours, reversal/translation properties, coordinate-limit boundaries, normalization collapse, 64-bit extreme coordinates, 65,535 points and 65,535 contours, descriptor/input preservation, and 2 subsequently rendered glyphs with matching native bitmap pixels and bearings.
  • Native FreeType comparisons cover cases where its host-width arithmetic is applicable. Small random polygons also use an independent classic shoelace-area oracle. LP64 overflow cases use known geometric results; the regression confirms the different native Windows result for the two-rectangle case. No native LP64 execution is claimed.
  • Packaged NID weVsBCT+TTQ is present.
  • Strict g++ -std=c++20 -Wall -Wextra -Werror -fno-asynchronous-unwind-tables -fsyntax-only -Icore/libs -I3rdparty/freetype/include core/libs/prx/libSceFreeType/Export.cpp core/libs/tests/GuestFreeType.cpp: passed.
  • python tools/check_conventions.py --base origin/main, python tools/check_test_registration.py build and git diff origin/main HEAD --check: passed. Registration audit: 1,167 executables, none unregistered.

No title, PS5 hardware, Linux or macOS runtime 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: #9530
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4960372742 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T00:49:59Z. --- ### What Implement `FT_Outline_Get_Orientation` (`weVsBCT+TTQ`) for the existing LP64 guest outline. Compute the bounding box, apply the bundled FreeType coordinate limits and normalization shifts, and integrate the control-point polygons with a signed 64-bit area accumulator. The query leaves points, tags, contours, flags and descriptor pointers unchanged. The name/NID matches the pinned [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). Behavior follows bundled [FreeType 2.13.3 ftoutln.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftoutln.c) and the bridge's existing 64-bit coordinates and unsigned counts. Console ABI/version and large-outline equivalence remain unverified and are recorded in debt. Delegating directly to the Windows native routine would use its 32-bit `FT_Pos` area: two equally oriented 32767-by-32767 rectangles produce a negative wrapped sum there, while the LP64 sum is positive. The adapter preserves the LP64 result. After the reference normalization, each edge contribution is bounded by 2^31; at most 65,535 points fit comfortably in the 64-bit accumulator. Valid outline arrays and contour indices remain the caller's precondition, as in native FreeType. Merge after #9530 for the shared include/debt insertions; #9530 already declares #9309. These are merge-order dependencies, not shared implementations or runtime requirements. No title unblock or performance improvement is claimed. ### Tested Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT, Release, `BUILD_TESTING=ON`, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering is on the CPU; GPUs tested: n/a. Base: `a6dcea9279b53b3a39c13695eac66f7c8b5b503c`. Head: `29eab421d93bf3383b7385940d9f5e21e731867b`. - The new behavioral regression cannot link against unchanged base because the guest orientation export is absent. This is a missing-feature baseline, not an observed game failure. - `cmake --build build --parallel 10`: full all-target integration build passed with the previously reviewed temporary test-only #8310 source at `ca55e46f98ad85861dd7567abad0c028274daca1`. That source was restored byte-for-byte and is excluded from this PR. This is an overlay-qualified build, not a standalone clean-main all-target pass. - After restoration, `cmake --build build --target libs guest_freetype_tests guest_freetype_charmap_tests patched_libraries_tests --parallel 8`: passed with submitted sources. - `ctest --test-dir build -R '^(guest_freetype(_charmap)?|patched_libraries)$' -V`: **3/3 passed, no skips**, 0.26 s. **360 patched libraries loaded, 0 failed**. - The existing `guest_freetype` test now checks **1,555 polygon cases**, null/empty/degenerate inputs, holes and cancellation between contours, reversal/translation properties, coordinate-limit boundaries, normalization collapse, 64-bit extreme coordinates, 65,535 points and 65,535 contours, descriptor/input preservation, and **2 subsequently rendered glyphs** with matching native bitmap pixels and bearings. - Native FreeType comparisons cover cases where its host-width arithmetic is applicable. Small random polygons also use an independent classic shoelace-area oracle. LP64 overflow cases use known geometric results; the regression confirms the different native Windows result for the two-rectangle case. No native LP64 execution is claimed. - Packaged NID `weVsBCT+TTQ` is present. - Strict `g++ -std=c++20 -Wall -Wextra -Werror -fno-asynchronous-unwind-tables -fsyntax-only -Icore/libs -I3rdparty/freetype/include core/libs/prx/libSceFreeType/Export.cpp core/libs/tests/GuestFreeType.cpp`: passed. - `python tools/check_conventions.py --base origin/main`, `python tools/check_test_registration.py build` and `git diff origin/main HEAD --check`: passed. Registration audit: 1,167 executables, none unregistered. No title, PS5 hardware, Linux or macOS runtime was tested. <!-- 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: #9530 <!-- #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 00:55:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T00:55:21Z.

Review: APPROVED


Reviewed the adapter against the pinned FreeType 2.13.3 implementation and the current GuestOutline representation. The collapsed/large-coordinate guards, independent x/y normalization shifts, contour closure, winding-sign mapping and degenerate result match the source algorithm; using a 64-bit accumulator addresses the LP64 result the PR documents. The expanded tests cover native-comparable inputs, geometry properties, contour cancellation, coordinate limits and rendered glyph output without mutating the guest outline.

The PR reports 1,555 polygon cases, two rendered-glyph comparisons, a strict syntax check, the focused 3/3 CTest selection and a 360-library patching check. Those runs are author-reported; I did not rerun a local build. Hosted eligibility, conventions, intake, labels and report checks pass; product jobs are skipped. The #9530 overlap is explicitly ordered in Depends on, and its author confirmed this PR should land afterward.

Approved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608013341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538#pullrequestreview-5608013341). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T00:55:21Z. **Review:** APPROVED --- Reviewed the adapter against the pinned FreeType 2.13.3 implementation and the current `GuestOutline` representation. The collapsed/large-coordinate guards, independent x/y normalization shifts, contour closure, winding-sign mapping and degenerate result match the source algorithm; using a 64-bit accumulator addresses the LP64 result the PR documents. The expanded tests cover native-comparable inputs, geometry properties, contour cancellation, coordinate limits and rendered glyph output without mutating the guest outline. The PR reports 1,555 polygon cases, two rendered-glyph comparisons, a strict syntax check, the focused 3/3 CTest selection and a 360-library patching check. Those runs are author-reported; I did not rerun a local build. Hosted eligibility, conventions, intake, labels and report checks pass; product jobs are skipped. The #9530 overlap is explicitly ordered in `Depends on`, and its author confirmed this PR should land afterward. Approved.
Ondra97 commented 2026-10-22 01:16:03 +00:00 (Migrated from github.com)

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


I am preparing the three FT_Get_CID_* metadata queries as an independent follow-up. The shared insertions in Export.cpp and the debt file will go after #9538, which already orders #9530 and #9309. I will declare that merge-order dependency and rebase those insertions after this PR merges. No changes to this branch are needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330294299 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538#issuecomment-6330294299). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T01:16:03Z. --- I am preparing the three `FT_Get_CID_*` metadata queries as an independent follow-up. The shared insertions in Export.cpp and the debt file will go after #9538, which already orders #9530 and #9309. I will declare that merge-order dependency and rebase those insertions after this PR merges. No changes to this branch are needed.
MarcZX10 commented 2026-10-22 01:17:01 +00:00 (Migrated from github.com)

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

Review: APPROVED


Re-reviewed the current head after #9545 declared this PR as its shared-insertion predecessor. The author has updated the branch to current main, the stated order is represented in Depends on, and the existing review of the outline algorithm and tests remains applicable. Hosted eligibility, conventions, intake, labels and report checks pass; platform builds are skipped by path policy. The Windows tests are author-reported; I did not run a local build.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608155637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538#pullrequestreview-5608155637). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:17:01Z. **Review:** APPROVED --- Re-reviewed the current head after #9545 declared this PR as its shared-insertion predecessor. The author has updated the branch to current main, the stated order is represented in `Depends on`, and the existing review of the outline algorithm and tests remains applicable. Hosted eligibility, conventions, intake, labels and report checks pass; platform builds are skipped by path policy. The Windows tests are author-reported; I did not run a local build.
MarcZX10 commented 2026-10-22 01:59:42 +00:00 (Migrated from github.com)

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

Review: APPROVED


Rechecked the unchanged implementation and its #9530 merge-order prerequisite. The adapter follows bundled FreeType’s coordinate bounding and normalization logic while retaining the LP64 accumulator; the tests cover degenerate, nested, cancellation, boundary and large-coordinate outlines plus rendered glyphs. Eligibility, conventions, intake, labels and report checks pass; build jobs were skipped. I did not run local tests. Approval stands with #9530 first as declared.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608409245 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538#pullrequestreview-5608409245). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:59:42Z. **Review:** APPROVED --- Rechecked the unchanged implementation and its #9530 merge-order prerequisite. The adapter follows bundled FreeType’s coordinate bounding and normalization logic while retaining the LP64 accumulator; the tests cover degenerate, nested, cancellation, boundary and large-coordinate outlines plus rendered glyphs. Eligibility, conventions, intake, labels and report checks pass; build jobs were skipped. I did not run local tests. Approval stands with #9530 first as declared.
fogydes commented 2026-10-22 08:41:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:41:12Z.


Reviewed; verified the implementation against the pinned ftoutln.c orientation routine. Each branch is a faithful port: null/empty → TRUETYPE and the degenerate-bounds box check match the source's opening; the ±0x1000000 range gate is taken verbatim; the shift math is the source's FT_MSB(abs) - 14 recomputed as bit_width(|x|) - 15 (same exponent, sign-safe with the unsigned OR of the two absolute extremes); the (y - prevY) * (x + prevX) accumulation runs the same order and sign — so the result is POSTSCRIPT for a positive signed area, TRUETYPE for negative, NONE for zero, exactly as freetype maps it. The deliberate divergence the body documents (64-bit accumulator instead of a 32-bit FT_Pos wrap) is the right call on LP64 and is covered by the two-extreme-rectangle special case in the tests. Guest buffers stay untouched (const query, no adapter state), the debt entry links the pinned source and scopes the unverified console ABI part, and the tests cover degenerate outlines, boundary coordinates both inside and outside the range gate, the LP64 extemes, random polygons cross-checked against an independent shoelace oracle, and rendered glyphs with the x-reflection flipping orientation. Nothing invented anywhere in the answer space.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336550745 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9538#issuecomment-6336550745). Originally posted by [fogydes](https://github.com/fogydes) on 2026-10-22T08:41:12Z. --- Reviewed; verified the implementation against the pinned `ftoutln.c` orientation routine. Each branch is a faithful port: null/empty → `TRUETYPE` and the degenerate-bounds box check match the source's opening; the ±0x1000000 range gate is taken verbatim; the shift math is the source's `FT_MSB(abs) - 14` recomputed as `bit_width(|x|) - 15` (same exponent, sign-safe with the unsigned OR of the two absolute extremes); the `(y - prevY) * (x + prevX)` accumulation runs the same order and sign — so the result is `POSTSCRIPT` for a positive signed area, `TRUETYPE` for negative, `NONE` for zero, exactly as freetype maps it. The deliberate divergence the body documents (64-bit accumulator instead of a 32-bit `FT_Pos` wrap) is the right call on LP64 and is covered by the two-extreme-rectangle special case in the tests. Guest buffers stay untouched (const query, no adapter state), the debt entry links the pinned source and scopes the unverified console ABI part, and the tests cover degenerate outlines, boundary coordinates both inside and outside the range gate, the LP64 extemes, random polygons cross-checked against an independent shoelace oracle, and rendered glyphs with the x-reflection flipping orientation. Nothing invented anywhere in the answer space.
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!9538
No description provided.