fix(agc): ignore stale input state for null pixel shaders #1348

Merged
TibixDev merged 1 commit from upstream-pr/1348 into main 2026-10-08 11:29:45 +00:00
TibixDev commented 2026-10-08 00:00:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T00:00:40Z.


What

Use the synthetic null pixel shader's own input and export state. Stale guest interpolation, color-export, or shader-control registers no longer reject it. Ordinary pixel shaders still validate those registers.

Complements #1139, which selects an inactive pixel shader but leaves this input decoder unchanged.

Tested

Fedora 44, Release: graphics tests. The new stale-register regression fails before the fix with SPI_PS_IN_CONTROL input count exceeds 32, then passes after it. It also checks that an ordinary shader still rejects the same state. Contribution checks pass. Windows was not tested.

Checklist

  • Current main; no duplicate open PR.
  • One topic.
  • No new code comments.
  • Unsupported paths still throw; UI stubs are documented.
  • No notes, logs, or images in the repository.
  • No new third-party code.
  • General behavior.
  • Depends on: none.
  • AI-assisted: yes.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779936989 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1348). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T00:00:40Z. --- ### What Use the synthetic null pixel shader's own input and export state. Stale guest interpolation, color-export, or shader-control registers no longer reject it. Ordinary pixel shaders still validate those registers. Complements #1139, which selects an inactive pixel shader but leaves this input decoder unchanged. ### Tested Fedora 44, Release: graphics tests. The new stale-register regression fails before the fix with `SPI_PS_IN_CONTROL input count exceeds 32`, then passes after it. It also checks that an ordinary shader still rejects the same state. Contribution checks pass. Windows was not tested. ### Checklist - [x] Current `main`; no duplicate open PR. - [x] One topic. - [x] No new code comments. - [x] Unsupported paths still throw; UI stubs are documented. - [x] No notes, logs, or images in the repository. - [x] No new third-party code. - [x] General behavior. - [x] Depends on: none. - [x] AI-assisted: yes.
Dextroid17 commented 2026-10-08 02:30:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:30:43Z.

Review: COMMENTED


Built and ran it, with a bisect to show the new assertions bite.

Linux (CachyOS, GCC, Release), NVIDIA RTX 3080 Ti:

cmake --build build --target agc_driver_graphics_tests --parallel 16
ctest -R ^agc_driver_graphics$        →  1/1 Passed  (4.23 s)

Mutation check — the parent's ShaderInputState.cpp with your test kept:

pr-1348   (null uses defaults):  1/1 Passed
pr-1348^  (null reads context):  ***Failed

The change has two halves and both are load-bearing. The visible one is the behaviour: a null pixel program has no inputs and no exports, so decoding the context's last written values gives it an interpolator count and colour export modes that nobody asked for. The second is the read side effect — readOr also called NoteRegisterRead, so the old null path consumed those registers, recording a guest write as used by a shader that ignores it. Now the null path does not call read for those five at all, which is the cleaner statement of the same intent: neither the stale value nor the read history crosses into the null program. readOr has no remaining callers, and the NoteRegisterRead uses elsewhere are the ordinary read paths in DrawDecode.cpp, untouched.

The test's control case is what makes it non-vacuous, and it is the detail I would keep. Filling five registers with 0xffffffff is the right probe — read as-is, those decode to a nonsense interpolator count and all-ones target modes, which is exactly what the assertions forbid. But the same context decoded as a non-null program is then required to fail with input count exceeds 32, which proves the junk is genuinely meaningful input rather than something the decoder would have ignored anyway. Without that control, a fixture whose stale values happened to be inert would pass for the wrong reason and the test would be worth nothing. Adding it is the difference between checking the behaviour and checking that nothing happened.

I did not find anything to ask for. The five registers covered are the ones the null path previously read, and the assertions pin each field that could leak from them.

This is a comment, not an approval — I have no merge rights here.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5450695353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1348#pullrequestreview-5450695353). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-08T02:30:43Z. **Review:** COMMENTED --- Built and ran it, with a bisect to show the new assertions bite. **Linux (CachyOS, GCC, Release), NVIDIA RTX 3080 Ti:** ``` cmake --build build --target agc_driver_graphics_tests --parallel 16 ctest -R ^agc_driver_graphics$ → 1/1 Passed (4.23 s) ``` **Mutation check** — the parent's `ShaderInputState.cpp` with your test kept: ``` pr-1348 (null uses defaults): 1/1 Passed pr-1348^ (null reads context): ***Failed ``` **The change has two halves and both are load-bearing.** The visible one is the behaviour: a null pixel program has no inputs and no exports, so decoding the context's last written values gives it an interpolator count and colour export modes that nobody asked for. The second is the read side effect — `readOr` also called `NoteRegisterRead`, so the old null path *consumed* those registers, recording a guest write as used by a shader that ignores it. Now the null path does not call `read` for those five at all, which is the cleaner statement of the same intent: neither the stale value nor the read history crosses into the null program. `readOr` has no remaining callers, and the `NoteRegisterRead` uses elsewhere are the ordinary read paths in `DrawDecode.cpp`, untouched. **The test's control case is what makes it non-vacuous, and it is the detail I would keep.** Filling five registers with `0xffffffff` is the right probe — read as-is, those decode to a nonsense interpolator count and all-ones target modes, which is exactly what the assertions forbid. But the same context decoded as a *non*-null program is then required to **fail** with `input count exceeds 32`, which proves the junk is genuinely meaningful input rather than something the decoder would have ignored anyway. Without that control, a fixture whose stale values happened to be inert would pass for the wrong reason and the test would be worth nothing. Adding it is the difference between checking the behaviour and checking that nothing happened. I did not find anything to ask for. The five registers covered are the ones the null path previously read, and the assertions pin each field that could leak from them. This is a comment, not an approval — I have no merge rights here. Written with AI assistance.
TibixDev commented 2026-10-08 08:24:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T08:24:10Z.


Rebased on e705d430. Kept #1139’s inert-pixel-stage checks and the upstream SRGB tests. This fix remains distinct: it discards stale input and export state when decoding a null pixel program.

Fedora 44 Release: agc_driver_tests, agc_driver_graphics_tests, agc_driver_pm4_tests build; the targeted tests and contribution checks pass. Windows CI is pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055838212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1348#issuecomment-6055838212). Originally posted by [TibixDev](https://github.com/TibixDev) on 2026-10-08T08:24:10Z. --- Rebased on `e705d430`. Kept #1139’s inert-pixel-stage checks and the upstream SRGB tests. This fix remains distinct: it discards stale input and export state when decoding a null pixel program. Fedora 44 Release: `agc_driver_tests`, `agc_driver_graphics_tests`, `agc_driver_pm4_tests` build; the targeted tests and contribution checks pass. Windows CI is pending.
adriadam10 commented 2026-10-08 11:29:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T11:29:41Z.


Checked build + ctest (442/442, agc_driver_graphics passes) and the new test fails without the change. The null-program decode no longer reads stale input/export registers, while ordinary pixel shaders still validate them (test covers both). CI green on the head; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6058876035 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1348#issuecomment-6058876035). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T11:29:41Z. --- Checked build + ctest (442/442, `agc_driver_graphics` passes) and the new test fails without the change. The null-program decode no longer reads stale input/export registers, while ordinary pixel shaders still validate them (test covers both). CI green on the head; 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!1348
No description provided.