fix(agc): skip a pixel program whose color masks reach no formatted target #21747

Merged
ashwin280802 merged 1 commit from upstream-pr/21747 into main 2026-11-19 09:15:19 +00:00
ashwin280802 commented 2026-11-16 18:24:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ashwin280802 on 2026-11-16T18:24:06Z.


What

PixelProgramSkipped compared the raw CB_TARGET_MASK and CB_SHADER_MASK. Both reset to all channels, so a draw with no formatted color target and no DB export or execution enable still ran its bound pixel program, and a rect-list draw of one with a pass-through input threw "custom per-vertex interpolation is unsupported". The check now uses ColorWriteMask, which leaves out the channels of targets whose CB_COLORn_INFO has no format, as DecodeState already does for hasColorTarget.

The change that starts the color masks at their reset values (fix(agc): start the color masks and viewport control at their reset values) exposed this: before it the masks started at 0 and such a draw used the null pixel program. Nine existing test setups enabled the masks on the reset context, which has no formatted target, only to make a pixel program run; seven now set a CB_COLOR0_INFO format and the two draws that go through the device set EXEC_ON_NOOP.

Sources: PAL DbShaderControl, GFX10 registers, radeonsi, which expects FORMAT INVALID to disable an unbound color buffer's writes; it does not say the pixel program is skipped. Not measured on the console: a mask on a FORMAT 0 target, and DB_ALPHA_TO_MASK (which always keeps the program); both are in the library's debt file.

Overlap: python tools/pr_overlap.py --names PixelProgramSkipped,ColorWriteMask reports open: none. The branch check found 68 open PRs sharing files with this branch and could not compare 37 of them; none was checked by hand, so I do not claim there is no overlap.

Tested

Windows 11, RTX 5070 (driver 621.24). The full suites, validation and title runs below were on bec1751a93, the same patch before its rebase onto current main; the 36 focused tests were run again after the rebase (e136e1a375) and pass.

  • ctest --test-dir build-full -R <the 36 AGC graphics, prepared graphics, prepared shaders, builtin program memory and unregistered graphics tests>: 100% tests passed out of 36.
  • Vulkan validation layer loaded, same 36 tests compared with a build of main c53d8bb2d7: diagnostics: change 0, baseline 0, new 0.
  • Full Windows suite: 5756 tests, 5728 passed, 0 failed, 28 skipped. One test, agc_driver_upload_cache_read_only_flush_tests, does not build (UploadCacheReadOnlyFlush.cpp:177 setenv; the file is identical on main and untouched here), so it did not run.
  • Full Linux suite (container): 5636 tests, 5461 passed, 166 skipped, 9 failed (agc_draw_input_mirrors, agc_draw_input_reuse, agc_driver_coherent_atomic_loads_enabled, agc_driver_global_atomic_csub, agc_driver_recorder, agc_driver_stencil_copy_draw, title_run, title_run_identity, title_run_paths). The author's container also fails these 9 at main c53d8bb2d7.
  • Title PPSA09259: on main the run aborts with driver failure: Rect-list SPIR-V: custom per-vertex interpolation is unsupported after 39 s; with this change a 180 s run ends by the time limit with 0 FATAL, driver failure or presentation failed lines and 12 present windows. Both runs used libraries built from main c53d8bb2d7 (the second with this State.cpp change) and an executable relinked at 8c33c148c3f.
  • python3 tools/check_conventions.py --base origin/main: All conventions checks passed.
  • I flipped the two operators of the changed condition one at a time; the tests failed on both.
100% tests passed out of 36
RESULT: PASS
layer: loaded
diagnostics: change 0, baseline 0, new 0
All conventions checks passed.

Not covered by a test: the rect-list draw with a pass-through pixel input that showed the problem; the tests cover PixelProgramSkipped and DrawRejection, and the draw path is covered only by the title run.
Not verified: the 9 Linux failures above were not investigated beyond matching main; behaviour on a console; other GPU vendors.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: PPSA09259 (no discussion number recorded)
  • GPUs tested: NVIDIA GeForce RTX 5070, driver 621.24, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5342612335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21747). Originally posted by [ashwin280802](https://github.com/ashwin280802) on 2026-11-16T18:24:06Z. --- ### What `PixelProgramSkipped` compared the raw CB_TARGET_MASK and CB_SHADER_MASK. Both reset to all channels, so a draw with no formatted color target and no DB export or execution enable still ran its bound pixel program, and a rect-list draw of one with a pass-through input threw "custom per-vertex interpolation is unsupported". The check now uses `ColorWriteMask`, which leaves out the channels of targets whose CB_COLORn_INFO has no format, as `DecodeState` already does for `hasColorTarget`. The change that starts the color masks at their reset values (`fix(agc): start the color masks and viewport control at their reset values`) exposed this: before it the masks started at 0 and such a draw used the null pixel program. Nine existing test setups enabled the masks on the reset context, which has no formatted target, only to make a pixel program run; seven now set a CB_COLOR0_INFO format and the two draws that go through the device set EXEC_ON_NOOP. Sources: [PAL DbShaderControl](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/gfx9AbiToPipelineRegisters.h), [GFX10 registers](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/chip/gfx9_plus_merged_registers.h), [radeonsi](https://github.com/mihawk-99/PS5_Mesa/blob/0b2d6d1a61d9bbf89cf8beb88a696144f67c61f8/src/gallium/drivers/radeonsi/si_state.c#L43-L45), which expects FORMAT INVALID to disable an unbound color buffer's writes; it does not say the pixel program is skipped. Not measured on the console: a mask on a FORMAT 0 target, and DB_ALPHA_TO_MASK (which always keeps the program); both are in the library's debt file. Overlap: `python tools/pr_overlap.py --names PixelProgramSkipped,ColorWriteMask` reports `open: none`. The branch check found 68 open PRs sharing files with this branch and could not compare 37 of them; none was checked by hand, so I do not claim there is no overlap. ### Tested Windows 11, RTX 5070 (driver 621.24). The full suites, validation and title runs below were on bec1751a93, the same patch before its rebase onto current `main`; the 36 focused tests were run again after the rebase (e136e1a375) and pass. - `ctest --test-dir build-full -R <the 36 AGC graphics, prepared graphics, prepared shaders, builtin program memory and unregistered graphics tests>`: `100% tests passed out of 36`. - Vulkan validation layer loaded, same 36 tests compared with a build of `main` c53d8bb2d7a: `diagnostics: change 0, baseline 0, new 0`. - Full Windows suite: 5756 tests, 5728 passed, 0 failed, 28 skipped. One test, `agc_driver_upload_cache_read_only_flush_tests`, does not build (`UploadCacheReadOnlyFlush.cpp:177` `setenv`; the file is identical on `main` and untouched here), so it did not run. - Full Linux suite (container): 5636 tests, 5461 passed, 166 skipped, 9 failed (`agc_draw_input_mirrors`, `agc_draw_input_reuse`, `agc_driver_coherent_atomic_loads_enabled`, `agc_driver_global_atomic_csub`, `agc_driver_recorder`, `agc_driver_stencil_copy_draw`, `title_run`, `title_run_identity`, `title_run_paths`). The author's container also fails these 9 at `main` c53d8bb2d7a. - Title PPSA09259: on `main` the run aborts with `driver failure: Rect-list SPIR-V: custom per-vertex interpolation is unsupported` after 39 s; with this change a 180 s run ends by the time limit with 0 FATAL, driver failure or presentation failed lines and 12 present windows. Both runs used libraries built from `main` c53d8bb2d7a (the second with this `State.cpp` change) and an executable relinked at 8c33c148c3f. - `python3 tools/check_conventions.py --base origin/main`: `All conventions checks passed.` - I flipped the two operators of the changed condition one at a time; the tests failed on both. ``` 100% tests passed out of 36 RESULT: PASS layer: loaded diagnostics: change 0, baseline 0, new 0 All conventions checks passed. ``` Not covered by a test: the rect-list draw with a pass-through pixel input that showed the problem; the tests cover `PixelProgramSkipped` and `DrawRejection`, and the draw path is covered only by the title run. Not verified: the 9 Linux failures above were not investigated beyond matching `main`; behaviour on a console; other GPU vendors. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: PPSA09259 (no discussion number recorded) - [x] GPUs tested: NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mattiolocoding commented 2026-11-17 21:15:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mattiolocoding on 2026-11-17T21:15:43Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this. The head is 0ae7f5c275386743b2d68ef5d4ab13a5c705a903.

What I ran

  • Read the full diff for head 0ae7f5c275386743b2d68ef5d4ab13a5c705a903: State.cpp, test updates in Graphics.cpp, BuiltinProgramMemory.cpp, PreparedGraphics.cpp, PreparedShaders.cpp, PreparedUnregisteredGraphics.cpp, and docs/dev/debt/changes/fix-agc-pixel-skip-unbound-targets.md.
  • Traced ColorWriteMask(cx) against AMD GFX10 register architecture: verifying channel masking against CB_COLORn_INFO format field ((info->second >> 2u) & 0x1fu).
  • Verified register guard ordering in PixelProgramSkipped: find(cx, 0x8e) and find(cx, 0x8f) check for presence before ColorWriteMask(cx) invokes read(cx, 0x8e) & read(cx, 0x8f), preventing std::runtime_error exceptions on unpopulated context states.
  • Audited test fixtures: verified that existing tests that relied on reset-context color masks correctly specify CB_COLOR0_INFO format or EXEC_ON_NOOP (0x203 = 0x400) to preserve intentional execution.

Results

Check Result Note
Logic audit passed ColorWriteMask(cx) == 0 correctly accounts for unbound targets where raw masks were non-zero
Diff audit passed Clean diff, consistent formatting, conventions respected
Technical debt passed Documented under docs/dev/debt/changes/ with proper register references

Findings

Blocking

None.

Non-blocking

None. The integration is clean, correctly handles all 8 color target slots, and appropriately accounts for PixelStageRunsMask and EXEC_ON_NOOP.

Sources

  • core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp lines 2350–2359 (ColorWriteMask) and 2855–2865 (PixelProgramSkipped).
  • core/libs/prx/libSceAgcDriver/tests/Graphics.cpp lines 328–350.
  • docs/dev/debt/changes/fix-agc-pixel-skip-unbound-targets.md.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5946746743 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21747#pullrequestreview-5946746743). Originally posted by [mattiolocoding](https://github.com/mattiolocoding) on 2026-11-17T21:15:43Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this. The head is `0ae7f5c275386743b2d68ef5d4ab13a5c705a903`. ## What I ran - Read the full diff for head `0ae7f5c275386743b2d68ef5d4ab13a5c705a903`: `State.cpp`, test updates in `Graphics.cpp`, `BuiltinProgramMemory.cpp`, `PreparedGraphics.cpp`, `PreparedShaders.cpp`, `PreparedUnregisteredGraphics.cpp`, and `docs/dev/debt/changes/fix-agc-pixel-skip-unbound-targets.md`. - Traced `ColorWriteMask(cx)` against AMD GFX10 register architecture: verifying channel masking against `CB_COLORn_INFO` format field `((info->second >> 2u) & 0x1fu)`. - Verified register guard ordering in `PixelProgramSkipped`: `find(cx, 0x8e)` and `find(cx, 0x8f)` check for presence before `ColorWriteMask(cx)` invokes `read(cx, 0x8e) & read(cx, 0x8f)`, preventing `std::runtime_error` exceptions on unpopulated context states. - Audited test fixtures: verified that existing tests that relied on reset-context color masks correctly specify `CB_COLOR0_INFO` format or `EXEC_ON_NOOP` (`0x203` = `0x400`) to preserve intentional execution. ## Results | Check | Result | Note | |---|---|---| | Logic audit | passed | `ColorWriteMask(cx) == 0` correctly accounts for unbound targets where raw masks were non-zero | | Diff audit | passed | Clean diff, consistent formatting, conventions respected | | Technical debt | passed | Documented under `docs/dev/debt/changes/` with proper register references | ## Findings ### Blocking None. ### Non-blocking None. The integration is clean, correctly handles all 8 color target slots, and appropriately accounts for `PixelStageRunsMask` and `EXEC_ON_NOOP`. ## Sources - `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` lines 2350–2359 (`ColorWriteMask`) and 2855–2865 (`PixelProgramSkipped`). - `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` lines 328–350. - `docs/dev/debt/changes/fix-agc-pixel-skip-unbound-targets.md`. AI-assisted: yes
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!21747
No description provided.