feat(libSceFreeType): implement fixed-point arithmetic #9410

Merged
Felipebmaitan merged 10 commits from upstream-pr/9410 into main 2026-11-20 19:59:21 +00:00
Felipebmaitan commented 2026-10-21 21:04:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Felipebmaitan on 2026-10-21T21:04:54Z.


What

Implements the six signed 64-bit guest exports FT_MulDiv, FT_MulFix, FT_DivFix, FT_RoundFix, FT_CeilFix and FT_FloorFix. The guest uses the existing LP64 adapter ABI on Linux and Windows. FT_MulDiv and FT_DivFix wrap their unsigned intermediates at 64 bits and return a signed 0x7fffffff on division by zero. FT_MulFix narrows both inputs and its result to signed 32 bits. The remaining functions round halfway away from zero, toward positive infinity or toward negative infinity, respectively. FreeType 2.13.3 arithmetic · x86-64 helper

Export NID
FT_MulDiv Q+ysHCIzphI
FT_MulFix 774ZHX0Z3Cc
FT_DivFix fp-jO+c8Rfk
FT_RoundFix IdtpBr-PoD0
FT_CeilFix 92e4jZiW9Tc
FT_FloorFix EqN+ED6P2FA

The NIDs follow the PS5 3.20 inventory. Console signatures, build options and wider-input results remain unverified and are recorded in the FreeType debt fragment. PS5 3.20 inventory

Integrated published head ed1945bc86b5332f1b53c36017bf07a691695bc3 and current main at e481b135558fc4316bc3b24e7408156737eff08d through merge commits. The regression test now models bundled FreeType 2.15.0's wrapped 64-bit product and rounding addition for the native LP64 FT_MulFix assertion. The same strict native assertion applies to system FreeType because current main requires version 2.15 or newer. Every guest value is checked against the existing guest oracle. FreeType 2.15.0 helper

The six-name scan found #16823 in libSceFreeTypeOt. That PR declares #9410 as its prerequisite. The #9848 candidate at 2590e6f55418484bd104ee772644256a3ea1bea4 combines cleanly with this branch and preserves both test registrations and debt fragments.

Tested

Validation for 29c150a49a1469cb271d5da023b5640c6b0d6744 used at most two compiler jobs.

  • Linux x86-64, Debian 12 container, GCC 14.2, Release. Full-project CMake configured with the bundled dependencies and the release package for the pinned FFmpeg revision. The stock guest_freetype_arithmetic CTest passed in 2.07 s. The prior test reproduced juanpimg's Nov 9 INT64_MIN mismatch against the same executable. The corrected test passed 470,982 triples and 2,825,892 results each for guest and native LP64 FreeType.
  • Windows x86-64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release. The full-project configuration built the 12 selected FreeType test executables with the bundled dependencies. All 12 verbose CTests passed in 3.71 s with zero skips. Arithmetic covered all 470,982 triples and 2,825,892 guest results.
  • Scoped production packaging on both hosts. Applied the repository's NID patcher and libc export-preservation list to the CMake-built libSceFreeType, libkernel and libc. Each smoke run loaded all three modules with zero failures. All six raw arithmetic NIDs passed 2,825,892 guest comparisons per host. The packaged Linux harness also passed 2,825,892 native LP64 comparisons.
  • Additional evidence. The Linux x86-64 UBSan source harness passed the same guest and native counts. Substituting current native multiplication into the guest column triggered the guest assertion. Source-level guest arithmetic and arithmetic-only raw NID runs also passed on Windows. Public-header audit passed for 413 libraries and 34,762 exports. Conventions, debt-fragment validation, whitespace and the six-name overlap scan passed.
  • Independent review. One reviewer checked the integrated arithmetic range, assertions and build registration. The review identified an unnecessary fallback for pre-2.15 system FreeType. That fallback was removed and the focused tests above ran with the strict oracle.
  • Prior contributor reports. JJenkx's Windows run covered the previous PR head merged onto 9fb2d9bb83. juanpimg's Linux failure was on the previous head merged onto d792f1ad5f. The final-head runs above were executed separately.

Full hosted Linux and Windows builds require collaborator dispatch. Console and title behavior remain unverified.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4958343673 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9410). Originally posted by [Felipebmaitan](https://github.com/Felipebmaitan) on 2026-10-21T21:04:54Z. --- ### What Implements the six signed 64-bit guest exports `FT_MulDiv`, `FT_MulFix`, `FT_DivFix`, `FT_RoundFix`, `FT_CeilFix` and `FT_FloorFix`. The guest uses the existing LP64 adapter ABI on Linux and Windows. `FT_MulDiv` and `FT_DivFix` wrap their unsigned intermediates at 64 bits and return a signed `0x7fffffff` on division by zero. `FT_MulFix` narrows both inputs and its result to signed 32 bits. The remaining functions round halfway away from zero, toward positive infinity or toward negative infinity, respectively. [FreeType 2.13.3 arithmetic](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/ftcalc.c) · [x86-64 helper](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/include/freetype/internal/ftcalc.h#L180) | Export | NID | | --- | --- | | FT_MulDiv | Q+ysHCIzphI | | FT_MulFix | 774ZHX0Z3Cc | | FT_DivFix | fp-jO+c8Rfk | | FT_RoundFix | IdtpBr-PoD0 | | FT_CeilFix | 92e4jZiW9Tc | | FT_FloorFix | EqN+ED6P2FA | The NIDs follow the PS5 3.20 inventory. Console signatures, build options and wider-input results remain unverified and are recorded in the FreeType debt fragment. [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c) Integrated published head `ed1945bc86b5332f1b53c36017bf07a691695bc3` and current `main` at `e481b135558fc4316bc3b24e7408156737eff08d` through merge commits. The regression test now models bundled FreeType 2.15.0's wrapped 64-bit product and rounding addition for the native LP64 `FT_MulFix` assertion. The same strict native assertion applies to system FreeType because current `main` requires version 2.15 or newer. Every guest value is checked against the existing guest oracle. [FreeType 2.15.0 helper](https://github.com/freetype/freetype/blob/37515cf56ba3349656049edbed89ffc6f6466f2d/include/freetype/internal/ftcalc.h#L94) The six-name scan found #16823 in `libSceFreeTypeOt`. That PR declares #9410 as its prerequisite. The #9848 candidate at `2590e6f55418484bd104ee772644256a3ea1bea4` combines cleanly with this branch and preserves both test registrations and debt fragments. ### 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. --> Validation for `29c150a49a1469cb271d5da023b5640c6b0d6744` used at most two compiler jobs. - **Linux x86-64, Debian 12 container, GCC 14.2, Release.** Full-project CMake configured with the bundled dependencies and the release package for the pinned FFmpeg revision. The stock `guest_freetype_arithmetic` CTest passed in 2.07 s. The prior test reproduced juanpimg's Nov 9 `INT64_MIN` mismatch against the same executable. The corrected test passed 470,982 triples and 2,825,892 results each for guest and native LP64 FreeType. - **Windows x86-64, WinLibs MinGW-w64 GCC 15.2.0 r7, Release.** The full-project configuration built the 12 selected FreeType test executables with the bundled dependencies. All 12 verbose CTests passed in 3.71 s with zero skips. Arithmetic covered all 470,982 triples and 2,825,892 guest results. - **Scoped production packaging on both hosts.** Applied the repository's NID patcher and libc export-preservation list to the CMake-built `libSceFreeType`, `libkernel` and `libc`. Each smoke run loaded all three modules with zero failures. All six raw arithmetic NIDs passed 2,825,892 guest comparisons per host. The packaged Linux harness also passed 2,825,892 native LP64 comparisons. - **Additional evidence.** The Linux x86-64 UBSan source harness passed the same guest and native counts. Substituting current native multiplication into the guest column triggered the guest assertion. Source-level guest arithmetic and arithmetic-only raw NID runs also passed on Windows. Public-header audit passed for 413 libraries and 34,762 exports. Conventions, debt-fragment validation, whitespace and the six-name overlap scan passed. - **Independent review.** One reviewer checked the integrated arithmetic range, assertions and build registration. The review identified an unnecessary fallback for pre-2.15 system FreeType. That fallback was removed and the focused tests above ran with the strict oracle. - **Prior contributor reports.** JJenkx's Windows run covered the previous PR head merged onto `9fb2d9bb83`. juanpimg's Linux failure was on the previous head merged onto `d792f1ad5f`. The final-head runs above were executed separately. Full hosted Linux and Windows builds require collaborator dispatch. Console and title behavior remain unverified. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
ycbuzi commented 2026-10-21 22:41:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T22:41:42Z.


Windows run of 5bf11d7a86 merged onto main a6dcea9279 (ec2f82dee0, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceFreeType and guest_freetype_arithmetic_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_freetype_arithmetic: passes on both repeats. That test runs test_guest_freetype_arithmetic.py against the executable. Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328163230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9410#issuecomment-6328163230). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T22:41:42Z. --- Windows run of 5bf11d7a86 merged onto `main` a6dcea9279 (ec2f82dee0, clean), the platform the description lists as not tested. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceFreeType` and `guest_freetype_arithmetic_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_freetype_arithmetic`: passes on both repeats. That test runs `test_guest_freetype_arithmetic.py` against the executable. Not run: a title.
MarcZX10 commented 2026-10-22 05:10:16 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


The arithmetic implementation and regression coverage are detailed. I independently compiled the exact added Arithmetic.cpp with C++20, -Wall -Wextra -Werror, then ran the PR's Python oracle against a small harness: 470,982 input triples and 2,825,892 guest results matched. I repeated that run under UBSan with no diagnostics. This was a source-level harness, not the packaged library/CMake integration test or a Windows/PS5 run. I also searched the live open PR queue for all six exports; no duplicate implementation is open. The newer FreeType trigonometry PR #9574 changes different exports and its merge with this branch is clean.

The remaining blocking repository-rule issue is freshness: this head's merge base is 0c6a5bd5938f, 423 commits behind current main (da54c652e30b), while the checklist says it is based on current main. Please rebase on current main, refresh the conventions and overlap checks, and rerun the focused FreeType/package tests on the rebased head. The existing Linux/Windows reports are useful evidence for this head, but do not validate a rebase onto today's tree. The hosted product jobs are skipped on this PR, as expected from the current workflow policy.

AI assistance was used to prepare this review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609528365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9410#pullrequestreview-5609528365). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T05:10:16Z. **Review:** CHANGES_REQUESTED --- The arithmetic implementation and regression coverage are detailed. I independently compiled the exact added `Arithmetic.cpp` with C++20, `-Wall -Wextra -Werror`, then ran the PR's Python oracle against a small harness: 470,982 input triples and 2,825,892 guest results matched. I repeated that run under UBSan with no diagnostics. This was a source-level harness, not the packaged library/CMake integration test or a Windows/PS5 run. I also searched the live open PR queue for all six exports; no duplicate implementation is open. The newer FreeType trigonometry PR #9574 changes different exports and its merge with this branch is clean. The remaining blocking repository-rule issue is freshness: this head's merge base is `0c6a5bd5938f`, 423 commits behind current `main` (`da54c652e30b`), while the checklist says it is based on current main. Please rebase on current `main`, refresh the conventions and overlap checks, and rerun the focused FreeType/package tests on the rebased head. The existing Linux/Windows reports are useful evidence for this head, but do not validate a rebase onto today's tree. The hosted product jobs are skipped on this PR, as expected from the current workflow policy. AI assistance was used to prepare this review.
MarcZX10 commented 2026-11-20 19:44:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T19:44:55Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the author has no required follow-up.

What I ran

Reviewed head 29c150a49a1469cb271d5da023b5640c6b0d6744. I did not run commands; repo_read.py was unavailable through the provided tools. The PR description reports Linux and Windows test runs, but I did not independently verify them.

Results

Check Result Note
Source review passed All six changed files read
Automated checks not run Author-reported runs only
Console behavior not run Described as unverified

Findings

Blocking

None.

Non-blocking

None.

Not verified

No changed files were excluded: the manifest lists six changed files, all included, and I read each one. Automated test results and console behavior were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5998427690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9410#pullrequestreview-5998427690). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T19:44:55Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the author has no required follow-up. ## What I ran Reviewed head `29c150a49a1469cb271d5da023b5640c6b0d6744`. I did not run commands; `repo_read.py` was unavailable through the provided tools. The PR description reports Linux and Windows test runs, but I did not independently verify them. ## Results | Check | Result | Note | |---|---|---| | Source review | passed | All six changed files read | | Automated checks | not run | Author-reported runs only | | Console behavior | not run | Described as unverified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No changed files were excluded: the manifest lists six changed files, all included, and I read each one. Automated test results and console behavior were not independently verified. ## To get this to a good state Nothing is required.
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!9410
No description provided.