feat(libSceJxr): implement pixel format lookup #9954

Merged
UnhealthyKraken merged 7 commits from upstream-pr/9954 into main 2026-10-26 15:24:16 +00:00
UnhealthyKraken commented 2026-10-22 23:44:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by UnhealthyKraken on 2026-10-22T23:44:50Z.


What

Implement libSceJxr PixelFormatLookup (NID 5Gjz1nLOKvo) through pinned public jxrlib and a C bridge. Modes 0/1 perform GUID/TIFF lookup. Misses and unsupported modes return the public -106 error without changing any record byte. Success fills the 56-byte LP64 guest model, explicitly clears its four padding bytes at 28..31, and borrows a read-only static GUID while the module remains loaded.

The field bridge remains necessary on Windows, where native jxrlib uses a 32-bit unsigned long. Padding is cleared explicitly rather than copied from indeterminate C++ padding. BunnyFl's firmware 13.42 native-PC report corroborates the 68-entry public table and record/results across 802 cases repeated three times, and identifies zero padding on all 309 successes. That is attributed contributor evidence, not my console measurement or proof of every Sony ABI/configuration. Valid-mode null records/GUIDs remain unsupported and unmeasured; tests no longer pin their exception behavior. Module/library versions and other firmware remain unverified in debt.

The earlier Apple Clang correction is retained: a project-owned forced include provides wchar.h and the exact U32 _byteswap_ulong(U32) prototype from pinned jxrlib. It suppresses no diagnostics and modifies no third-party sources. Public PixelFormatLookup declarations are shared by implementation/tests. jxrlib is a pinned submodule built from source; #9540 is merged and its authored history is preserved. readIS/writeIS remain unsupported.

Tested

Exact head fd4e2c5466d5a79ddbd4b7521e6810b090ade219, after a history-preserving main 504ea3b53b merge. 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.

The regression-only source fails both forward/reverse padding cases while three existing raw/reference controls pass, before the production correction. Both directions poison padding and verify record canaries across the public reference inventory; existing metadata, failure nonmutation, guarded reads, GUID lifetime and concurrency checks remain.

The unchanged C99 compatibility files and native bridge were already built with Apple Clang 17.0.0 on hosted macOS 15 Intel, with the native reference probe passing 66 hashes: Apple job. Its baseline reproduced both undeclared calls. This is historical native dependency/reference evidence, not a full final-head macOS guest runtime run on the separate #8658 port.

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

  • 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:4975646272 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9954). Originally posted by [UnhealthyKraken](https://github.com/UnhealthyKraken) on 2026-10-22T23:44:50Z. --- ### What Implement libSceJxr PixelFormatLookup (NID 5Gjz1nLOKvo) through pinned public jxrlib and a C bridge. Modes 0/1 perform GUID/TIFF lookup. Misses and unsupported modes return the public -106 error without changing any record byte. Success fills the 56-byte LP64 guest model, explicitly clears its four padding bytes at 28..31, and borrows a read-only static GUID while the module remains loaded. The field bridge remains necessary on Windows, where native jxrlib uses a 32-bit unsigned long. Padding is cleared explicitly rather than copied from indeterminate C++ padding. [BunnyFl's firmware 13.42 native-PC report](https://github.com/boykopovar/AnyPS5/pull/9954#issuecomment-6406356097) corroborates the 68-entry public table and record/results across 802 cases repeated three times, and identifies zero padding on all 309 successes. That is attributed contributor evidence, not my console measurement or proof of every Sony ABI/configuration. Valid-mode null records/GUIDs remain unsupported and unmeasured; tests no longer pin their exception behavior. Module/library versions and other firmware remain unverified in debt. The earlier Apple Clang correction is retained: a project-owned forced include provides wchar.h and the exact U32 _byteswap_ulong(U32) prototype from pinned jxrlib. It suppresses no diagnostics and modifies no third-party sources. Public PixelFormatLookup declarations are shared by implementation/tests. jxrlib is a pinned submodule built from source; #9540 is merged and its authored history is preserved. readIS/writeIS remain unsupported. ### Tested Exact head fd4e2c5466d5a79ddbd4b7521e6810b090ade219, after a history-preserving main 504ea3b53b23 merge. 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](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40264736645/job/121384527090), [Windows](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40264736645/job/121389909276). 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. The regression-only source fails both forward/reverse padding cases while three existing raw/reference controls pass, before the production correction. Both directions poison padding and verify record canaries across the public reference inventory; existing metadata, failure nonmutation, guarded reads, GUID lifetime and concurrency checks remain. The unchanged C99 compatibility files and native bridge were already built with Apple Clang 17.0.0 on hosted macOS 15 Intel, with the native reference probe passing 66 hashes: [Apple job](https://github.com/UnhealthyKraken/AnyPS5/actions/runs/40246759509/job/121339289609). Its baseline reproduced both undeclared calls. This is historical native dependency/reference evidence, not a full final-head macOS guest runtime run on the separate #8658 port. 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. <!-- 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-23 00:27:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:27:15Z.

Review: CHANGES_REQUESTED


The focused Linux CI build succeeds, but one of the four selected tests fails: guest_jxr_lookup_patched cannot dlopen the patched libSceJxr.prx with RTLD_NOW | RTLD_LOCAL. The raw lookup and reference tests pass. Please expose dlerror() and diagnose whether this is the patched artifact or runtime dependency/search path, then rerun the focused tests; I cannot approve while a newly added required focused test is failing.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5622537162 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9954#pullrequestreview-5622537162). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T00:27:15Z. **Review:** CHANGES_REQUESTED --- The focused Linux CI build succeeds, but one of the four selected tests fails: `guest_jxr_lookup_patched` cannot `dlopen` the patched `libSceJxr.prx` with `RTLD_NOW | RTLD_LOCAL`. The raw lookup and reference tests pass. Please expose `dlerror()` and diagnose whether this is the patched artifact or runtime dependency/search path, then rerun the focused tests; I cannot approve while a newly added required focused test is failing.
jotitadev commented 2026-10-23 06:09:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T06:09:37Z.

Review: COMMENTED


macOS test: jxrlib does not compile with Apple clang

Apple M2 Max, macOS 27.2, Apple clang (Xcode 27), CMake 4.4.4, x86-64 Release build under Rosetta 2, BUILD_TESTING=ON. Head 807965be9f. main does not build on macOS, so the platform is #8658 (feat/macos-port) @ fa063d8b07 with this PR merged in (clean merge).

The jxr target stops on two implicit function declarations, which Apple clang treats as errors in C99:

3rdparty/jxrlib/image/decode/segdec.c:66:12: error: call to undeclared function '_byteswap_ulong'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
3rdparty/jxrlib/jxrgluelib/JXRGlueJxr.c:66:48: error: call to undeclared library function 'wcslen' with type 'unsigned long (const int *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

On non-Windows hosts _byteswap_ulong is defined in image/sys/strcodec.c but not declared in any header, and JXRGlueJxr.c does not include <wchar.h>. With the __ANSI__ branch of configure_jxr_native these only warn on GCC 13 (the Linux CI), but GCC 14 also turns -Wimplicit-function-declaration into an error by default, so newer Linux toolchains should hit the same thing (not run here). Since libSceJxr links jxr, the default build fails, not only the JXR tests.

As a local check I added target_compile_options(${target} PRIVATE -Wno-error=implicit-function-declaration) to the non-Windows branch of cmake/Jxr.cmake. With that, jxr builds and all four tests pass: guest_jxr_lookup_reference, guest_jxr_lookup, guest_jxr_lookup_patched, guest_jxr (4/4). Both implicit declarations match the real signatures on x86-64, so silencing them is safe. Forcing in a prototype and <wchar.h> would work too.

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

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624583154 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9954#pullrequestreview-5624583154). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-23T06:09:37Z. **Review:** COMMENTED --- ### macOS test: jxrlib does not compile with Apple clang Apple M2 Max, macOS 27.2, Apple clang (Xcode 27), CMake 4.4.4, x86-64 Release build under Rosetta 2, `BUILD_TESTING=ON`. Head `807965be9f`. `main` does not build on macOS, so the platform is #8658 (`feat/macos-port`) @ `fa063d8b07` with this PR merged in (clean merge). The `jxr` target stops on two implicit function declarations, which Apple clang treats as errors in C99: ``` 3rdparty/jxrlib/image/decode/segdec.c:66:12: error: call to undeclared function '_byteswap_ulong'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 3rdparty/jxrlib/jxrgluelib/JXRGlueJxr.c:66:48: error: call to undeclared library function 'wcslen' with type 'unsigned long (const int *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] ``` On non-Windows hosts `_byteswap_ulong` is defined in `image/sys/strcodec.c` but not declared in any header, and `JXRGlueJxr.c` does not include `<wchar.h>`. With the `__ANSI__` branch of `configure_jxr_native` these only warn on GCC 13 (the Linux CI), but GCC 14 also turns `-Wimplicit-function-declaration` into an error by default, so newer Linux toolchains should hit the same thing (not run here). Since `libSceJxr` links `jxr`, the default build fails, not only the JXR tests. As a local check I added `target_compile_options(${target} PRIVATE -Wno-error=implicit-function-declaration)` to the non-Windows branch of `cmake/Jxr.cmake`. With that, `jxr` builds and all four tests pass: `guest_jxr_lookup_reference`, `guest_jxr_lookup`, `guest_jxr_lookup_patched`, `guest_jxr` (4/4). Both implicit declarations match the real signatures on x86-64, so silencing them is safe. Forcing in a prototype and `<wchar.h>` would work too. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
MarcZX10 commented 2026-10-23 06:13:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:13:18Z.

Review: DISMISSED


Reviewed exact head 807965be9fc56465ab07b18bfd191cb3474fe0b0. The Linux patched-library dependency failure reported on the older head appears resolved by the focused 4/4 run, but the current PR still has a reproducible platform build blocker: Apple Clang fails compiling the newly added jxrlib target because _byteswap_ulong is used without a visible declaration in segdec.c, and wcslen is used without including its declaration in JXRGlueJxr.c. The new configure_jxr_native does not provide either declaration on non-Windows builds; the author’s local workaround of downgrading implicit-declaration errors is not in this head and would leave undeclared-call ABI assumptions in code. Please fix the declarations/includes (or otherwise provide correctly typed declarations) and rerun the focused JXR build on Apple Clang. This request is for the newly added default-build dependency failing on a supported compiler, independent of intake. The Windows relinker job also currently reports four 120-second tooling-test timeouts; I have not reproduced those locally, so please distinguish that CI infrastructure/tooling failure from the JXR compile issue when reporting reruns.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5624609590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9954#pullrequestreview-5624609590). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T06:13:18Z. **Review:** DISMISSED --- Reviewed exact head `807965be9fc56465ab07b18bfd191cb3474fe0b0`. The Linux patched-library dependency failure reported on the older head appears resolved by the focused 4/4 run, but the current PR still has a reproducible platform build blocker: Apple Clang fails compiling the newly added jxrlib target because `_byteswap_ulong` is used without a visible declaration in `segdec.c`, and `wcslen` is used without including its declaration in `JXRGlueJxr.c`. The new `configure_jxr_native` does not provide either declaration on non-Windows builds; the author’s local workaround of downgrading implicit-declaration errors is not in this head and would leave undeclared-call ABI assumptions in code. Please fix the declarations/includes (or otherwise provide correctly typed declarations) and rerun the focused JXR build on Apple Clang. This request is for the newly added default-build dependency failing on a supported compiler, independent of intake. The Windows relinker job also currently reports four 120-second tooling-test timeouts; I have not reproduced those locally, so please distinguish that CI infrastructure/tooling failure from the JXR compile issue when reporting reruns.
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!9954
No description provided.