feat(libSceFreeType): copy and convert guest bitmaps #8286

Merged
santhoshkumar-dev merged 5 commits from upstream-pr/8286 into main 2026-10-24 10:56:08 +00:00
santhoshkumar-dev commented 2026-10-20 08:46:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-20T08:46:32Z.


What

The existing libSceFreeType bridge can render a glyph bitmap but cannot initialize, retain, convert or release standalone bitmaps. Add FT_Bitmap_New, FT_Bitmap_Copy, FT_Bitmap_Convert and FT_Bitmap_Done using the bundled FreeType allocator and bitmap routines. Copies own their pixel storage; conversion preserves native row direction, alignment, pixel-mode handling and partial output state when allocation fails.

A tracked glyph-slot bitmap also updates its native record when changed or freed. The registration is removed when its guest face wrapper is destroyed, so reusing that storage cannot write through a stale native pointer. Copying a bitmap onto itself follows FreeType's no-op behavior; unsupported shared-buffer aliases throw before freeing storage.

Refresh onto fetched main e3d03fbae64e1b49e5d4e84e753ccce6edf60da5, preserving all merged FreeType features and their registrations/debt entries. The implementation and behavioral fixtures are unchanged. Rechecked newer main 74f6fa8e312462bc4b373b5ec498b2eea2b28efc before publication: no FreeType production/test/debt file changed in that interval and the branch merges cleanly. Results are pinned to the submitted head, not a claim of rebuilding newer upstream commits.

Tested

Submitted head 7f5367d4e4bb603746dbcb91eaaf4d2f490467b0.

Windows 11 x64, WinLibs GCC 15.2.0 r7, Ninja Release, bundled dependencies, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF: full default build passed; 4/4 focused CTests passed, zero skips.

Local Ubuntu 24.04.1 x86-64/WSL2 (6.6.87.2), GCC 13.3.0, glibc 2.39, same build options: complete libs build plus selected executables passed; 4/4 focused CTests each passed three consecutive times. This covers the feature, existing base/charmap APIs and the 368-library packaged loader. No fresh title, console or macOS result is claimed.

The earlier Linux release and bitmap sanitizer validation by @jotitadev is retained as attributed historical evidence: https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6350224579. The fresh Linux results below are local, without sanitizers; no fresh sanitizer claim is made.

Whitespace and conventions checks pass. The bitmap refresh retains main's outline, charmap, face-info, list and size-request source/test registrations alongside its own bitmap registration.

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:4933306986 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-20T08:46:32Z. --- ### What The existing `libSceFreeType` bridge can render a glyph bitmap but cannot initialize, retain, convert or release standalone bitmaps. Add `FT_Bitmap_New`, `FT_Bitmap_Copy`, `FT_Bitmap_Convert` and `FT_Bitmap_Done` using the bundled FreeType allocator and bitmap routines. Copies own their pixel storage; conversion preserves native row direction, alignment, pixel-mode handling and partial output state when allocation fails. A tracked glyph-slot bitmap also updates its native record when changed or freed. The registration is removed when its guest face wrapper is destroyed, so reusing that storage cannot write through a stale native pointer. Copying a bitmap onto itself follows FreeType's no-op behavior; unsupported shared-buffer aliases throw before freeing storage. Refresh onto fetched main `e3d03fbae64e1b49e5d4e84e753ccce6edf60da5`, preserving all merged FreeType features and their registrations/debt entries. The implementation and behavioral fixtures are unchanged. Rechecked newer main `74f6fa8e312462bc4b373b5ec498b2eea2b28efc` before publication: no FreeType production/test/debt file changed in that interval and the branch merges cleanly. Results are pinned to the submitted head, not a claim of rebuilding newer upstream commits. ### Tested Submitted head `7f5367d4e4bb603746dbcb91eaaf4d2f490467b0`. Windows 11 x64, WinLibs GCC 15.2.0 r7, Ninja Release, bundled dependencies, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`: full default build passed; **4/4 focused CTests passed, zero skips**. Local Ubuntu 24.04.1 x86-64/WSL2 (6.6.87.2), GCC 13.3.0, glibc 2.39, same build options: complete `libs` build plus selected executables passed; **4/4 focused CTests each passed three consecutive times**. This covers the feature, existing base/charmap APIs and the 368-library packaged loader. No fresh title, console or macOS result is claimed. The earlier Linux release and bitmap sanitizer validation by @jotitadev is retained as attributed historical evidence: https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6350224579. The fresh Linux results below are local, without sanitizers; no fresh sanitizer claim is made. Whitespace and conventions checks pass. The bitmap refresh retains main's outline, charmap, face-info, list and size-request source/test registrations alongside its own bitmap registration. <!-- 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: none <!-- #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 -->
nikowolf123 commented 2026-10-20 22:04:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T22:04:30Z.


