feat(libSceFreeTypeOt): export the fixed-point arithmetic helpers #16823
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16823"
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 juanpimg on 2026-11-07T17:03:37Z.
What
Adds six
libSceFreeTypeOtexports:FT_MulDiv,FT_MulFix,FT_DivFix,FT_RoundFix,FT_CeilFixandFT_FloorFix, following the FreeType 2.4.12 arithmetic inftcalc.c. The console prototypes and FreeType version equivalence are unverified.The module links the bundled FreeType, whose own definitions own the plain
FT_*names, so the implementations use the library's resolved-name convention:<name>_nid_postfix, whichtools/nid_names.pyhashes to the inventory NID, with noAPS5_EXPORT. The suffix keeps them distinct from the bundled symbols, so there is no interposition and no linker flag.The three matrix and vector transform names this PR used to carry (
FT_Matrix_Multiply,FT_Matrix_Invert,FT_Vector_Transform) are now exported bylibSceFreeType(#9419), so they are removed here to keep one provider per NID. The six remaining names overlap with #9410, which implements them inlibSceFreeType; this PR is sequenced withDepends on: #9410. If #9410 lands first, this branch will be reduced toAPS5_DUMMY_FUNdeclarations or closed.Tested
CachyOS Linux, kernel 7.3.1-1-cachyos, GCC 16.2.1, CMake 3.31.6, Ninja 1.12.1, Release build, rebased onto current
main(d792f1ad5f).guest_freetype_corner,guest_freetype_ot_constants,guest_freetype_ot_memory,guest_freetype_ot_raccess: 4/4 pass, covering positive, negative, rounding, zero-divisor, overflow and boundary cases for the six functions.nid_patcherresolves all six names to their inventory NIDs (Q+ysHCIzphI,774ZHX0Z3Cc,fp-jO+c8Rfk,IdtpBr-PoD0,92e4jZiW9Tc,EqN+ED6P2FA) in the patchedlibSceFreeTypeOt.prx; the bundled plainFT_*symbols stay LOCAL.python3 tools/check_conventions.py --base origin/main: passes, with no cross-library duplicate.git diff --check: clean.Checklist
main; the only overlap is #9410 (same six arithmetic names inlibSceFreeType), sequenced withDepends on: #9410NotImplemented_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 coptergui-ops on 2026-11-07T18:56:26Z.
Review: CHANGES_REQUESTED
NID sourcing and arithmetic check out, the naming deviates from the convention this library itself set — please rework before merge.
Verified good:
sprx_dlsym("Q+ysHCIzphI", &__ptr_FT_MulDiv)etc., all nine name↔NID pairs match the PR exactly), andtools/nid_names.py --name FT_MulDiv …computes the same nine NIDs.(a + 0x8000 - (a<0)) & ~0xFFFF, ceil(a + 0xFFFF) & ~0xFFFF, floora & ~0xFFFFmatch ftcalc.c;FT_DivFix(a,b) = MulDiv(a, 0x10000, b);FT_Matrix_Invertis the delta = MulFix cross-product thenDivFixchain, null and singular return before writing, which the tests pin;Invalid_Argument = 6matches the same library's debt entry for the memory exports (Invalid_Argument 0x06).FT_MulDiv_No_Round, identity, rotation inverse, half scaling, singular/zero/null, and the null-pointer calls; andFT_Matrix_Multiply_Scaled(…, 1)/FT_Vector_Transform_Scaled(…, 1)equivalence holds under this library's own debt entry ("the scaled calls divide each term by 0x10000 * scaling").Findings:
_nid_postfixwith noAPS5_EXPORT— this library already does exactly that for implemented exports (ft_mem_qalloc_nid_postfixinsrc/Memory.cpp,FT_Trace_Get_Name_nid_postfixinExport.cpp), and implemented stubs with explicit aliases keep the resolved name plus_nid_no_patch(FT_Trace_Get_Name_nid_no_patchwithAPS5_EXPORT("64XMq6sDxUo", …)).FreetypeMulDivfollows neither form. The collision concern in the description does not apply to the convention name:FT_MulDiv_nid_postfixis a distinct symbol from bundled FreeType'sFT_MulDiv, so nothing is interposed. Use the resolved names with_nid_postfixand drop the explicit aliases.tools/check_conventions.pyflags it as a [debt-length] warning. State the gap first (NIDs present in the 3.20 inventory; prototypes, console ABI and version equivalence unverified) and keep only what the gap needs.FT_MulDiv,FT_MulFix,FT_DivFix,FT_RoundFix,FT_CeilFixandFT_FloorFixin libSceFreeType, six of the same nine names. The repo allows both libraries but requires the two PRs to be sequenced viaDepends on:(or one closed) — the body says "Depends on: none" and claims no other open PR implements the same functions.Nothing about the semantics themselves is wrong — rename, trim the entry, and declare the sequence with #9410 and this is good.
Imported from boykopovar/AnyPS5. Originally posted by coptergui-ops on 2026-11-08T03:34:44Z.
Review: APPROVED
Re-reviewed at rework head
66786c6239— all three of my earlier findings are addressed and independently confirmed here:<Base>_nid_postfixwith noAPS5_EXPORT(FT_MulDiv,FT_MulFix,FT_DivFix,FT_RoundFix,FT_CeilFix,FT_FloorFix,FT_Matrix_Multiply,FT_Matrix_Invert,FT_Vector_Transform); the two composite bodies delegate as expected (FT_Matrix_Multiply_Scaled_nid_postfix(a, b, 1),FT_Vector_Transform_Scaled_nid_postfix(vector, matrix, 1)).tools/check_conventions.py --base origin/main --head 66786c62reports no debt findings (only body-template complaints from this run, as the PR body here is the real template-filled one).Depends onin the body rather than silently duplicated.No new findings against the rework.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-11T11:52:44Z.
Review: CHANGES_REQUESTED
Checked the six implementations against FreeType 2.4.12
ftcalc.cand theCheckedMulDivrules already in this module; the arithmetic is right. Blocking points:libSceFreeType, andcheck_conventionsrejects a name already exported by another library (duplicate-export), so whichever lands second fails. This PR says it depends on #9410 but its code does not change either way. Please settle the order: once #9410 is merged, reduce this branch toAPS5_DUMMY_FUNdeclarations (or close it), and if the two differ in behaviour (2.4.12 throwing outside 32-bit range here vs 2.13.3 narrowing there), say which one the console build matches and put the other under debt.core/libs/tests/GuestFreeTypeCorner.cpp:169-235): the PR body says overflow and zero-divisor cases are covered, but the six new checks pin none of the throwing paths (operand above 0x7FFFFFFF, quotient above 0xFFFFFFFF, zero divisor with zero factor).FT_MulFixalso has no case that rounds up (e.g.FT_MulFix(1, 0x8000) == 1).FT_CeilFix/FT_RoundFix(Export.cpp:443-449) overflow signedint64_tnearINT64_MAX; do the addition inuint64_tso the wraparound is defined.Happy to re-review once #9410 is resolved.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T20:22:12Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the documented prototype, ABI, and FreeType equivalence caveats remain unverified.
What I ran
Read the prepared diff and the changed source, declarations, tests, and debt entry at head
03be4e958eb09cdbdf3ae706724f7baf42defd2b. No commands or tests were run. The reported build and checks are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Console prototypes, ABI, and equivalence to the console's FreeType version were not verified, as documented in the PR. No tests were run during this review.
files.jsonwas not available through the reader; the manifest lists four changed files, all included, and all four were read. No files were excluded in the manifest.To get this to a good state
Nothing is required.
Pull request closed