Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
MathiasDevelopes:codex/pr-agc-stencil-clear-state
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
MathiasDevelopes:codex/pr-agc-stencil-clear-state

Conversation

@MathiasDevelopes

Copy link
Copy Markdown
Contributor

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

Copilot AI balanced review requested due to automatic review settings October 13, 2026 17:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

@github-actions github-actions Bot added docs agc libSceAgc* labels Oct 13, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 13, 2026
* perf(agc): fast-skip pure PM4 NOP packets during queue execution

(cherry picked from commit 139bf04)

Ported from upstream PR boykopovar#5481

* fix(agc): copy a shader, context or user config register to memory with COPY_DATA

A dispatch now leaves its initiator and, for DISPATCH_DIRECT, its group
counts in the shader registers, where the CP puts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5e36c08)

Ported from upstream PR boykopovar#5477

* fix(agc): accept reported vertex stage state

(cherry picked from commit 632331d)

Ported from upstream PR boykopovar#4341

* fix(agc): initialize stencil control and reference masks

(cherry picked from commit 85e0d98bba896002539365bb29a7a39a8e43f501)
(cherry picked from commit 13dca48)

Ported from upstream PR boykopovar#5347

* fix(agc): accept inactive vertex point size on non-point draws

(cherry picked from commit d4b59ce)

Ported from upstream PR boykopovar#4715

* fix(agc): treat type-0 texture descriptors as null

(cherry picked from commit 7e1e1ce)

Ported from upstream PR boykopovar#4779

* fix(agc): fall back out-of-range sceAgcInit versions to table 13

Pointer-shaped NID kW3GLb7QfPg calls from public homebrew succeed on console; returning an error left those titles failing init after boykopovar#4835.

(cherry picked from commit 939f784)

Ported from upstream PR boykopovar#5163 (debt-doc hunk dropped: file absent on main)

* fix(agc): clamp sceAgcInit versions above 13 inline

(cherry picked from commit 0cc5102)

Ported from upstream PR boykopovar#5163 (second commit)

* metal: adapt the shared AGC driver slice to the Metal execution loop

- skip pure PM4 NOP packets in the Metal packet loop (upstream PR boykopovar#5481)
- note the dispatch registers after direct and indirect Metal dispatch so
  COPY_DATA from a shader register works there (upstream PR boykopovar#5477)
- NullImageDescriptor delegates to IsNullTextureResource (upstream PR boykopovar#4779)
- tests: pm4 compute replay reads the dispatch initiator and group counts
  back through COPY_DATA; metal utility tests cover a type-0 image descriptor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

---------

Co-authored-by: Kikoarl <7354010+Kikoarl@users.noreply.github.com>
Co-authored-by: LeandroLP23 <leandroplacidi@gmail.com>
Co-authored-by: MarcZX100 <marczxrr@gmail.com>
Co-authored-by: MathiasDevelopes <25400788+MathiasDevelopes@users.noreply.github.com>
Co-authored-by: lorkydey <57268822+Lorkydey@users.noreply.github.com>
Co-authored-by: mazen <mazenshaar@hotmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@oneandonlydean oneandonlydean self-assigned this Oct 14, 2026
(cherry picked from commit 85e0d98bba896002539365bb29a7a39a8e43f501)
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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.

@oneandonlydean
oneandonlydean force-pushed the codex/pr-agc-stencil-clear-state branch from d6b29fd to 8d89265 Compare October 14, 2026 05:02
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@oneandonlydean
oneandonlydean merged commit 115dc95 into boykopovar:main Oct 14, 2026
8 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.

3 participants