docs/dev/debt/libSceFreeType.md#L3 adds a new ### Bitmap handling section. CONTRIBUTING.md asks for entries "under the same ### sections as the index". The index has only four: Build, Silent stubs, Unknown function info and Functional. The Conventions check does not compare section names, so it passes. tools/debt_split.py does sort sections in index order, though, so the next split or resolve that rewrites this file will move Bitmap handling below Functional. Earlier custom sections were moved into index sections after merge (ddb135643a, cb7fd81933, f2558e7be6).

The same paragraph asks that an entry state the gap first (what differs from the console, what is unverified, what throws). In this entry the first two sentences describe the implementation, "console behavior and errors have not been measured" comes third, and what throws comes last. I would move the entry under the existing ### Unknown function info, after the FreeType 2.13.3 entry, and open with the gap, for example:

- [FT_Bitmap_New, FT_Bitmap_Copy, FT_Bitmap_Convert, FT_Bitmap_Done](../../../core/libs/prx/libSceFreeType/src/Bitmap.cpp) (libSceFreeType) - console behaviour and error codes are not measured; these follow the bundled FreeType 2.13.3. Copy and Convert throw when source and target share a non-null buffer, and Convert throws when they are the same object
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302782000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6302782000). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T22:04:30Z. --- [`docs/dev/debt/libSceFreeType.md#L3`](https://github.com/boykopovar/AnyPS5/blob/821c6c14107ee4699e420e244b8a8dd277ee67f5/docs/dev/debt/libSceFreeType.md#L3) adds a new `### Bitmap handling` section. [CONTRIBUTING.md](https://github.com/boykopovar/AnyPS5/blob/821c6c14107ee4699e420e244b8a8dd277ee67f5/CONTRIBUTING.md#documentation) asks for entries "under the same `###` sections as the index". The index has only four: Build, Silent stubs, Unknown function info and Functional. The Conventions check does not compare section names, so it passes. [`tools/debt_split.py`](https://github.com/boykopovar/AnyPS5/blob/821c6c14107ee4699e420e244b8a8dd277ee67f5/tools/debt_split.py#L64) does sort sections in index order, though, so the next `split` or `resolve` that rewrites this file will move `Bitmap handling` below `Functional`. Earlier custom sections were moved into index sections after merge (ddb135643a, cb7fd81933, f2558e7be6). The same paragraph asks that an entry state the gap first (what differs from the console, what is unverified, what throws). In this entry the first two sentences describe the implementation, "console behavior and errors have not been measured" comes third, and what throws comes last. I would move the entry under the existing `### Unknown function info`, after the FreeType 2.13.3 entry, and open with the gap, for example: ```markdown - [FT_Bitmap_New, FT_Bitmap_Copy, FT_Bitmap_Convert, FT_Bitmap_Done](../../../core/libs/prx/libSceFreeType/src/Bitmap.cpp) (libSceFreeType) - console behaviour and error codes are not measured; these follow the bundled FreeType 2.13.3. Copy and Convert throw when source and target share a non-null buffer, and Convert throws when they are the same object ```
MarcZX10 commented 2026-10-20 22:05:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:05:11Z.


I checked the current head and confirmed the debt entry still sits under the new ### Bitmap handling heading. tools/debt_split.py orders sections from the shared debt index, whose headings are Build, Silent stubs, Unknown function info and Functional; an extra heading can be reordered by the next split/resolve. The entry also says console behavior and errors are unmeasured only after describing the implementation. The suggested move to Unknown function info with the unverified console behavior first matches the documented debt format.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6302800449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6302800449). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:05:11Z. --- I checked the current head and confirmed the debt entry still sits under the new `### Bitmap handling` heading. `tools/debt_split.py` orders sections from the shared debt index, whose headings are Build, Silent stubs, Unknown function info and Functional; an extra heading can be reordered by the next split/resolve. The entry also says console behavior and errors are unmeasured only after describing the implementation. The suggested move to `Unknown function info` with the unverified console behavior first matches the documented debt format.
Ondra97 commented 2026-10-22 01:56:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-22T01:56:20Z.


I opened #9550 to add FT_New_Size, FT_Activate_Size and FT_Done_Size. I declared #8286 for merge order because both patches insert declarations before GuestFace. The size objects and bitmap registration implement different functions; retain both sets of declarations when resolving that insertion.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330815005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6330815005). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-22T01:56:20Z. --- I opened #9550 to add FT_New_Size, FT_Activate_Size and FT_Done_Size. I declared #8286 for merge order because both patches insert declarations before GuestFace. The size objects and bitmap registration implement different functions; retain both sets of declarations when resolving that insertion.
santhoshkumar-dev commented 2026-10-22 07:37:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by santhoshkumar-dev on 2026-10-22T07:37:35Z.


Addressed the requested documentation placement in 6133773304. The custom Bitmap handling heading is removed; the bitmap entry is under Unknown function info, immediately after the general FreeType 2.13.3 entry. It starts with the unmeasured console behavior/error-code gap and documents unsupported alias cases. Conventions passes; this commit changes only paragraph placement.

For #9550, confirmed the merge order: bitmap registration and the additional size-object declarations are distinct and both must be retained.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335410512 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286#issuecomment-6335410512). Originally posted by [santhoshkumar-dev](https://github.com/santhoshkumar-dev) on 2026-10-22T07:37:35Z. --- Addressed the requested documentation placement in `6133773304`. The custom `Bitmap handling` heading is removed; the bitmap entry is under `Unknown function info`, immediately after the general FreeType 2.13.3 entry. It starts with the unmeasured console behavior/error-code gap and documents unsupported alias cases. Conventions passes; this commit changes only paragraph placement. For #9550, confirmed the merge order: bitmap registration and the additional size-object declarations are distinct and both must be retained.
jotitadev commented 2026-10-22 09:32:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T09:32:28Z.

Review: COMMENTED


First Linux run (the PR lists Windows only). Ubuntu 26.04, glibc 2.43, x86_64 i7-8700, GCC 15.2.0, head 613377330 merged --no-commit onto origin/main 7e2ba73e4 (clean, the branch is ~680 commits behind).

  • Release: guest_freetype_bitmap, guest_freetype, guest_freetype_charmap and patched_libraries pass.
  • -DANYPS5_ENABLE_ASAN=ON (ASan + UBSan + LeakSanitizer): guest_freetype_bitmap passes with no report, including the forced allocation failure and the repeated convert/cleanup cases. guest_freetype passes too.
  • Not from this PR: guest_freetype_charmap fails under LeakSanitizer on main as well (16920 bytes in 95 allocations, from FT_Init_FreeType_nid_postfix and FT_New_Face_nid_postfix at GuestFreeTypeCharmap.cpp:83-85, never released). Same result with and without this PR.

No control run: the FT_Bitmap_* exports don't exist on main, so the new test doesn't link there.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5612110221 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8286#pullrequestreview-5612110221). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T09:32:28Z. **Review:** COMMENTED --- First Linux run (the PR lists Windows only). Ubuntu 26.04, glibc 2.43, x86_64 i7-8700, GCC 15.2.0, head 613377330 merged `--no-commit` onto `origin/main` 7e2ba73e4 (clean, the branch is ~680 commits behind). - Release: `guest_freetype_bitmap`, `guest_freetype`, `guest_freetype_charmap` and `patched_libraries` pass. - `-DANYPS5_ENABLE_ASAN=ON` (ASan + UBSan + LeakSanitizer): `guest_freetype_bitmap` passes with no report, including the forced allocation failure and the repeated convert/cleanup cases. `guest_freetype` passes too. - Not from this PR: `guest_freetype_charmap` fails under LeakSanitizer on `main` as well (16920 bytes in 95 allocations, from `FT_Init_FreeType_nid_postfix` and `FT_New_Face_nid_postfix` at `GuestFreeTypeCharmap.cpp:83-85`, never released). Same result with and without this PR. No control run: the `FT_Bitmap_*` exports don't exist on `main`, so the new test doesn't link there. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!8286
No description provided.