feat(libSceFreeTypeOt): implement ft_corner_is_flat and ft_corner_orientation #11426
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11426"
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 iAbdulrrahman on 2026-10-26T13:08:16Z.
What
Implement FreeType corner orientation and flatness algorithms for
libSceFreeTypeOt(ft_corner_orientationandft_corner_is_flat) based on FreeType 2.13.3 (ftcalc.c).Tested
Built with CMake relinker configuration and executed
guest_freetype_corner_testscovering orientation directions, collinearity, large 64-bit coordinates, flat and non-flat angles, dominant vectors, zero vectors, full-range identical vectors, and full-range perpendicular / near-perpendicular vectors under signed/unsigned and 128-bit boundaries.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 MarcZX10 on 2026-10-26T13:15:11Z.
Review: APPROVED
Reviewed the implementation against the linked FreeType 2.13.3
ftcalc.csource: the orientation cross-product/sign andFT_HYPOTcorner-flatness comparison match the reference algorithm. I also rantools/nid_names.pyfor both names; it mapsft_corner_is_flattoP6WOAeb0lJ8andft_corner_orientationtoXGVABnpNksQ, matching the replaced exports. The reported focused test covers the core direction, collinearity, flatness, and degenerate-vector cases; hosted policy checks pass. No title/PS5 runtime call or console-version equivalence is established, as the debt entry states.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T13:54:19Z.
Review: CHANGES_REQUESTED
The flatness implementation has undefined behavior for values within its declared
std::int64_tinput range. I reproduced signed overflow with UBSan using the exact calculation from this PR andft_corner_is_flat_nid_postfix(INT64_MAX, 0, 1, 0):in_x + out_xoverflows atax. The laterinDist + outDist - hypotDistexpression can also overflow for large magnitudes. The new tests described as large 64-bit coordinates use1e9, so they do not exercise 64-bit boundaries.Please make these intermediates overflow-defined (or explicitly reject out-of-range inputs if that matches the console contract) and add boundary tests that run under UBSan. I could not build this test target with the local
ANYPS5_RELINKER_ONLY=ONconfiguration because that mode returns before addingcore/libs; the standalone UBSan reproduction did confirm the overflow.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T14:12:20Z.
Review: CHANGES_REQUESTED
The new unsigned intermediates remove signed-overflow UB, but they still wrap and misclassify valid full-range inputs. I compiled the updated calculation under UBSan and ran
ft_corner_is_flat(INT64_MAX, INT64_MAX, INT64_MAX, INT64_MAX): it returns 0. These vectors point in exactly the same direction, so FreeType’s flatness criterion returns 1 (the distance deficit is zero). The unsignedinDist + outDistwraps here, and the conversion toax/ayalso loses the mathematical sum. Please use overflow-safe/wider arithmetic or constrain the supported input range to the actual console contract, and add this same-direction boundary case plus a near-perpendicular boundary case. This is a defined-result correctness issue, separate from the previous UBSan overflow.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-26T16:13:04Z.
Review: DISMISSED
Re-reviewed exact head
6465f72851f0. The new 128-bit arithmetic fixes the same-directionINT64_MAXfailure I reported earlier; I compiled the exact two function bodies and the current regression test source in a standalone C++20 harness with UBSan, and the test program passes. Current-main conventions andgit diff --checkpass, the merge preview is clean, and no interveningmainchange touches this PR's files. I did not build the full CMake target.Two repository-rule items remain before approval:
bf77a9e9cba4, while livemainisda89f18ea7c1. CONTRIBUTING requires branches to stay current; please sync to livemain.docs/dev/debt/libSceFreeTypeOt.mdline with open PRs #9792, #9802, #9924, #10178 and #10897. I understand these add independent exports, but the checklist still saysDepends on: noneand I found no agreement on the debt-line merge order. CONTRIBUTING asks authors to agree which overlapping PR lands first and declare that order. Please coordinate with those authors and record the agreed order or reconciliation in the checklist.The earlier arithmetic finding is resolved; this request is only for branch freshness and overlap coordination.