Skip to content

feat(libSceJxr): implement codec row-state and coding-context reset helpers - #15689

Merged
13 commits merged into
boykopovar:mainfrom
Noxy-HNR:claude/jxr-row-state
Nov 9, 2026
Merged

13 commits merged into
boykopovar:mainfrom
Noxy-HNR:claude/jxr-row-state

Conversation

@Noxy-HNR

@Noxy-HNR Noxy-HNR commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What

Implements seven libSceJxr exports as thin adapters over the pinned jxrlib (3rdparty/jxrlib, f7521879862b9085318e814c6157490dd9dbbdb4), through a C bridge in jxr_lookup_native:

  • checkImageBuffer and getTilePos (strcodec.c)
  • initMRPtr, advanceMRPtr, advanceOneMBRow and swapMRPtr (strcodec.c)
  • ResetCodingContext (image.c)

They act on the caller's LP64 CWMImageStrCodec (35,944 bytes) and its alpha codec, or on a 704-byte CCodingContext. _Static_asserts pin the sizes and the field offsets used. The prototypes come from jxrlib's strcodec.h; matching the export names to them is an inference.

  • Writes go through GuestArena::HostWrite. A codec, alpha codec or context that the host may not write throws std::invalid_argument, and no byte changes. checkImageBuffer only reads.
  • Inputs that would make jxrlib read or write out of bounds throw std::invalid_argument instead:
    • a null codec or context
    • more than 16 channels in either codec
    • more than 4096 tile columns or rows
    • a current tile index past the last tile when it would be read
    • in advanceMRPtr: a secondary codec (jxrlib asserts this), an unknown color format (it indexes cblkChromas), or a null row buffer it would advance

The debt entry records what is inferred, and the remaining-export count drops by seven.

Tested

New guest_jxr_rows test. It builds randomized codec pairs and runs each export on one copy and jxrlib's own function on a clone. It then compares the codecs (pointers by offset), row buffers, prediction rows and coding context. Coverage:

  • checkImageBuffer: YUV and non-YUV data, 7 color formats, 6 bit depths, 8 unit sizes and random strides, at each of 6 widths × 7 row counts.
  • getTilePos: walks a 12×8 macroblock grid for every 1–4 × 1–4 tile layout.
  • Row pointers: all 9 color formats, 1, 3, 4 and 16 channels, with and without an alpha codec, through initMRPtr, three advanceMRPtr calls, swapMRPtr and advanceOneMBRow.
  • ResetCodingContext: 8 random contexts.
  • Every rejection listed above.
  • Windows only: 7 guest direct-memory pages are made read-only with sceKernelMprotect, and PAGE_READONLY is confirmed with VirtualQuery. checkImageBuffer still reads the codec. Each mutating export throws with every page byte-for-byte unchanged, including when only the alpha codec is read-only. After write access is restored, the calls succeed.
  • Negative controls: on Windows, with the codec write check in Rows.cpp removed, the test crashes with an access violation (0xc0000005) on the read-only page. On Linux, with the jxrlib calls in getTilePos and swapMRPtr stubbed out, it fails with "getTilePos differs from jxrlib".

Results:

No console or retail-title test.

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: feat(libSceJxr): implement quantizer sharing and DC/AC prediction state helpers #15479
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

…te helpers

setUniformQuantizer, useDCQuantizer, useLPQuantizer, getDCACPredMode and
updatePredInfo call the pinned jxrlib on the caller's codec state, after
checking the tile, channel, column and color format bounds those calls
rely on. The test compares every export with jxrlib on randomized codec
state across tile counts, channel counts, contexts and color formats.
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Progress report (947c9dc → 96c37ed)

📈 System libraries: 30.44% (+0.04%, +12 implemented functions)

✅ 12 implemented
Library Name
libSceJxr ResetCodingContext_nid_postfix
libSceJxr advanceMRPtr_nid_postfix
libSceJxr advanceOneMBRow_nid_postfix
libSceJxr checkImageBuffer_nid_postfix
libSceJxr getDCACPredMode_nid_postfix
libSceJxr getTilePos_nid_postfix
libSceJxr initMRPtr_nid_postfix
libSceJxr setUniformQuantizer_nid_postfix
libSceJxr swapMRPtr_nid_postfix
libSceJxr updatePredInfo_nid_postfix
libSceJxr useDCQuantizer_nid_postfix
libSceJxr useLPQuantizer_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libSceJxr 43/136 (31.62%) 55/136 (40.44%) +8.82%

@JJenkx

