Skip to content

fix(libSceAgc): write the console's context push packets for ContextStateOp 1 - #20548

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
AdriaanBoshoff:fix/libSceAgc-context-state-push
Nov 29, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
AdriaanBoshoff:fix/libSceAgc-context-state-push

Conversation

@AdriaanBoshoff

Copy link
Copy Markdown
Contributor

What

prosper's agcbuild console measurements (tools/library-oracle) show sceAgcDcbContextStateOp(buf, 1) writing 5 words and returning the first one:

c0012800 00000000 80018001    CONTEXT_CONTROL  load 0, shadow 0x80018001
c0001200 00000001             CLEAR_STATE      1

AnyPS5 wrote KytyPS5's 27-word sequence of NOP markers instead (agcbuild_DcbContextStateOp_b).

  • sceAgcDcbContextStateOp now writes those two packets for operation 1. Operations 0, 2 and 3 were not measured, so they still go through sceAgcDcbContextStateOp_0100, which is unchanged.
  • The driver ran every CLEAR_STATE as a clear. It now treats commands 0 to 3 as clear, push, pop and push-clear, sharing the code of the CONTEXT_STATE NOP operations. Without this, the console's operation-1 packet would clear the context instead of saving it. Commands 4 to 15 are now refused rather than run as a clear.
  • CONTEXT_CONTROL accepts the shadow-control word 0x80018001 from that packet. The driver keeps no shadow memory, and the packet requests no load.
  • For operations above 3 (_a and _c), the console writes only CLEAR_STATE with the operation's low bits and returns null. The two measured values, 1 and 2, can't tell a 2-bit mask from a 4-bit one, so AnyPS5 still throws and both entries stay in known.tsv.
  • sceAgcDcbContextStateOpGetSize(1) still reports KytyPS5's 108 bytes, more than the 20 written. The debt entry records this.
  • Tests:
    • agc_context_state_size_tests checks the console packet word for word.
    • agc_driver_graphics_tests runs push, pop and push-clear through CLEAR_STATE.
    • agc_driver_tests now submits commands 0 to 3 and expects 4 and 15 to be refused.
  • Debt entries in libSceAgc.md and libSceAgcDriver.md. Reading CLEAR_STATE 1 as a push is inferred from AnyPS5's existing meaning of operation 1. It is not measured.

Tested

Windows 11, WinLibs GCC 15.2.0, Release.

  • ctest -R "agc_context_state_size|^agc_commands$|^agc_driver_graphics$|^agc_driver$|agc_command": 8 of 8 pass.
  • library_oracle.py agcbuild: 146 known findings, 0 new. DcbContextStateOp_b now matches.
  • 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

…tateOp 1

sceAgcDcbContextStateOp(1) writes CONTEXT_CONTROL with shadow control
0x80018001 and CLEAR_STATE 1, as measured by agcbuild_DcbContextStateOp_b.
The driver now runs CLEAR_STATE commands 1 to 3 as push, pop and
push-clear instead of always clearing, and accepts that shadow control.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 15, 2026

@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 — no blocking findings

The reviewed change matches the stated scope, and no blocking defect was verified in the inspected code.

What I ran

No commands or tests were run. The author reports Windows 11 test and oracle results in the PR description; those results were not independently verified. Reviewed head: f8db0aa9ca56c3b630b7b8bf5cacd94a12a8caaa.

Results

Check Result Note
Source review passed Changed behavior and relevant callers inspected
Tests not run Results supplied by author only
Console measurements not run Measurement claims supplied by author

Findings

Blocking

None.

Non-blocking

None.

Not verified

The reported test, oracle, and conventions checks were not run independently. Physical-console packet behavior and the inferred CLEAR_STATE command meanings were not verified. All eight changed files listed in review/manifest.json were read; Packet.cpp was also read to check buffer reservation behavior. No changed files were excluded in review/manifest.json.

To get this to a good state

Nothing is required.

@blawesom

Copy link
Copy Markdown
Contributor

Validation: PR #20548 (Linux/AMD, RADV) — PASS

Independent end-to-end run of head f8db0aa9ca56c3b630b7b8bf5cacd94a12a8caaa (fix/libSceAgc-context-state-push), 2026-11-15. Validation only — no code changes, no push.

