feat(libSceFreeType): expose LP64 trigonometry #9574
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9574"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T02:48:02Z.
What
Add five fixed-point angle exports through the LP64 guest interface:
FT_CosyD4-QaNSinkFT_SinL1uHkWTazkIFT_TandojyaLKzKN0FT_Vector_Unit3WpTQrvGUcUFT_Angle_DiffD1l8+Bu+-Y8Preserve all 64 input bits by reducing angles modulo a full 16.16-degree turn before calling native cosine, sine and unit-vector routines. This gives the same quarter-turn sequence and residual CORDIC angle as the bundled implementation. Unit vectors write both complete eight-byte guest components; null outputs retain the native no-op behavior.
A direct Windows
FT_Tancall loses the high quotient bits near its poles. At raw angle5898240(90 degrees), the bundled source compiled with LP64 types produces-640155090944, while native Windows FreeType returns-204963840. Use the bundled CORDIC steps and constants with a 64-bit rounded quotient, retaining the full fixed-point result. These are source-version results, not ideal real-number trigonometry.Angle differences retain the native (-180, 180] interval without iterating through huge turn counts. Throw when the original signed 64-bit subtraction would overflow; the bundled source's behavior there is undefined. Console ABI, FreeType version and CORDIC equivalence remain unverified and are recorded in library debt.
Names/NIDs match the pinned PS5 3.20 inventory. Contracts and integer behavior follow bundled FreeType 2.13.3 fttrigon.c, ftcalc.c and fttrigon.h.
Merge after #9550 and #9560 for shared CMake, include, prototype, helper, test-call and debt insertions. Their declared chains cover the other reported insertion overlaps; implementations are independent and no open PR adds these five exports. Retain each source entry, declaration and test when resolving those insertions. No title unblock or performance improvement is claimed.
Tested
Rebased on upstream main
4997726a5f6b8cd263461508945a4676647ef482; tested headb393ef93cc1c830897a83c833b41a445b439a055. Windows 11 Pro 10.0.26300, WinLibs MinGW-w64 GCC 15.2.0 UCRT, Ninja, Release,BUILD_TESTING=ON, bundled dependencies. CPU: AMD Ryzen 9 7900X; RAM: 32 GB; GPU: NVIDIA GeForce RTX 4070 Ti SUPER. Font rendering uses the CPU.cmake --build ../build --target relinker libs guest_freetype_tests guest_freetype_charmap_tests guest_freetype_names_tests guest_freetype_sfnt_names_tests guest_freetype_request_size_tests patched_libraries_tests guest_font_tests guest_system_font_tests guest_font_writing_line_tests font_face_lifetime_tests guest_freetype_outline_tests guest_freetype_charmap_info_tests guest_freetype_outline_mutations_tests guest_freetype_face_info_tests guest_freetype_list_tests --parallel 8: production relinker, all patched libraries and selected runtime fixtures built successfully with no overlay.ctest --test-dir ../build -R '^(guest_freetype.*|guest_.*font.*|font_.*|patched_libraries)$' -V: 17/17 passed, no skips, 1.15 s total; 368 patched libraries loaded, 0 failed.python tools/check_conventions.py --base origin/main,python tools/check_main_sync.py --base origin/main --strict,git diff origin/main...HEAD --check: passed. The existing runtime fixtures remain registered and executed.python tools/pr_overlap.py --branch codex/pr9574-rebase-20261023c --repo boykopovar/AnyPS5 --jobs 8: reviewed. The existing #9550/#9560 dependencies cover shared CMake, header, prototype, helper, call and debt insertions, including their #9545 and #9519/#9465 chains. #9588 adds independent glyph records and #9848 changes platform export handling. Same-NID reports in #9453/#9462/#9922 are throwing stubs in separate FreeTypeOl/FreeTypeOt libraries; the old #9574 head is the expected self-match. Trigonometry.cpp and the native-width test correction remain unchanged.The original missing-feature baseline lacks the guest exports required by this regression. The 68 tangent goldens come from the bundled CORDIC/division source compiled with int64_t LP64 aliases; the earlier narrowing negative control was not repeated for this rebase. Console compatibility and title-level impact remain unverified; this rebase adds Windows host runtime validation only.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T03:31:33Z.
I opened #9588 for FT_Glyph_Get_CBox. I declared #9574 for merge order because the new query and its ownership dependency share debt/guest-record insertions with the existing FreeType chain. Retain the distinct glyph records, trigonometry/decomposition support and debt entries.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:51:48Z.
Review: APPROVED
Reviewed the five export implementations and the regression coverage against the pinned FreeType 2.13.3 trigonometry implementation. The full-width angle normalization, guest 64-bit output writes, CORDIC tangent path and overflow handling for the angle subtraction are consistent with the stated LP64 contract. The tests cover randomized and boundary angles, pole goldens, guard bytes, null output, glyph rendering and explicit negative controls; the report clearly limits its ABI evidence to the compiled LP64 model and Windows runtime.
The declared #9550 and #9560 merge order is explicit, and both prerequisites remain open and mergeable. Hosted eligibility, intake, labels, report and conventions checks pass. The hosted product-build jobs are skipped; I relied on the detailed author-reported local tests and did not treat those jobs as executed. No PS5 hardware or title runtime is claimed.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T04:53:37Z.
Review: COMMENTED
On Linux
guest_freetypefails with this PR. The new pole-tangent loop assumes the hostFT_Tanis the 32-bit (LLP64) one.Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release (and an ASan build of the same target). Head
11957acbamerged--no-commitontomain17f533556(clean).guest_freetypeaborts withFreeType check failed at line 174, in both Release and ASan:This asserts that the host FreeType gets these poles wrong. That is true on Windows, where
FT_Fixedis a 32-bitlong. On Linux, and on macOS,longis 64-bit, so the bundled FreeType gives the same values as the guest table. Built against the same3rdparty/freetype:sizeof(FT_Fixed) = 8,FT_Tan(5898239) = 640155090944,FT_Tan(5898240) = -640155090944,FT_Tan(17694720) = -640155090944. Those are exactly thepoleTangentsentries, so the inequality fails.With that line guarded as
if (sizeof(FT_Fixed) == 4) Require(...), and nothing else changed,guest_freetypeandguest_freetype_charmappass in Release, andguest_freetypepasses under ASan (detect_leaks=1). So the implementation side is fine on Linux, and only the host-difference assertion needs to be limited to LLP64 hosts (or dropped).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:09:18Z.
Review: COMMENTED
Re-ran on Linux after
68a5a7093(pole check split bysizeof(FT_Fixed)).Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release. Head
8aa308c7bmerged--no-commitontomaind6eafa54d(clean).guest_freetypeandguest_freetype_charmappass, 3 of 3 runs:4226 scalar cases, 4226 vectors, 1764 angle differences, 68 LP64 tangent goldens, 10 rendered glyphs. The newelsebranch holds here (sizeof(FT_Fixed) == 8, hostFT_Tanequals the goldens).(x >> 1)rounding term inFT_Tan_nid_postfixaborts at line 173.FT_Tan_nid_postfixforwarding to the nativeFT_Tan(NormalizeAngle(angle))also passes the whole test, so the custom tangent path only differs from the host one on LLP64 (Windows).Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T10:53:43Z.
Review: DISMISSED
Re-reviewed the test-only update at head
8aa308c7becd831013b02b5cf1b23de61aa77314. Thesizeof(FT_Fixed)split correctly expects the Windows LLP64 host to differ from the 64-bit guest tangent table while requiring the Linux LP64 host to match it. The independent Linux reviewer reports both focused FreeType tests pass 3/3 on this head and confirms the CORDIC rounding negative control still fails. Conventions anddiff --checkpass against currentupstream/main; the exact-head Windows build/test report is author-provided, and hosted product jobs are skipped. One repository requirement remains.check_main_sync.pyreports 5 ahead / 58 behind currentmain(merge base4a17c7175); please refresh the branch and repeat the focused verification. The declared #9550/#9560 sequence is clear, and I found no new implementation issue in this test correction.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:13:18Z.
Correction to my 10:53 review: I withdraw the intake/queue objection. Your contribution-count eligibility means no title unblock or intake exception is required for this generic addition.
The current-base request remains. Exact head
8aa308c7becd831013b02b5cf1b23de61aa77314is based on4a17c71757644170c6a0acfcc67fb17f81cff93f, 101 commits behind currentupstream/main8b3e39832af85f404c6195418d11b3e1ebd1924d.git diff --check, current-main conventions, and merge-tree pass, with no merge conflict. The Windows full build and 3/3 focused tests are author-reported; the independent Linux run reports both focused tests passing 3/3 and the tangent negative control still failing as intended. Those runs are on this exact head but its older base. Please merge/rebase the latest main and rerun the focused FreeType tests/checks before merge. I found no new implementation issue in this pass; the declared #9550/#9560 integration order remains clear.