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

Merged
AdriaanBoshoff merged 2 commits from upstream-pr/20548 into main 2026-11-29 09:05:19 +00:00
AdriaanBoshoff commented 2026-11-15 09:45:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AdriaanBoshoff on 2026-11-15T09:45:57Z.


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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5321499615 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20548). Originally posted by [AdriaanBoshoff](https://github.com/AdriaanBoshoff) on 2026-11-15T09:45:57Z. --- ### 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 - [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
MarcZX10 commented 2026-11-15 11:00:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-15T11:00:27Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5910350152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20548#pullrequestreview-5910350152). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-15T11:00:27Z. **Review:** COMMENTED --- # 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.
MarcZX10 commented 2026-11-25 11:23:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T11:23:04Z.

Review: APPROVED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6056715327 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/20548#pullrequestreview-6056715327). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T11:23:04Z. **Review:** APPROVED --- # 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.
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!20548
No description provided.