Skip to content

fix(libSceAgc): encode multi-draw and base indirect arguments as the console does - #20182

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
cristibctr:fix/agc-multi-draw-console-encoding
Nov 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
cristibctr:fix/agc-multi-draw-console-encoding

Conversation

@cristibctr

Copy link
Copy Markdown
Contributor

What

Three libSceAgc packet builders threw for arguments that a PS5 encodes:

  • sceAgcDcbDrawIndexIndirectMulti and sceAgcDcbDrawIndirectMulti threw for an unaligned data offset, an unaligned or short stride, a count selector other than 0 or 1, and a count address passed together with a direct count.
  • sceAgcDcbSetBaseIndirectArgs threw for a shader type above 1, an address that is not 8-byte aligned and an address above 48 bits.

Prosper's console measurements (DcbDrawIndexIndirectMulti_a/b/c, DcbDrawIndirectMulti_a/b/c, DcbSetBaseIndirectArgs_a/b/c) show that the console:

  • writes the multi-draw offset, count, count address and stride unchanged, and leaves the count-indirect bit clear for the selectors 0x22222222, 2 and 0x44444444 while still writing the count address;
  • builds the SET_BASE header as 0xc0021100 with the whole 32-bit shader type shifted left by one ORed in, clears bits 1 and 2 of the address and writes its high dword whole. For example shader type 0x11111111 with address 0x22222222 gives e2223322 00000001 22222220 00000000.

This PR encodes those arguments the same way. The nine cases now match and their rows are removed from tools/library-oracle/known.tsv.

Not settled by the measurements, so these still throw and are recorded in docs/dev/debt/libSceAgc.md:

  • a multi-draw count selector that is odd and above 1: no measurement has bit 0 set, so it is not known whether the console tests bit 0 or the value 1. Selector 1 keeps the earlier encoding (bit 30, a non-null 4-byte aligned count address);
  • an odd sceAgcDcbSetBaseIndirectArgs address: the three measured addresses have bits 0, 3 and 4 clear, so they fit a mask of the low 3, 4 or 5 bits. Bits 3 and 4 are kept, as before, on the assumption of an 8-byte alignment.

The multi-draw modifier is a seventh argument that the measurements do not pass; the measured packets equal those of a zero modifier. The driver's handling of these packets is unchanged.

tools/pr_overlap.py reports textual conflicts only, no shared exports:

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (r7), Release, BUILD_TESTING=ON, on main 61f33fc and on this branch:

  • ctest --test-dir build-main -R '^(agc_commands|agc_draw_setup|guest_indexed_draw)$' -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 3 of 3 pass on both. Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS or any VUID- line. These tests build packets on the CPU and create no Vulkan device.
  • agc_commands now checks the nine console packets, and that a selector of 1 with a null count address, an odd selector above 1 and an odd base address are refused without touching the buffer.
  • python3 tools/library-oracle/library_oracle.py --build build-main after libs and library_oracle_replay were rebuilt: 155 known findings, 0 new, 0 now matching with the nine rows removed.
  • python3 tools/check_conventions.py --base origin/main: all checks passed.

No title was run.

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: NVIDIA GeForce RTX 4070 Ti, driver 32.0.16.2114, Windows 11 Pro 10.0.26300 (the tests create no Vulkan device)
  • AI-assisted: yes

🤖 Generated with Claude Code

…console does

sceAgcDcbDrawIndexIndirectMulti and sceAgcDcbDrawIndirectMulti threw for
unaligned offsets, short or unaligned strides, count selectors other than
0 and 1, and a count address passed with a direct count.
sceAgcDcbSetBaseIndirectArgs threw for shader types above 1, addresses
that are not 8-byte aligned and addresses above 48 bits. Prosper's console
measurements encode all of these; the nine cases now match.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 14, 2026
@oneandonlydean
oneandonlydean merged commit 3203b5e into boykopovar:main Nov 14, 2026
16 checks passed
@github-actions

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 18795 tools/library-oracle/known.tsv L95-98
PR 19355 core/libs/prx/libSceAgc/DcbDraw/src/DrawIndexed.cpp L52-57, L59-60
core/libs/prx/libSceAgc/DcbDraw/src/DrawNonIndexed.cpp L26-32
core/libs/prx/libSceAgc/tests/Commands.cpp L188-190
tools/library-oracle/known.tsv L88-94, L96-101
PR 19357 tools/library-oracle/known.tsv L118-124

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 19191 docs/dev/debt/libSceAgc.md
tools/library-oracle/known.tsv

angrysandhill added a commit to angrysandhill/AnyPS5 that referenced this pull request Nov 14, 2026
Resolve known.tsv by removing both the multi-draw and base indirect rows
boykopovar#20182 removed and this change's register-direct rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants