feat(libSceJxr): release shared channel quantizers #16854

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

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


What

freeQuantizer was a parameterless placeholder that threw. It now follows pinned jxrlib strcodec.c: only a non-null pQuantizer[0] is released with the guest free, because allocateQuantizer takes one block and aliases the later channels into it. The table entries are not cleared. A null table throws std::invalid_argument where jxrlib dereferences it.

The test checks an empty table (no-op, entries unchanged), a three-channel table pointing into one guest malloc block (released once, channel pointers unchanged) and the null-table error.

freeQuantizer - not measured on a PS5: the prototype is 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 07c8408713ebb61e05814134a1707e6ff1c02709. 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: omitting the guest free makes the ownership 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, #16713, #16728, #16851) 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 #16728 implements allocateQuantizer; #16827 and #16851 concern different exports. Shared header and debt-count edits need reconciliation in merge order; there is no functional dependency.

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:5204613155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16854). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-07T18:24:49Z. --- ### What `freeQuantizer` was a parameterless placeholder that threw. It now follows pinned jxrlib [strcodec.c](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/image/sys/strcodec.c#L855-L859): only a non-null `pQuantizer[0]` is released with the guest `free`, because [allocateQuantizer](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/image/sys/strcodec.c#L839-L853) takes one block and aliases the later channels into it. The table entries are not cleared. A null table throws `std::invalid_argument` where jxrlib dereferences it. The test checks an empty table (no-op, entries unchanged), a three-channel table pointing into one guest `malloc` block (released once, channel pointers unchanged) and the null-table error. [freeQuantizer](https://github.com/MarrasFederico/AnyPS5/blob/3c0945f4b0787e8a97dd86d3a3ac791564744ca7/core/libs/prx/libSceJxr/src/Quantizer.cpp) - not measured on a PS5: the prototype is 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 `07c8408713ebb61e05814134a1707e6ff1c02709`. 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: omitting the guest free makes the ownership 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, #16713, #16728, #16851) 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 #16728 implements allocateQuantizer; #16827 and #16851 concern different exports. Shared header and debt-count edits need reconciliation in merge order; there is no functional dependency. ### 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:50 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Windows run of head 9dc01f4ac1, 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:5819052955 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16854#pullrequestreview-5819052955). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T18:18:50Z. **Review:** COMMENTED --- Windows run of head `9dc01f4ac1`, 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!16854
No description provided.