Environment: CachyOS, kernel 7.3.4-1-cachyos x86-64 · GCC 16.2.1 · CMake 4.4.5 / Ninja 1.13.2 · AMD Radeon RX 9070 XT (RADV GFX1201, Vulkan 1.4.354) · Khronos validation layer 1.4.363 via VK_LAYER_PATH (≥ required 1.4.335) · Release, BUILD_TESTING=ON, builds capped at --parallel 12 (CMAKE_BUILD_PARALLEL_LEVEL=12 GOMAXPROCS=12), sequential ctest.

Merge baseline: merge-base with origin/main = 35ff88317949567ea35374f49a9056590cb2dc77; git merge-tree --write-tree origin/main HEAD → clean, no conflicts. Single commit, +70/−19 over 8 files (ContextState.cpp, ContextStateSize.cpp, Pm4.cpp, tests/{Pm4,Submit}.cpp, debt docs, known.tsv).

Gate 1 — build: configure + cmake --build build --parallel 12 → exit 0, 10439 targets, 6m13s wall. Base worktree (merge-base) built identically, exit 0, 6m14s.

Gate 2 — focused GPU tests, head vs base, same host/GPU (ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer): 41-test regex covering the changed files (agc_driver_pm4*, agc_context_state_size, agc_driver_submit*, guest_agc_pm4_nop, guest_gnm_neo_context_state*, plus eop/wait/copy/trace AGC driver tests): head 41/41 Passed (19.8s), base 41/41 Passed (19.8s), identical test-name sets, no failures → no flake reruns needed. Layer inserted 8× head / 8× base, was not found but was requested by env var VK_INSTANCE_LAYERS = 0, VUID- lines 0 on both — no new VUID IDs.

Gate 3 — repo checks: check_conventions.py --base origin/main → pass. pr_overlap.py --branch → exit 2 (failed closed, informational): shared-file PRs worth a manual look: #6186, #18914, #19191, #6188, #10249 on Pm4.cpp. Not a defect in this PR.

Gate 4 — reproducers: agc_context_state_size_tests (new testConsolePush), agc_driver_pm4_tests pm4, agc_driver_pm4_tests context-reg-rmw, agc_driver_tests (incl. changed testClearState) — all exit 0, layer inserted 4/4, 0 VUIDs.

Verdict: PASS. Logs under /home/benj/val-20548/wt-{head,base}/logs/. Environment-specific to RADV GFX12. AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 15, 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 4448 docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6186 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6808 docs/dev/debt/libSceAgcDriver.md
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 9289 docs/dev/debt/libSceAgcDriver.md
PR 9335 docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9508 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9915 docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10193 docs/dev/debt/libSceAgcDriver.md
PR 10359 docs/dev/debt/libSceAgcDriver.md
PR 10743 docs/dev/debt/libSceAgcDriver.md
PR 11551 docs/dev/debt/libSceAgcDriver.md
PR 11825 docs/dev/debt/libSceAgcDriver.md
PR 12792 docs/dev/debt/libSceAgcDriver.md
PR 12944 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 13809 docs/dev/debt/libSceAgcDriver.md
PR 13863 docs/dev/debt/libSceAgcDriver.md
PR 13920 docs/dev/debt/libSceAgcDriver.md
PR 13928 docs/dev/debt/libSceAgcDriver.md
PR 13929 docs/dev/debt/libSceAgcDriver.md
PR 14944 docs/dev/debt/libSceAgcDriver.md
PR 14964 docs/dev/debt/libSceAgcDriver.md
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
docs/dev/debt/libSceAgcDriver.md
PR 15456 docs/dev/debt/libSceAgcDriver.md
PR 15529 docs/dev/debt/libSceAgcDriver.md
PR 15621 docs/dev/debt/libSceAgcDriver.md
PR 15845 docs/dev/debt/libSceAgcDriver.md
PR 16260 docs/dev/debt/libSceAgcDriver.md
PR 16427 docs/dev/debt/libSceAgcDriver.md
PR 17742 docs/dev/debt/libSceAgc.md
PR 17943 docs/dev/debt/libSceAgcDriver.md
PR 18082 docs/dev/debt/libSceAgcDriver.md
PR 18914 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 19610 docs/dev/debt/libSceAgcDriver.md
PR 19821 docs/dev/debt/libSceAgcDriver.md
PR 20010 docs/dev/debt/libSceAgcDriver.md
PR 20084 docs/dev/debt/libSceAgcDriver.md
PR 20153 docs/dev/debt/libSceAgcDriver.md
PR 20172 core/libs/prx/libSceAgcDriver/tests/Submit.cpp
PR 20405 tools/library-oracle/known.tsv
PR 21059 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
PR 21649 docs/dev/debt/libSceAgcDriver.md
PR 21653 tools/library-oracle/known.tsv
PR 22062 docs/dev/debt/libSceAgcDriver.md
PR 22434 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22535 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
tools/library-oracle/known.tsv
PR 22574 tools/library-oracle/known.tsv
PR 22647 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
docs/dev/debt/libSceAgcDriver.md
PR 22667 core/libs/prx/libSceAgc/DcbState/src/ContextState.cpp
core/libs/prx/libSceAgc/tests/ContextStateSize.cpp
tools/library-oracle/known.tsv
PR 22731 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 23188 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
tools/library-oracle/known.tsv
PR 27133 docs/dev/debt/libSceAgcDriver.md
PR 27635 core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp
core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 27684 core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
PR 27775 core/libs/prx/libSceAgcDriver/tests/Submit.cpp

