fix(agc): read an unwritten pixel program address as unset #2022

Merged
NahuelGenchi merged 1 commit from upstream-pr/2022 into main 2026-10-10 06:08:05 +00:00
NahuelGenchi commented 2026-10-09 05:14:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NahuelGenchi on 2026-10-09T05:14:20Z.


What

A depth/stencil-only draw whose pixel program address (SPI_SHADER_PGM_LO/HI_PS) was never written is rejected on main with:

AGC graphics: depth/stencil-only draws without a pixel shader are not implemented

The draw decoder already reads an unwritten address as 0 and binds the null pixel program for it (DecodeGraphicsPrograms, since #469). Only PixelProgramSkipped required both registers to be present and 0, and the precheck in DrawPrecheck.cpp rejected the never-written case before the draw got there.

  • PixelProgramSkipped now reads an unwritten SPI_SHADER_PGM_LO/HI_PS as unset, like a written 0. NullPixelProgramRejection then applies to such a draw too, so one that writes color is rejected as "a draw without a pixel program writes color", as with a written 0.
  • The precheck no longer rejects these draws. It still drops the ones that test neither depth nor stencil, as before.
  • The graphics test fixture makeState() now names a pixel program at 0x100. Its draws relied on an absent address being read as a real pixel program.

Tested

Ubuntu 26.04, GCC 15.2, Release build, AMD Radeon R9 380 (RADV, Mesa 26.0.8).

  • agc_driver_graphics passes. New checks: with both registers erased, the draw is read as having no pixel program, is rejected if it writes color, and is accepted as depth-only otherwise. Without the PixelProgramSkipped change the new check fails with an unwritten pixel program address was not read as unset.
  • Full ctest: 492/494. agc_driver_emulated_color_compare (needs shaderResourceMinLod, which GFX8 lacks) and agc_driver_f32_denormal_flush (v_fma_f32 denormal result on GFX8) fail the same way on main on this card.
  • Sonic Origins (PPSA05324), with #2004 and local workarounds for its earlier stops (see #2021): its depth/stencil clear draws have no pixel program and never write SPI_SHADER_PGM_LO_PS. Before, they stopped at the precheck above. With this change they reach the null pixel program variant, prepared shader artifact is missing for the requested static ABI ... stage=5 wave=64, which #1902 covers.
  • tools/check_conventions.py --base origin/main passes.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4796293249 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2022). Originally posted by [NahuelGenchi](https://github.com/NahuelGenchi) on 2026-10-09T05:14:20Z. --- ### What A depth/stencil-only draw whose pixel program address (`SPI_SHADER_PGM_LO/HI_PS`) was never written is rejected on `main` with: ```text AGC graphics: depth/stencil-only draws without a pixel shader are not implemented ``` The draw decoder already reads an unwritten address as 0 and binds the null pixel program for it (`DecodeGraphicsPrograms`, since #469). Only `PixelProgramSkipped` required both registers to be present and 0, and the precheck in `DrawPrecheck.cpp` rejected the never-written case before the draw got there. - `PixelProgramSkipped` now reads an unwritten `SPI_SHADER_PGM_LO/HI_PS` as unset, like a written 0. `NullPixelProgramRejection` then applies to such a draw too, so one that writes color is rejected as "a draw without a pixel program writes color", as with a written 0. - The precheck no longer rejects these draws. It still drops the ones that test neither depth nor stencil, as before. - The graphics test fixture `makeState()` now names a pixel program at 0x100. Its draws relied on an absent address being read as a real pixel program. ### Tested Ubuntu 26.04, GCC 15.2, Release build, AMD Radeon R9 380 (RADV, Mesa 26.0.8). - `agc_driver_graphics` passes. New checks: with both registers erased, the draw is read as having no pixel program, is rejected if it writes color, and is accepted as depth-only otherwise. Without the `PixelProgramSkipped` change the new check fails with `an unwritten pixel program address was not read as unset`. - Full `ctest`: 492/494. `agc_driver_emulated_color_compare` (needs `shaderResourceMinLod`, which GFX8 lacks) and `agc_driver_f32_denormal_flush` (`v_fma_f32` denormal result on GFX8) fail the same way on `main` on this card. - Sonic Origins (PPSA05324), with #2004 and local workarounds for its earlier stops (see #2021): its depth/stencil clear draws have no pixel program and never write `SPI_SHADER_PGM_LO_PS`. Before, they stopped at the precheck above. With this change they reach the null pixel program variant, `prepared shader artifact is missing for the requested static ABI ... stage=5 wave=64`, which #1902 covers. - `tools/check_conventions.py --base origin/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-09 05:22:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:22:25Z.

Review: APPROVED


Reviewed the full diff and the draw precheck/null pixel program flow. Treating unwritten LO/HI registers as zero matches the decoder behavior, the precheck no longer intercepts valid depth/stencil-only draws, and the fixture now declares its real pixel program. The added tests cover color rejection and depth-only acceptance. Linux, Windows, changes, conventions, and report checks pass for this head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5466032750 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2022#pullrequestreview-5466032750). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T05:22:25Z. **Review:** APPROVED --- Reviewed the full diff and the draw precheck/null pixel program flow. Treating unwritten LO/HI registers as zero matches the decoder behavior, the precheck no longer intercepts valid depth/stencil-only draws, and the fixture now declares its real pixel program. The added tests cover color rejection and depth-only acceptance. Linux, Windows, changes, conventions, and report checks pass for this head.
popcoder565 commented 2026-10-09 15:23:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:57Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 5c291a55, merged onto main d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run.

  • This PR's tests pass: agc_driver_graphics. None of them reported skipping a case.
  • Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows PATH setup.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083898860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2022#issuecomment-6083898860). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:23:57Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `5c291a55`, merged onto `main` d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run. - This PR's tests pass: `agc_driver_graphics`. None of them reported skipping a case. - Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows `PATH` setup. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
tv7 commented 2026-10-10 01:51:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tv7 on 2026-10-10T01:51:46Z.


Tested on Windows with Marvel's Wolverine (PPSA03671).

Setup: Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release. This PR (5c291a55) merged onto main 54f28f2d3 with other open PRs the title needs to get this far (#1836, #1893, #1709, #1837, #1940), plus a local change that lets sceKernelSignalSema accept a count of 0 (the title calls it that way).

Without this PR: the first depth-only draw aborts with AGC graphics: depth/stencil-only draws without a pixel shader are not implemented.

With this PR: that draw passes. The next stop is the DB_RENDER_CONTROL depth clear covered by #2219.

Limits: one title, one run each way. Nothing is presented yet at that point, so I can't check that these draws render correctly.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092383825 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2022#issuecomment-6092383825). Originally posted by [tv7](https://github.com/tv7) on 2026-10-10T01:51:46Z. --- Tested on Windows with Marvel's Wolverine (PPSA03671). **Setup:** Windows 11 Pro (10.0.26200), RTX 3070, GCC 15.2.0 UCRT (WinLibs), Release. This PR (5c291a55) merged onto main 54f28f2d3 with other open PRs the title needs to get this far (#1836, #1893, #1709, #1837, #1940), plus a local change that lets `sceKernelSignalSema` accept a count of 0 (the title calls it that way). **Without this PR:** the first depth-only draw aborts with `AGC graphics: depth/stencil-only draws without a pixel shader are not implemented`. **With this PR:** that draw passes. The next stop is the `DB_RENDER_CONTROL` depth clear covered by #2219. **Limits:** one title, one run each way. Nothing is presented yet at that point, so I can't check that these draws render correctly.
adriadam10 commented 2026-10-10 06:08:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:08:01Z.


Checked the diff, built and ran the libSceAgcDriver ctest scope (273/273, agc_driver_graphics and agc_driver_prepared_graphics pass). With the source changes reverted agc_driver_graphics fails, so the new checks pin the fix. Consistent with the decoder's existing reading of an unwritten address as 0; colour-writing draws are still rejected. Also confirmed on Windows by @popcoder565 and @tv7; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094503022 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2022#issuecomment-6094503022). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T06:08:01Z. --- Checked the diff, built and ran the libSceAgcDriver ctest scope (273/273, `agc_driver_graphics` and `agc_driver_prepared_graphics` pass). With the source changes reverted `agc_driver_graphics` fails, so the new checks pin the fix. Consistent with the decoder's existing reading of an unwritten address as 0; colour-writing draws are still rejected. Also confirmed on Windows by @popcoder565 and @tv7; merging.
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!2022
No description provided.