feat(libSceJxr): implement PKFree as jxrlib does #9540

Merged
alvaroelpob merged 1 commit from upstream-pr/9540 into main 2026-10-22 23:59:46 +00:00
alvaroelpob commented 2026-10-22 00:53:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-22T00:53:37Z.


What

Implements PKFree in libSceJxr. The module's four named exports (PKFree, PixelFormatLookup, readIS, writeIS) are all functions from Microsoft's jxrlib, so PKFree follows jxrlib's JXRGlue.c:

  • ERR PKFree(void** ppv): a non-null ppv has *ppv released with the guest free and set to null; a null ppv does nothing.
  • It always returns WMP_errSuccess (0). ERR is long, so the export returns a 64-bit value.

PixelFormatLookup, readIS and writeIS still throw: PixelFormatLookup needs jxrlib's pixel format table, and readIS/writeIS work on the codec's internal bit I/O state. The debt entry now covers only those three, and a new Functional entry records that PKFree follows jxrlib and is not checked against the console's code.

The module gets a CMakeLists.txt so it can register guest_jxr, which installs a recording application allocator, frees a guest malloc block through PKFree, and checks that the allocator's free received that block and the pointer is cleared. It then calls PKFree with the cleared pointer and with a null ppv, and checks that both return 0 and free nothing.

Tested

Ubuntu (WSL2), GCC 15.2.0, Release: ctest --test-dir build -R guest_jxr --output-on-failure passes. No title imports PKFree that I know of, so it has not run under a title.

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:4960400035 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9540). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-22T00:53:37Z. --- ### What Implements `PKFree` in libSceJxr. The module's four named exports (`PKFree`, `PixelFormatLookup`, `readIS`, `writeIS`) are all functions from Microsoft's jxrlib, so `PKFree` follows jxrlib's [JXRGlue.c](https://github.com/4creators/jxrlib/blob/f7521879862b9085318e814c6157490dd9dbbdb4/jxrgluelib/JXRGlue.c#L53-L62): - `ERR PKFree(void** ppv)`: a non-null `ppv` has `*ppv` released with the guest `free` and set to null; a null `ppv` does nothing. - It always returns `WMP_errSuccess` (0). `ERR` is `long`, so the export returns a 64-bit value. `PixelFormatLookup`, `readIS` and `writeIS` still throw: `PixelFormatLookup` needs jxrlib's pixel format table, and `readIS`/`writeIS` work on the codec's internal bit I/O state. The debt entry now covers only those three, and a new Functional entry records that `PKFree` follows jxrlib and is not checked against the console's code. The module gets a `CMakeLists.txt` so it can register `guest_jxr`, which installs a recording application allocator, frees a guest `malloc` block through `PKFree`, and checks that the allocator's `free` received that block and the pointer is cleared. It then calls `PKFree` with the cleared pointer and with a null `ppv`, and checks that both return 0 and free nothing. ### 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 (WSL2), GCC 15.2.0, Release: `ctest --test-dir build -R guest_jxr --output-on-failure` passes. No title imports `PKFree` that I know of, so it has not run under a title. ### 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-22 00:53:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-22T00:53:44Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608003991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9540#pullrequestreview-5608003991). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-22T00:53:44Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
MarcZX10 commented 2026-10-22 01:02:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:02:15Z.

Review: APPROVED


I checked the upstream jxrlib PKFree implementation and ABI (ERR is long), then reviewed the guest allocator test and debt scope. The code matches the pinned source behavior: it frees and nulls a non-null pointee, tolerates null inputs, and returns success. The hosted conventions and labels checks pass; no product build is currently configured for this PR, and the author reports the focused WSL2 test. I found no blocking issue in the reviewed diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608055216 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9540#pullrequestreview-5608055216). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:02:15Z. **Review:** APPROVED --- I checked the upstream jxrlib PKFree implementation and ABI (`ERR` is `long`), then reviewed the guest allocator test and debt scope. The code matches the pinned source behavior: it frees and nulls a non-null pointee, tolerates null inputs, and returns success. The hosted conventions and labels checks pass; no product build is currently configured for this PR, and the author reports the focused WSL2 test. I found no blocking issue in the reviewed diff.
MarcZX10 commented 2026-10-22 11:34:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:34:17Z.


I rechecked the current head against upstream main: the merge is clean, but the sync check reports 1 commit ahead / 119 behind (base a6dcea927). The allocator behavior and test registration look consistent with the repo; your PR reports the focused guest_jxr test passing. Please refresh onto current main and rerun the focused test plus conventions before merge so the checklist reflects the current base.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6339734774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9540#issuecomment-6339734774). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T11:34:17Z. --- I rechecked the current head against upstream `main`: the merge is clean, but the sync check reports 1 commit ahead / 119 behind (base `a6dcea927`). The allocator behavior and test registration look consistent with the repo; your PR reports the focused `guest_jxr` test passing. Please refresh onto current `main` and rerun the focused test plus conventions before merge so the checklist reflects the current base.
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!9540
No description provided.