feat(libSceFreeType): implement the legacy integer square root #11878

Closed
santhoshkumar-dev wants to merge 7 commits from upstream-pr/11878 into main
santhoshkumar-dev commented 2026-10-27 11:11:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-27T11:11:10Z.


What

Add FT_Sqrt32 (C7N2GuwqTA0) to the physical libSceFreeType adapter. Its signed 32-bit argument is interpreted as unsigned input bits, and its result is the integer floor square root. A bounded integer search uses 64-bit products for all input bit patterns.

The name/NID is in the PS5 3.20 inventory. The interface and unsigned interpretation follow legacy FreeType 2.4.12 ftcalc.h and ftcalc.c. Console ABI/arithmetic equivalence is unverified and recorded in debt.

The matching OT inventory helper is named and declared in the public header reachable through its umbrella. Its existing no-parameter placeholder, explicit NID alias and throwing behavior remain; this is not an OT-provider implementation or a claim about its console prototype. Implementation and tests include the canonical square-root header.

Merge order: #11613 first, confirmed by its author. Its removal of the neighbouring OT sine stub conflicts textually with identifying the square-root helper. No code from that PR is included and there is no functional/build dependency. A rebase will be needed after it merges. The author of #12370 has committed to hold that inventory PR until this PR lands and rebase afterward; I confirm the order #11613 → #11878 → #12370. The earlier #9465/#10897 debt-file conflicts were rechecked at their newer heads on October 29; the results below supersede the old conflict report. No confirmation from those two authors has been received.

Tested

Submitted and tested head 576c7ed4d8d5c70e83f5de2086371fdeee1cc94d, including upstream main 61e96fecbd6df49dfd56d50bfa212cd14c84a95a.

Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. On each platform the complete libs target and selected executables build, and 70/70 CTests pass, zero skips: public-header audit, all 64 header compilation batches, both square-root export modes, base/charmap checks and the packaged-library loader.

The feature fixture resolves the actual unpatched symbol and packaged NID separately. Each mode checks 262,143 cases: boundaries for every one of the 65,536 square-root intervals and 65,536 deterministic samples checked against square inequalities. This includes signed-negative bit patterns. Regression-only head d015ec968ce728eb5901e897e58e1dc2f4da7e49 reproduced the missing unpatched entry before implementation.

No full application/test-suite, macOS, title or physical-console run is claimed.

The published implementation head is unchanged. On October 29, upstream 4c7d275bef89d309313d16bc2bc05d37a1b50be2 merges cleanly with it. This is a merge-tree check, not a fresh build or runtime validation of that composition. #11613 remains a declared textual ordering dependency.

