Skip to content

fix(libSceAgc): encode sceAgcCbBranch register arguments as the console does - #21376

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
AdriaanBoshoff:fix/libSceAgc-cb-branch-console-encoding
Nov 25, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
AdriaanBoshoff:fix/libSceAgc-cb-branch-console-encoding

Conversation

@AdriaanBoshoff

Copy link
Copy Markdown
Contributor

What

prosper's agcbuild console measurements (tools/library-oracle) show sceAgcCbBranch masking its register arguments instead of rejecting them:

case mode compare function compare address word 1 address written
_a 0x11 0x22 0x33333333 0x201 0x33333330
_b 1 2 3 0x201 0
_c 0x22 0x44 0 0x402 0

AnyPS5 threw on the mode and compare-function bits and on the unaligned address.

  • The mode is masked to 2 bits and the compare function to 3 bits.
  • When the compare function is not 0, the low 3 bits of the compare address are cleared rather than checked. The data fits clearing 2, 3 or 4 bits; 3 matches the 8-byte alignment sceAgcBranchPatchSetCompareAddress already requires. Compare function 0 was not measured, so its address still passes through unchanged (testUnusedFields).
  • The cache policies, targets and sizes are the 7th to 12th arguments. The oracle replays them as stack garbage, so the three entries still throw on the size check. Their known.tsv reason is now the stack-argument one, as for AcbCopyData.
  • The driver still refuses to execute BRANCH packets, so this changes only the encoding.
  • agc_branch_patch_tests gains testConsoleArguments, which writes the three measured cases plus a compare-function-3 address that is 4- but not 8-byte aligned, and drops the failure expectation for that address.
  • Debt entry in libSceAgc.md.

Tested

Windows 11, WinLibs GCC 15.2.0, Release.

  • ctest -R agc_branch_patch: 1 of 1 pass.
  • library_oracle.py agcbuild: 144 known findings, 0 new.
  • python tools/check_conventions.py --base origin/main

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

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the measurements and encoding changes are consistent with the code inspected.

What I ran

Read the prepared diff and all four changed files at head e52442471d8d0fa2ce6d8285ecfaaf32cb409478, plus sceAgcBranchPatchSetCompareAddress to confirm the existing 8-byte patch alignment check. No commands or tests were run in this review.

Results

Check Result Note
Changed-file review passed All four changed files read
Tests not run Author reports Windows test and oracle runs

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported Windows 11 test, oracle, and convention-check results were not run or independently confirmed. No console behavior beyond the measurements described in the PR was verified. Read: core/libs/prx/libSceAgc/Cb/src/Branch.cpp, core/libs/prx/libSceAgc/tests/BranchPatch.cpp, docs/dev/debt/libSceAgc.md, and tools/library-oracle/known.tsv. No changed files were excluded.

To get this to a good state

Nothing is required.

@github-actions

github-actions Bot commented Nov 16, 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 17742 docs/dev/debt/libSceAgc.md
PR 23188 tools/library-oracle/known.tsv

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 16, 2026
…le does

The console masks the mode to 2 bits and the compare function to 3 bits
and clears the low bits of the compare address instead of rejecting them.
The remaining oracle mismatches come from stack arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AdriaanBoshoff
AdriaanBoshoff force-pushed the fix/libSceAgc-cb-branch-console-encoding branch from e524424 to 1e732ec Compare November 16, 2026 09:09
@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Validation-layer run of this PR on an NVIDIA GPU under Linux, since CI covers only lavapipe.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, -DBUILD_TESTING=ON; NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684), proprietary driver 620.70.06, Vulkan 1.4.357 (loader 1.4.363), Khronos validation layer 1.4.363.1. Head 1e732ecb5d merged onto main e4caa07950 (clean merge); main is the same commit built separately. This test selects no GPU.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
  ctest --test-dir build -R '^agc_branch_patch' -V
main e4caa07950 this PR
Result 1/1 pass 1/1 pass
Insert instance layer "VK_LAYER_KHRONOS_validation" 0 0
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

The test is the one from the Tested section; this PR extends tests/BranchPatch.cpp, so the same test runs on both builds (rebuilt on the merge) and is not skipped. It encodes command buffers on the CPU and creates no Vulkan instance, so the layer is never loaded (0 inserts on both builds): this run checks the encoding on Linux, not validation.

The focused test passes on Linux; no Vulkan instance is created, so there is nothing for the layer to validate.

AI-assisted: yes (Claude Code)

This was referenced Nov 21, 2026
@kiwe147

kiwe147 commented Nov 21, 2026

Copy link
Copy Markdown

Tested head 1e732ecb5d, applied with git apply on main fd4aeed483 together with the other 25 PRs of one batch (#24107, #24132, #24238, #15143, #22088, #22685, #23739, #24032, #16054, #20001, #20344, #24170, #24396, #16856, #17298, #20497, #23347, #24426, #24554, #24598, #21556, #22047, #22082, #14124, #18476). All applied without conflicts and the whole tree built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3080 (driver 621.24) and the AMD Radeon iGPU of the CPU (gfx1036, driver 32.0.21036.18). No validation layer. iGPU run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ANYPS5_GPU="AMD Radeon", agc_/video tests only.

tests RTX 3080 iGPU
agc_branch_patch_tests (1 test, matched by name to the test file this PR changes) all pass all pass

Whole batch: the full ctest -j 12 (6524 tests) on the RTX 3080 has 8 failing tests; the 4 that also fail on main fd4aeed483 are agc_driver_stencil_plane_memory, agc_driver_msaa_dcc_unwatch, agc_storage_write_back_host_retile, and pr_overlap_names, which needs a newer Python than my 3.10. Intermittent in this run (pass when rerun alone, or known flaky): agc_driver_store_over_untracked. Traced to other PRs of the batch, each by reverting it and testing again: #21556 (guest_json_allocator), #16856 (guest_kernel_sys_module_internal), #15143 (guest_math_exact); none is in this PR's area. Failing tests I could not trace to a single PR (reverting the likely candidates did not clear them): public_headers. The 2127 agc_/video tests on the iGPU have 2 failing: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked (agc_driver_stencil_plane_memory also fails on main).

This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants