fix(agc): initialize stencil control and reference masks #5347

Merged
MathiasDevelopes merged 1 commit from upstream-pr/5347 into main 2026-10-14 09:48:15 +00:00
MathiasDevelopes commented 2026-10-13 17:37:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-13T17:37:54Z.


What

Initialize DB_STENCIL_CONTROL, DB_STENCILREFMASK and DB_STENCILREFMASK_BF (context 0x10b–0x10d) to zero on a new queue and after CLEAR_STATE. Planet Coaster (PPSA01736 v01.017) enables stencil tests without writing the control register and stopped at missing register in context bank at DWORD 0x10b (267).

The values come from libSceAgc's public register-default tables V0, V4, V5 and V7–V11. Linux's GFX10 clear-state table agrees on the control register but differs on the reference masks; the source and unmeasured console reset behavior are recorded in technical debt. Missing registers elsewhere still throw.

Regressions cover unwritten front/back stencil state, explicit overrides, context reset and the PM4 CLEAR_STATE packet. Both new regressions failed on unmodified main, including the title's exact 0x10b error.

Overlap check: #4949 adds sample-location defaults to the same initializer at different lines, with tests elsewhere in Graphics.cpp. No duplicate stencil-default fix was found.

Tested

  • Windows x64, build 26300.9457; bundled MinGW-w64 GCC 15.2.0, Release, BUILD_TESTING=ON.
  • Independent branch tested on main 61b8742b6: built agc_driver_graphics_tests and agc_driver_pm4_tests; ctest --test-dir build -R '^agc_driver_(graphics|pm4)$' --output-on-failure passed (2/2; 0.11 s and 6.06 s). Subsequently rebased onto 8cf6a0bc3; intervening upstream changes affect only the README and demo page. Conventions and whitespace checks passed after the rebase.
  • The full runtime libs target was built on the combined bring-up branch. With the separate fiber stack-range fix also applied, Planet Coaster passes the missing-register failure, reaches the main menu and plays audio. The tester reports about 0.2 FPS, a black roller coaster and unresponsive input during the slowdown; an automated run also recorded a WatchDog illegal-instruction trap (0xc000001d, eboot.exe+0x2bf288). Title status: Game bring-up #5342. Full gameplay, Linux and other GPU vendors were not tested.

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 (the title validation also includes the separate fiber fix)
  • Unblocks: PPSA01736 #5342
  • GPUs tested: NVIDIA GeForce RTX 3060, driver 610.88 (32.0.16.1088), Windows x64 build 26300.9457; title runtime tested, state/PM4 regressions use host-side checks
  • AI-assisted: yes, OpenAI Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4847095845 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5347). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-13T17:37:54Z. --- ### What Initialize `DB_STENCIL_CONTROL`, `DB_STENCILREFMASK` and `DB_STENCILREFMASK_BF` (context `0x10b`–`0x10d`) to zero on a new queue and after `CLEAR_STATE`. Planet Coaster (PPSA01736 v01.017) enables stencil tests without writing the control register and stopped at `missing register in context bank at DWORD 0x10b (267)`. The values come from libSceAgc's public register-default tables V0, V4, V5 and V7–V11. Linux's GFX10 clear-state table agrees on the control register but differs on the reference masks; the source and unmeasured console reset behavior are recorded in technical debt. Missing registers elsewhere still throw. Regressions cover unwritten front/back stencil state, explicit overrides, context reset and the PM4 `CLEAR_STATE` packet. Both new regressions failed on unmodified `main`, including the title's exact `0x10b` error. Overlap check: [#4949](https://github.com/boykopovar/AnyPS5/pull/4949) adds sample-location defaults to the same initializer at different lines, with tests elsewhere in `Graphics.cpp`. No duplicate stencil-default fix was found. ### Tested - Windows x64, build 26300.9457; bundled MinGW-w64 GCC 15.2.0, Release, `BUILD_TESTING=ON`. - Independent branch tested on `main` `61b8742b6`: built `agc_driver_graphics_tests` and `agc_driver_pm4_tests`; `ctest --test-dir build -R '^agc_driver_(graphics|pm4)$' --output-on-failure` passed (2/2; 0.11 s and 6.06 s). Subsequently rebased onto `8cf6a0bc3`; intervening upstream changes affect only the README and demo page. Conventions and whitespace checks passed after the rebase. - The full runtime `libs` target was built on the combined bring-up branch. With the separate fiber stack-range fix also applied, Planet Coaster passes the missing-register failure, reaches the main menu and plays audio. The tester reports about 0.2 FPS, a black roller coaster and unresponsive input during the slowdown; an automated run also recorded a WatchDog illegal-instruction trap (`0xc000001d`, `eboot.exe+0x2bf288`). Title status: [Game bring-up #5342](https://github.com/boykopovar/AnyPS5/discussions/5342). Full gameplay, Linux and other GPU vendors were not tested. ### 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 (the title validation also includes the separate fiber fix) - [x] Unblocks: PPSA01736 [#5342](https://github.com/boykopovar/AnyPS5/discussions/5342) - [x] GPUs tested: NVIDIA GeForce RTX 3060, driver 610.88 (32.0.16.1088), Windows x64 build 26300.9457; title runtime tested, state/PM4 regressions use host-side checks - [x] AI-assisted: yes, OpenAI Codex
copilot-pull-request-reviewer[bot] commented 2026-10-13 17:38:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-13T17:38:00Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5507582495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5347#pullrequestreview-5507582495). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-13T17:38:00Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
oneandonlydean commented 2026-10-14 05:02:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:02:53Z.


Rebased onto main; no other change. Could someone with a title that sets stencil state through these registers run it on this head and post the result (title ID, GPU/OS, before/after)? It needs a run before it can go in.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161300933 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5347#issuecomment-6161300933). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:02:53Z. --- Rebased onto main; no other change. Could someone with a title that sets stencil state through these registers run it on this head and post the result (title ID, GPU/OS, before/after)? It needs a run before it can go in.
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!5347
No description provided.