Refreshed whole-branch checks use private integration c0d3470ce52526c28fdb23d54aab171cadb4d760 (parents: upstream 4c7d275bef89d309313d16bc2bc05d37a1b50be2 and this published head). #10897 head 39e096c534b2ccd77ab93b0e364de4a3cf64bb9b merges cleanly with both main and this integration. #9465 head 7f3a3a3f39b0fa44fd0171dc0418ce16c3e3d8f5 conflicts in exactly libSceFreeType/CMakeLists.txt and include/Api.hpp against both: those conflicts are inherited from main. Neither comparison now conflicts in docs/dev/debt/libSceFreeTypeOt.md, which this PR does not modify. #11613 and #12370 still conflict with this integration in libSceFreeTypeOt/Export.cpp; the confirmed landing order above covers those conflicts. Earlier individual-file checks were insufficient to establish whole-branch mergeability. Reviewer reassessment of the older #9465/#10897 ordering request is pending; no author agreement is claimed.

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: #11613
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5032913912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11878). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-27T11:11:10Z. --- ### What Add `FT_Sqrt32` (`C7N2GuwqTA0`) to the physical `libSceFreeType` adapter. Its signed 32-bit argument is interpreted as unsigned input bits, and its result is the integer floor square root. A bounded integer search uses 64-bit products for all input bit patterns. The name/NID is in the [PS5 3.20 inventory](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceFreeTypeOt.c). The interface and unsigned interpretation follow legacy [FreeType 2.4.12 ftcalc.h](https://github.com/freetype/freetype/blob/cecf93ef90c660a8b0b45e5adbbfb5ea443fb6b9/include/freetype/internal/ftcalc.h#L43-L60) and [ftcalc.c](https://github.com/freetype/freetype/blob/cecf93ef90c660a8b0b45e5adbbfb5ea443fb6b9/src/base/ftcalc.c#L142-L172). Console ABI/arithmetic equivalence is unverified and recorded in debt. The matching OT inventory helper is named and declared in the public header reachable through its umbrella. Its existing no-parameter placeholder, explicit NID alias and throwing behavior remain; this is not an OT-provider implementation or a claim about its console prototype. Implementation and tests include the canonical square-root header. Merge order: #11613 first, [confirmed by its author](https://github.com/boykopovar/AnyPS5/pull/11878#issuecomment-6440965748). Its removal of the neighbouring OT sine stub conflicts textually with identifying the square-root helper. No code from that PR is included and there is no functional/build dependency. A rebase will be needed after it merges. The author of #12370 has committed to hold that inventory PR until this PR lands and rebase afterward; I confirm the order #11613 → #11878 → #12370. The earlier #9465/#10897 debt-file conflicts were rechecked at their newer heads on October 29; the results below supersede the old conflict report. No confirmation from those two authors has been received. ### Tested Submitted and tested head `576c7ed4d8d5c70e83f5de2086371fdeee1cc94d`, including upstream main `61e96fecbd6df49dfd56d50bfa212cd14c84a95a`. Windows 11 x64 / WinLibs GCC 15.2.0 r7 and local Ubuntu 24.04.1 x86-64 under WSL2 / GCC 13.3.0 / glibc 2.39: Ninja Release, bundled dependencies, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. On each platform the complete `libs` target and selected executables build, and **70/70 CTests pass, zero skips**: public-header audit, all 64 header compilation batches, both square-root export modes, base/charmap checks and the packaged-library loader. The feature fixture resolves the actual unpatched symbol and packaged NID separately. Each mode checks 262,143 cases: boundaries for every one of the 65,536 square-root intervals and 65,536 deterministic samples checked against square inequalities. This includes signed-negative bit patterns. Regression-only head `d015ec968ce728eb5901e897e58e1dc2f4da7e49` reproduced the missing unpatched entry before implementation. No full application/test-suite, macOS, title or physical-console run is claimed. The published implementation head is unchanged. On October 29, upstream `4c7d275bef89d309313d16bc2bc05d37a1b50be2` merges cleanly with it. This is a merge-tree check, not a fresh build or runtime validation of that composition. #11613 remains a declared textual ordering dependency. Refreshed whole-branch checks use private integration `c0d3470ce52526c28fdb23d54aab171cadb4d760` (parents: upstream `4c7d275bef89d309313d16bc2bc05d37a1b50be2` and this published head). #10897 head `39e096c534b2ccd77ab93b0e364de4a3cf64bb9b` merges cleanly with both main and this integration. #9465 head `7f3a3a3f39b0fa44fd0171dc0418ce16c3e3d8f5` conflicts in exactly `libSceFreeType/CMakeLists.txt` and `include/Api.hpp` against both: those conflicts are inherited from main. Neither comparison now conflicts in `docs/dev/debt/libSceFreeTypeOt.md`, which this PR does not modify. #11613 and #12370 still conflict with this integration in `libSceFreeTypeOt/Export.cpp`; the confirmed landing order above covers those conflicts. Earlier individual-file checks were insufficient to establish whole-branch mergeability. Reviewer reassessment of the older #9465/#10897 ordering request is pending; no author agreement is claimed. <!-- 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. --> ### 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) - [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: #11613 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
MarcZX10 commented 2026-10-27 12:14:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T12:14:19Z.

Review: CHANGES_REQUESTED


The integer square-root implementation and tests are well scoped. The unsigned reinterpretation matches FreeType 2.4.12's FT_Sqrt32 contract, the search bound covers the full uint32_t domain, and the tests cover every square interval boundary plus deterministic samples. I found no implementation defect in the reviewed code.

Changes requested — contribution ordering/overlap. The body says the four shared files with #9465 and #10897 merge cleanly, but I independently ran git merge-tree for this head against both current PR heads. Both combinations conflict in docs/dev/debt/libSceFreeTypeOt.md: this PR replaces the unidentified-export-count entry with provider-specific import-resolution wording, while #9465/#10897 update the count and identified-name list. Please coordinate an agreed order with those PR authors and declare it in Depends on; correct the claim that these combinations merge cleanly. The declared #11613 dependency also has a real conflict in libSceFreeTypeOt/Export.cpp, which your description already identifies and correctly says needs a rebase after it lands.

The hosted Windows job and conventions, intake, labels, and report checks pass. The Linux product job is skipped by repository path policy. No code change is required for the implementation finding above, but the shared debt entry and ordering need to be made reviewable before merge.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5666855015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11878#pullrequestreview-5666855015). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T12:14:19Z. **Review:** CHANGES_REQUESTED --- The integer square-root implementation and tests are well scoped. The unsigned reinterpretation matches FreeType 2.4.12's `FT_Sqrt32` contract, the search bound covers the full `uint32_t` domain, and the tests cover every square interval boundary plus deterministic samples. I found no implementation defect in the reviewed code. **Changes requested — contribution ordering/overlap.** The body says the four shared files with #9465 and #10897 merge cleanly, but I independently ran `git merge-tree` for this head against both current PR heads. Both combinations conflict in `docs/dev/debt/libSceFreeTypeOt.md`: this PR replaces the unidentified-export-count entry with provider-specific import-resolution wording, while #9465/#10897 update the count and identified-name list. Please coordinate an agreed order with those PR authors and declare it in `Depends on`; correct the claim that these combinations merge cleanly. The declared #11613 dependency also has a real conflict in `libSceFreeTypeOt/Export.cpp`, which your description already identifies and correctly says needs a rebase after it lands. The hosted Windows job and conventions, intake, labels, and report checks pass. The Linux product job is skipped by repository path policy. No code change is required for the implementation finding above, but the shared debt entry and ordering need to be made reviewable before merge.
MarcZX10 commented 2026-10-29 10:06:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:06:49Z.

Review: APPROVED


Rechecked the exact unchanged head 576c7ed4d8d5c70e83f5de2086371fdeee1cc94 after the coordination updates. The #11613 → #11878 → #12370 order is recorded and confirmed by the relevant authors; #10897 reports no ordering requirement. The refreshed whole-branch comparison shows the #9465 conflict is the same with or without #11878, so it is not a new overlap introduced by this PR. Current main has a clean merge preview with this branch, and git diff --check passes. Hosted Windows, conventions, intake and report checks pass; Linux product tests are skipped. I did not rerun the C++ suite locally. The implementation finding was already clear, and the outstanding coordination point from my prior review is resolved. Approved, with the declared #11613 dependency still governing merge order.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695977417 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11878#pullrequestreview-5695977417). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T10:06:49Z. **Review:** APPROVED --- Rechecked the exact unchanged head `576c7ed4d8d5c70e83f5de2086371fdeee1cc94` after the coordination updates. The #11613 → #11878 → #12370 order is recorded and confirmed by the relevant authors; #10897 reports no ordering requirement. The refreshed whole-branch comparison shows the #9465 conflict is the same with or without #11878, so it is not a new overlap introduced by this PR. Current main has a clean merge preview with this branch, and `git diff --check` passes. Hosted Windows, conventions, intake and report checks pass; Linux product tests are skipped. I did not rerun the C++ suite locally. The implementation finding was already clear, and the outstanding coordination point from my prior review is resolved. Approved, with the declared #11613 dependency still governing merge order.

Pull request closed

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!11878
No description provided.