JJenkx commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 3f289497fb, merged onto main 5b1d381d5a (4245ebc16b, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run this test on pull requests.

  • guest_jxr_rows passes in 3 of 3 runs.

AI-assisted: yes.

@TechLevelZero

Copy link
Copy Markdown
Contributor

✅ AMD GPU test: passed

PR head 3f28949 merged onto main b11c7bf · tested 2026-11-04 21:17 UTC · 21 min

GPU AMD Radeon RX 6300 (RADV NAVI24), driver Mesa 25.2.8-0ubuntu0.24.04.4, Vulkan 1.4.318
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-42-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,162 passed · 10 failed (0 new, 6 also fail on main, 4 unstable on main) · 10 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,182 of 3,894 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (967 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_graphics_maps_fallback 120.2 s, ⚠️ agc_driver_pipeline_journal 120.2 s, ⚠️ agc_driver_graphics 107.1 s, ⚠️ public_headers 77.9 s, ⚠️ agc_driver_bda_device 71.5 s
Unstable on main (4, these also failed in recent main runs on this machine; not counted against this PR)
agc_driver_graphics_maps_fallback: failed in 2 of the last 10 main runs
agc_driver_pipeline_journal: failed in 8 of the last 10 main runs
agc_driver_two_sample_alpha_to_coverage_sample_mask_export: failed in 3 of the last 10 main runs
guest_pthread_start: failed in 1 of the last 10 main runs
Failing on main too (6, not counted against this PR)
agc_driver_alpha_to_coverage_sample_mask_export
agc_driver_guest_memory_lifetime_direct
agc_driver_image_table
agc_driver_native_depth_bda_clear
agc_driver_native_multisample_depth
agc_driver_submit_progress
Passed on retry (2, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)
agc_driver_emulated_color_compare_srgb_decode: Timeout in the parallel run; also passed only on retry in 26 other runs in the last 7 days
vulkan_validation_gate_attribution: Failed in the parallel run; also passed only on retry in 24 other runs in the last 7 days
Validated but not compared (64, not in the main baseline's validation pass)
public_headers
public_headers_compile_0
public_headers_compile_1
public_headers_compile_10
public_headers_compile_11
public_headers_compile_12
public_headers_compile_13
public_headers_compile_14
public_headers_compile_15
public_headers_compile_16
public_headers_compile_17
public_headers_compile_18
public_headers_compile_2
public_headers_compile_20
public_headers_compile_21
public_headers_compile_22
public_headers_compile_23
public_headers_compile_24
public_headers_compile_25
public_headers_compile_26
public_headers_compile_27
public_headers_compile_28
public_headers_compile_29
public_headers_compile_3
public_headers_compile_30
public_headers_compile_31
public_headers_compile_32
public_headers_compile_33
public_headers_compile_34
public_headers_compile_35
public_headers_compile_36
public_headers_compile_37
public_headers_compile_38
public_headers_compile_39
public_headers_compile_4
public_headers_compile_40
public_headers_compile_41
public_headers_compile_42
public_headers_compile_43
public_headers_compile_44
public_headers_compile_45
public_headers_compile_46
public_headers_compile_47
public_headers_compile_48
public_headers_compile_49
public_headers_compile_5
public_headers_compile_50
public_headers_compile_51
public_headers_compile_52
public_headers_compile_53
public_headers_compile_54
public_headers_compile_55
public_headers_compile_56
public_headers_compile_57
public_headers_compile_58
public_headers_compile_59
public_headers_compile_6
public_headers_compile_60
public_headers_compile_61
public_headers_compile_62
public_headers_compile_63
public_headers_compile_7
public_headers_compile_8
public_headers_compile_9
Validation IDs already present on main (8 IDs in 675 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (675 tests): agc_compute_pipeline_replay, agc_driver_address_draw_space_reuse, agc_driver_address_draw_space_reuse_held, agc_driver_address_draw_space_reuse_off, agc_driver_address_draw_space_reuse_transitions, agc_driver_address_draw_space_reuse_verify, agc_driver_address_passes, agc_driver_address_passes_draw_transitions, and 667 more
VUID-vkCmdCopyImage-srcImage-01548 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-vkCmdCopyImage-srcImage-01551 (11 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store_image_copy, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_partially_unmapped_plane, agc_driver_depth_plane_unmapped_plane, and 3 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
VUID-VkSamplerCreateInfo-addressModeU-01079 (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeU-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeV-parameter (1 test): agc_driver_image_gather_volume
VUID-VkSamplerCreateInfo-addressModeW-parameter (1 test): agc_driver_image_gather_volume
Skipped (10)
agc_driver_copied_writer_label_order: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_copied_writer_label_order_drain: skipped, the device reports a minStorageBufferOffsetAlignment of 4, so the dispatch binds its record at +0x1004 in place and nothing is written back; the test needs an alignment above 4
agc_driver_float16_unused_nan_payloads: skipped, the device has no native f16 conversions with RTE rounding and kept f16 denormals
agc_driver_gcn_display_present: skipped, no display: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
agc_driver_linear_target_direct_write_completion: skipped, the device does not keep host imports write-watched, so no completion stamp over the target is tracked
agc_driver_ngg_vertex_wave_reduction: skipped, s3 describes a 32-lane wave only on 32-lane subgroups, and the device has 64 lanes
agc_driver_scattered_runs: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
Reproduce
git fetch origin 3f289497fba7e4de564d741447e96fc1657fdffb b11c7bf84f5d2f636ff60166cc3371bd071e24d5
git checkout b11c7bf84f5d2f636ff60166cc3371bd071e24d5 && git merge --no-ff 3f289497fba7e4de564d741447e96fc1657fdffb
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 12 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 16 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Nov 5, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 5, 2026
# Conflicts:
#	core/libs/prx/libSceJxr/Export.cpp
#	core/libs/prx/libSceJxr/include/Api.hpp
#	docs/dev/debt/libSceJxr.md
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 6, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 7645 core/libs/prx/libSceJxr/CMakeLists.txt
PR 14212 docs/dev/debt/libSceJxr.md
PR 15626 core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 15645 core/libs/prx/libSceJxr/CMakeLists.txt
core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 15646 core/libs/prx/libSceJxr/CMakeLists.txt
core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 17400 core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 17401 core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 17402 core/libs/prx/libSceJxr/CMakeLists.txt
core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md
PR 17403 core/libs/prx/libSceJxr/CMakeLists.txt
core/libs/prx/libSceJxr/Export.cpp
core/libs/prx/libSceJxr/include/Api.hpp
docs/dev/debt/libSceJxr.md

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 7, 2026
@oneandonlydean oneandonlydean self-assigned this Nov 7, 2026
@oneandonlydean oneandonlydean closed this pull request by merging all changes into boykopovar:main in 847a356 Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build docs needs rebase Conflicts with main, rebase needed prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants