feat(libSceJxr): release prediction rows #16851

Closed
MarrasFederico wants to merge 3 commits from upstream-pr/16851 into main
MarrasFederico commented 2026-11-07 18:16:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-07T18:16:55Z.


What

freePredInfo was a parameterless placeholder that threw. It now follows pinned jxrlib strPredQuant.c: a non-null pPredInfoMemory is released with the guest free and the field is cleared; the per-channel row pointers are left as they were. A codec without a block is left unchanged. A null codec throws std::invalid_argument where jxrlib dereferences it.

The test hands the codec a guest malloc block and checks that the free callback still observes the original pPredInfoMemory. After the callback returns, only that field is cleared: a full codec byte snapshot is compared, and the quantizers and prediction rows match an untouched reference copy. A second call is a no-op; a null codec throws.

freePredInfo - not measured on a PS5: prototype and layout are inferred from the export name; the debt entry is in docs/dev/debt/libSceJxr.md.

Tested

Ubuntu 26.04.1 LTS x86-64, GCC 15.2.0, Release, BUILD_TESTING=ON, base 5062ba1fa434906ad0075f4d46bc763946e21ca3. No PS5 hardware or title was tested; Windows and macOS were not tested.

  • Built core/libs/prx/libSceJxr/all serially with nice -n 19 cmake --build build --parallel 2 --target core/libs/prx/libSceJxr/all.

  • ctest --test-dir build -R 'guest_jxr' --output-on-failure passes (100% tests passed out of 15).

  • On current main the export is a parameterless placeholder that throws through NotImplemented_nid_no_patch, so the new assertions cannot pass there.

  • python3 tools/check_conventions.py --base upstream/main and git diff --check pass.

  • Regression control: moving the pointer clear before the guest free makes the callback-order assertion fail. Restored the source, rebuilt with the same serial limits, and all 15 JPEG XR tests pass.

  • pr_overlap.py returned 2. Compared every reported head (#14212, #15626, #15645, #15646, #15684, #15689, #15771, #15772, #15774, #16282, #16710, #16827) against its own merge base, including the original export and any new private-helper definitions: none implements the same export or helpers. Shared debt/header insertions remain. The related #16827 allocates prediction rows. It shares the LP64 assertion, header/helper insertion points, test heap fixture and inventory count; combine #16827 first and reconcile those common insertions, keeping one heap fixture. No functional dependency is required.

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:5204549542 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16851). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-07T18:16:55Z. --- ### What `freePredInfo` was a parameterless placeholder that threw. It now follows pinned jxrlib [strPredQuant.c](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/image/sys/strPredQuant.c#L158-L163): a non-null `pPredInfoMemory` is released with the guest `free` and the field is cleared; the per-channel row pointers are left as they were. A codec without a block is left unchanged. A null codec throws `std::invalid_argument` where jxrlib dereferences it. The test hands the codec a guest `malloc` block and checks that the free callback still observes the original `pPredInfoMemory`. After the callback returns, only that field is cleared: a full codec byte snapshot is compared, and the quantizers and prediction rows match an untouched reference copy. A second call is a no-op; a null codec throws. [freePredInfo](https://github.com/MarrasFederico/AnyPS5/blob/803bb4a9ea8ed8ba1eacd544f0d2e26a60d83ddc/core/libs/prx/libSceJxr/src/Predict.cpp) - not measured on a PS5: prototype and layout are inferred from the export name; the debt entry is in `docs/dev/debt/libSceJxr.md`. ### Tested <!-- 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. --> Ubuntu 26.04.1 LTS x86-64, GCC 15.2.0, Release, `BUILD_TESTING=ON`, base `5062ba1fa434906ad0075f4d46bc763946e21ca3`. No PS5 hardware or title was tested; Windows and macOS were not tested. - Built `core/libs/prx/libSceJxr/all` serially with `nice -n 19 cmake --build build --parallel 2 --target core/libs/prx/libSceJxr/all`. - `ctest --test-dir build -R 'guest_jxr' --output-on-failure` passes (100% tests passed out of 15). - On current `main` the export is a parameterless placeholder that throws through `NotImplemented_nid_no_patch`, so the new assertions cannot pass there. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - Regression control: moving the pointer clear before the guest free makes the callback-order assertion fail. Restored the source, rebuilt with the same serial limits, and all 15 JPEG XR tests pass. - `pr_overlap.py` returned 2. Compared every reported head (#14212, #15626, #15645, #15646, #15684, #15689, #15771, #15772, #15774, #16282, #16710, #16827) against its own merge base, including the original export and any new private-helper definitions: none implements the same export or helpers. Shared debt/header insertions remain. The related #16827 allocates prediction rows. It shares the LP64 assertion, header/helper insertion points, test heap fixture and inventory count; combine #16827 first and reconcile those common insertions, keeping one heap fixture. No functional dependency is required. ### 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 -->
gabichuuuuu commented 2026-11-08 18:18:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T18:18:48Z.

Review: COMMENTED


Windows run of head bd430edbb7, merged alone onto main f35f1e5eca (clean merge). Setup: Windows 11, WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release, BUILD_TESTING=ON.

  • All 16 guest_jxr* tests with --repeat until-fail:5: every run passes.
  • No runnable negative control: with main's libSceJxr/Export.cpp and this PR's header, the build stops with conflicting declaration of C function, because the test calls exports whose signatures only exist with this PR.

Merge order: every open libSceJxr PR from this series edits the same "remaining stubs" line in docs/dev/debt/libSceJxr.md, so each merge will conflict with the next one there.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5819052895 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16851#pullrequestreview-5819052895). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T18:18:48Z. **Review:** COMMENTED --- Windows run of head `bd430edbb7`, merged alone onto `main` `f35f1e5eca` (clean merge). Setup: Windows 11, WinLibs GCC 15.2 (`x86_64-ucrt-posix-seh`), Release, `BUILD_TESTING=ON`. - All 16 `guest_jxr*` tests with `--repeat until-fail:5`: every run passes. - No runnable negative control: with `main`'s `libSceJxr/Export.cpp` and this PR's header, the build stops with `conflicting declaration of C function`, because the test calls exports whose signatures only exist with this PR. **Merge order:** every open libSceJxr PR from this series edits the same "remaining stubs" line in `docs/dev/debt/libSceJxr.md`, so each merge will conflict with the next one there.

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