@NathanFahey23

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head f8db0aa9ca, merged onto main b885c40a67 (a71404779e, clean merge).

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer loaded. GPU set: ctest -R '^(agc_\|shader\|video_out\|guest_video)' --parallel 4, one run per side.

main b885c40a67 merge a71404779e
GPU set 1843 pass, 20 skipped, 0 failed 1843 pass, 20 skipped, 0 failed
VUID- lines 0 0
tests built from the changed files (agc_context_state_size_tests, agc_driver_pm4*, agc_driver_submit_progress) 31 of 31 pass
homebrew, 30 s each (tools/title_run.py, cold shader cache) Jelly5 rendering 118.2, VLC rendering 119.5, DriftCheck rendering 59.9, PS5SX2 rendering 59.8, DOOM rendering 36.4 Jelly5 rendering 118.2, VLC rendering 119.5, DriftCheck rendering 59.9, PS5SX2 rendering 59.8, DOOM rendering 36.4

The one test not run on both sides is agc_driver_upload_cache_read_only_flush: its executable does not build on Windows on this main (setenv, fixed by #19899). The homebrew titles are Jelly5, VLC, DriftCheck, PS5SX2 and DOOM; fps is one run each, for whether they still render, not a performance comparison.

Not checked: AMD, Linux, macOS, any commercial title.

AI-assisted: yes

@domx4q

domx4q commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Linux NVIDIA run with the Khronos validation layer, since the runs so far are NVIDIA on Windows and RADV on Linux.

Setup: Arch Linux, kernel 7.3.4, GCC 16.2.1 Release, NVIDIA GeForce RTX 4090 (10de:2684), driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head f8db0aa9ca merged with --no-ff onto main e4caa07950 (1b398b028b, clean merge). agc_context_state_size_tests is EXCLUDE_FROM_ALL, so it was built explicitly on both sides.

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_context_state_size|^agc_commands$|^agc_driver_graphics$|^agc_driver$|agc_command|^agc_driver_pm4$' -V
main e4caa07950 this PR
ctest 9/9 passed 9/9 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 3 3
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- 0 0

The tests are agc_commands, agc_context_state_size_tests, agc_command_batch_failure, agc_command_batch_fence_failure, agc_command_state, agc_command_memory_reuse, agc_driver_pm4, agc_driver_graphics and agc_driver; this PR adds no test, it changes ContextStateSize.cpp, Pm4.cpp and Submit.cpp. The layer lines come from agc_command_memory_reuse (1) and agc_driver (2); the others create no Vulkan instance. Both Vulkan logs show the RTX 4090 (Vulkan device: NVIDIA GeForce RTX 4090, Selected GPU name=NVIDIA GeForce RTX 4090).

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@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

The changed packet encoding and PM4 handling look consistent with the stated measured operation-1 sequence, and the added tests cover the modeled push, pop, and push-clear behavior; I did not run tests.

What I ran

Reviewed head 82a8cd6b68674a9ac9d962f80451b2b2f3544c60 against base main. Read all changed lines in the nine files listed by the manifest, plus targeted context in Pm4.hpp, QueueState.hpp search results, and review/README.md. I did not run commands or tests.

Results

Check Result Note
Changed lines read passed All manifest entries inspected
Tests not run Author-reported results only
Console behavior not run Operation-1 packet described as measured

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author reports Windows 11 / WinLibs GCC 15.2.0 Release test and oracle results; I did not reproduce them. Console behavior beyond the described operation-1 measurement was not verified. The full text of changed files was present and the changed lines were read; files excluded by rule: none.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 25, 2026
@oneandonlydean
oneandonlydean merged commit 7401ec5 into boykopovar:main Nov 29, 2026
16 checks passed
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.

6 participants