feat(libSceFreeType): implement FT_Atan2 and the FT_Vector polar calls #10600

Merged
MarcZX10 merged 19 commits from upstream-pr/10600 into main 2026-11-06 09:43:58 +00:00
MarcZX10 commented 2026-10-24 12:00:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T12:00:24Z.


What

Adds FT_Atan2, FT_Vector_Length, FT_Vector_Rotate, FT_Vector_Polarize and FT_Vector_From_Polar to libSceFreeType, following the bundled FreeType 2.13.3 (fttrigon.c). The guest passes 64-bit FT_Fixed, FT_Angle and vector fields; each adapter converts them to the host types and runs the native CORDIC code, so results for values that fit the host type are identical to the native ones. A guest value outside the host FT_Fixed range throws, which only matters where the native type is 32 bits (Windows). FT_Vector_Polarize writes its outputs only when the native call does (not for a null argument or the zero vector); null vectors are accepted as in the native API. Console signatures are unverified; the debt entries say so.

This is separate from #9574, which adds FT_Sin, FT_Cos, FT_Tan, FT_Angle_Diff and FT_Vector_Unit; no function overlaps.

Commits: for each function in turn, in the order above, the implementation, its test and its debt entry.

Tested

Linux x86-64, GCC, full CMake build (Ninja, Release). guest_freetype_vector_polar compares each adapter with the native function over grids of coordinates (zero, one, negatives, 64, 16.16 units, arbitrary values and INT32_MAX) and, for the rotation and polar-to-vector calls, angles from 0 to 725 degrees and negative angles, plus null arguments and the zero vector. An earlier version of the polarize adapter wrote zeros for the zero vector where the native call leaves its outputs untouched; the test caught it and it is fixed. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran the test at each of the five stages with that check disabled in a local, uncommitted edit; all exit 0. Windows was not run. tools/check_conventions.py and git diff --check pass. No title or GPU involved.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4995199447 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10600). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T12:00:24Z. --- ### What Adds `FT_Atan2`, `FT_Vector_Length`, `FT_Vector_Rotate`, `FT_Vector_Polarize` and `FT_Vector_From_Polar` to libSceFreeType, following the bundled FreeType 2.13.3 ([fttrigon.c](https://github.com/freetype/freetype/blob/42608f77f20749dd6ddc9e0536788eaad70ea4b5/src/base/fttrigon.c)). The guest passes 64-bit `FT_Fixed`, `FT_Angle` and vector fields; each adapter converts them to the host types and runs the native CORDIC code, so results for values that fit the host type are identical to the native ones. A guest value outside the host `FT_Fixed` range throws, which only matters where the native type is 32 bits (Windows). `FT_Vector_Polarize` writes its outputs only when the native call does (not for a null argument or the zero vector); null vectors are accepted as in the native API. Console signatures are unverified; the debt entries say so. This is separate from #9574, which adds `FT_Sin`, `FT_Cos`, `FT_Tan`, `FT_Angle_Diff` and `FT_Vector_Unit`; no function overlaps. Commits: for each function in turn, in the order above, the implementation, its test and its debt entry. ### Tested Linux x86-64, GCC, full CMake build (Ninja, Release). `guest_freetype_vector_polar` compares each adapter with the native function over grids of coordinates (zero, one, negatives, 64, 16.16 units, arbitrary values and `INT32_MAX`) and, for the rotation and polar-to-vector calls, angles from 0 to 725 degrees and negative angles, plus null arguments and the zero vector. An earlier version of the polarize adapter wrote zeros for the zero vector where the native call leaves its outputs untouched; the test caught it and it is fixed. The host CPU (Xeon E5-1620 v2) fails the startup CPU-feature gate, so I ran the test at each of the five stages with that check disabled in a local, uncommitted edit; all exit 0. Windows was not run. `tools/check_conventions.py` and `git diff --check` pass. No title or GPU involved. ### Checklist - [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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!10600
No description provided.