feat(libSceFreeTypeOptOl): implement PFR queries #9646
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9646"
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 UnhealthyKraken on 2026-10-22T05:59:43Z.
What
Implement FT_Get_PFR_Metrics, FT_Get_PFR_Advance and FT_Get_PFR_Kerning in the physical libSceFreeTypeOptOl provider through the existing shared FreeType face adapter. Guest positions, scales and vectors retain 64-bit storage on Windows. The optional module forwards to helpers in the existing runtime and creates no second FreeType instance.
A null face returns Invalid_Argument (6), with outputs untouched and no host PFR calls. This follows official FreeType 2.4.11 ftpfr.c, blob 3a0f92d07ae29fa0385e36ee2660d3ededaa40dc, and BunnyFl's firmware 13.42 Unicorn report. The report also attributes a 2.4.11 version to Ol disassembly and finds the same three NIDs in OptOl and Ol under logical library libSceFreeType. This patch implements OptOl only; Ol support remains missing. The reported version was not executed, and no real-face Sony behavior was measured.
Nonnull behavior still follows bundled FreeType 2.13.3 through the existing LP64 adapter: PFR advances/kerning use metric space, invalid PFR advance indices write zero, non-PFR advance failures preserve output, and non-PFR metrics write fallback values before returning the format error. Sony prototypes, private layouts, configuration, module/library versions and real-face equivalence remain unverified in debt. Names/NIDs are attributable to the PS5 3.20 OptOl inventory.
The main refresh adopts one shared public declaration per export, the OptOl umbrella and decltype-based test pointers. The standalone null-face target compiles the actual wrappers/helpers with isolated host spies; it checks literal error 6, all 16 metrics output masks, null/non-null outputs, sentinels/canaries and zero host calls. The full fixture keeps its synthetic face, aliasing, signed-width and lifetime coverage. The patched target now explicitly builds its kernel/libc dependencies.
Tested
Exact head
1248d841c7, after a history-preserving main504ea3b53bmerge. Actual project Release builds and all eight focused CTests pass on hosted Ubuntu 24.04/GCC 13.3 and Windows/WinLibs GCC 15.2, followed by two repetitions per case. Linux, Windows. Both jobs first reproduce the expected failures on the regression-only baseline, then rebuild the candidate and verify the unchanged legacy fixture executable by SHA256. Linux additionally withholds only the patched kernel: the actual loader reports libkernel.prx missing and all three patched cases fail; restoring it gives 8/8 again with the same fixture. Conventions, whitespace and public-header audits pass. No selected candidate case was skipped.Before the guard change, all three real raw query tests return 35 instead of 6 and the standalone unit records one host call; the native reference case passes. The regression-only baseline therefore has four expected failures and one passing reference. The same committed fixtures run against the corrected implementation. This does not establish real-face firmware behavior from the reported null-only measurements.
No local builds/runtime tests, games, proprietary modules/captures or physical-console execution. The full repository test suite was not run; validation used one cloud build job at a time and compiler/test parallelism 1.
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 jotitadev on 2026-10-22T07:09:19Z.
Review: COMMENTED
Linux run, since the description lists only Windows. The implementation passes, but on Linux the three
*_patchedcases fail. The cause is how the test executable is linked.Machine: Linux x86_64, i7-8700, Ubuntu 26.04, GCC 15.2, Release,
BUILD_TESTING=ON, full build. Head5a35e3400merged--no-commitontomaind6eafa54d(clean).As submitted,
guest_freetype_pfr_{metrics,advance,kerning}_patchedfail 3 of 3 runs, before any PFR check:guest_freetype_pfr_testslinkslibcon every platform, so it starts with the unpatchedlibc.prxloaded (its RUNPATH islibs/unpatched). Thendlopen(libs/libSceFreeType.prx)pulls the patchedlibkernel.prxthrough$ORIGIN. Thelibc.prxdependency is satisfied by the copy already loaded, which exports*_nid_postfixnames and not NIDs. So the patchedlibkernel.prximportg5PTgiKQ9Eo(exported by the patchedlibc.prx) cannot resolve.LD_DEBUG=filesshowslibc.prxloaded as "needed by guest_freetype_pfr_tests" andlibkernel.prxas "needed by .../libs/libSceFreeType.prx".The CMAC patched test (#9571,
Cmac.cmake) avoids this by linkinglibconly on Windows. The same change here fixes it:With it, all 7
guest_freetype_pfr_*tests pass, plusguest_freetypeandguest_freetype_charmap, 3 of 3 runs. The raw cases still load the unpatchedlibc.prxthrough the prx's own$ORIGINRUNPATH.Red with that change and
main'slibSceFreeTypeOptOl/Export.cpp:referencepasses, and the six raw/patched cases fail onMissing FT_Get_PFR_{Metrics,Advance,Kerning}, as*_nid_postfix(raw) and asOqaxEkRhr+8/NVuvsPgTXto/qBohKqdkAqE(patched). This matches your baseline. On this LP64 host, the 64-bit signed results and untouched high-bit output checks pass.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by fogydes on 2026-10-22T08:12:54Z.
Reviewed; the wrapper behavior matches the pinned freetype tree it links (3rdparty/freetype, 2.13.3
ftpfr.c): the non-PFR fallback (units_per_EM for both resolutions,size->metricsscaling,Unknown_File_Format), the font-format-gated advance zeroing for PFR against the non-PFR unchanged output, and the kerning fallback toFT_Get_Kerning(FT_KERNING_UNSCALED). Exports follow the established_nid_postfixdiscovery with no table edit, and the test registration mirrorsguest_freetype_tests. The debt entry documents the gap honestly.One nit:
GuestFreeTypePfr.cppusesoffsetofwithout including<cstddef>; it compiles today through transitive includes, but the include should state the dependency.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T09:18:53Z.
Review: DISMISSED
The implementation behavior tracks the pinned FreeType 2.13.3 helper semantics, and the synthetic output/canary coverage is detailed. There are two concrete items still unresolved at the current head
5a35e3400: 1. The independent Linux run on this exact head reports all threeguest_freetype_pfr_{metrics,advance,kerning}_patchedtests fail before their PFR assertions: the test executable preloads unpatchedlibc.prx, then loads patchedlibkernel.prx, whose NID import cannot resolve against that already-loaded libc. The reproduced correction is to linklibconly underif(WIN32), as in the CMAC patched test. This matters because the current test report claims those patched cases pass, while Linux product CI was skipped. Please apply the platform-specific linkage and rerun the seven PFR cases on Linux and Windows. 2. Add<cstddef>directly toGuestFreeTypePfr.cppfor itsoffsetofuse. The exact-head report and CI show conventions, eligibility, intake, labels and progress report pass; product build/test jobs are skipped. I did not rerun the full FreeType build in this environment.I’ve noticed that holding this PR because of #5239 isn’t necessary. It’s fine for PRs to keep coming in; they’ll be handled in due course. Please disregard my earlier request to hold or defer it.
Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T14:26:48Z.
Fixed both concrete review items in
1df8b3cd063baaf7a20869b8405678b164d28216, together with a history-preserving merge of current main329efe1bfd. The test links guestlibconly on Windows, so Linux patched cases no longer preload the raw runtime.<cstddef>is now included directly foroffsetof.Rebuilt the full affected Windows libraries and reran the seven PFR cases, the existing FreeType/charmap cases and the loader: 10/10 pass. Conventions/current PR body, whitespace, and test registration pass (1176 executables, none unregistered).
I could not rerun Linux locally: the installed Ubuntu WSL has no CMake, Ninja, g++ or pkg-config; I installed nothing. @jotitadev's original-head Linux reproduction and successful run with this same linkage correction remain attributed evidence, not a Linux run of this new head by me. A fresh Linux rerun is still welcome. The PR description now states that limitation explicitly. @MarcZX10 @fogydes