fix(agc): reject primitive restart only for indexed draws #60

Merged
oneandonlydean merged 1 commit from upstream-pr/60 into main 2026-09-28 06:56:38 +00:00
oneandonlydean commented 2026-09-28 03:49:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-28T03:49:52Z.


What

DecodeState and the DrawRejection precheck rejected every draw while GE_MULTI_PRIM_IB_RESET_EN (user-config register 0x24b) was set. Primitive restart only applies to index buffers, so non-indexed draws (DRAW_INDEX_AUTO) were skipped for a setting that can't affect them. A retail title leaves restart enabled around its auto-indexed draws.

How

  • DecodeState still reads 0x24b (so it stays in the recorded draw-key registers) but no longer rejects on it.
  • DrawRejection takes an indexed flag, and reports restart only for indexed draws.
  • The driver's draw path rejects an indexed draw with restart enabled before the precheck, so indexed draws with restart are still refused when the precheck is off. Restart itself is still not implemented.

Testing

tests/Graphics.cpp: with restart enabled on the reference state, DecodeState succeeds, DrawRejection(queue, false) is empty and DrawRejection(queue, true) names GE_MULTI_PRIM_IB_RESET_EN.

agc_driver_graphics_tests isn't registered with CTest and doesn't link on main (unresolved Recorder/ReadDrawArguments symbols). To run it, I linked its objects against the driver's objects by hand. The restart checks pass, and the run then stops at a later check that fails the same way on main (missing register in context bank at DWORD 0x325). All registered CTest tests pass except agc_driver and agc_driver_pm4, which fail on main too.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4659012028 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/60). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-28T03:49:52Z. --- ### What `DecodeState` and the `DrawRejection` precheck rejected every draw while `GE_MULTI_PRIM_IB_RESET_EN` (user-config register `0x24b`) was set. Primitive restart only applies to index buffers, so non-indexed draws (`DRAW_INDEX_AUTO`) were skipped for a setting that can't affect them. A retail title leaves restart enabled around its auto-indexed draws. ### How - `DecodeState` still reads `0x24b` (so it stays in the recorded draw-key registers) but no longer rejects on it. - `DrawRejection` takes an `indexed` flag, and reports restart only for indexed draws. - The driver's draw path rejects an indexed draw with restart enabled before the precheck, so indexed draws with restart are still refused when the precheck is off. Restart itself is still not implemented. ### Testing `tests/Graphics.cpp`: with restart enabled on the reference state, `DecodeState` succeeds, `DrawRejection(queue, false)` is empty and `DrawRejection(queue, true)` names `GE_MULTI_PRIM_IB_RESET_EN`. `agc_driver_graphics_tests` isn't registered with CTest and doesn't link on `main` (unresolved `Recorder`/`ReadDrawArguments` symbols). To run it, I linked its objects against the driver's objects by hand. The restart checks pass, and the run then stops at a later check that fails the same way on `main` (`missing register in context bank at DWORD 0x325`). All registered CTest tests pass except `agc_driver` and `agc_driver_pm4`, which fail on `main` too.
SamG-Coder commented 2026-09-28 06:52:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by SamG-Coder on 2026-09-28T06:52:33Z.


Independently reproduced the regression and validated this fix with a small PS5 SDK demo converted to a Windows executable.

The demo draws two triangles and explicitly writes GE_MULTI_PRIM_IB_RESET_EN (0x24b) through sceAgcDcbSetUcRegistersIndirect. It selects either DRAW_INDEX_AUTO or DRAW_INDEX and tests restart off/on.

Baseline: SamG-Coder/AnyPS5@fa787cf (upstream c368817 plus the BGRA fix in #65). Patched runtime: the same baseline with this PR's 0479a5f applied without conflicts, producing local test commit 830f8ec. The baseline relinker was used for both variants, and the exact same PS5 ELF inputs were reused; only the linked runtime directory changed.

Draw type Restart Baseline With this PR
Non-indexed Off Renders correctly Renders correctly
Non-indexed On Draws skipped; blank frames Renders correctly
Indexed Off Renders correctly Renders correctly
Indexed On Rejected Still rejected as unsupported

Each combination was tested with the draw precheck enabled and with APS5_NO_DRAW_PRECHECK=1: 16 runs total, 140 completed flips per run, with both final framebuffers checked.

The useful regression signal is that the baseline non-indexed/restart-on case completes every flip but renders no triangles. The independent pixel checker rejects that blank output. With this PR, it passes both with and without the precheck.

Validation details:

  • Independent triangle coverage, bounds, and barycentric color/lighting checks pass for every expected rendered frame: 112,896 covered pixels, bounds (192,235)–(1087,485), maximum sampled channel error 1/255.
  • All successful framebuffer captures across both runtimes and all tested modes are byte-for-byte identical.
  • Negative cases require the specific GE_MULTI_PRIM_IB_RESET_EN rejection diagnostic and an exactly uniform background; successful flip completion alone is not counted as rendering success.
  • Indexed restart remains rejected with the precheck disabled, confirming the additional driver guard is exercised.

This provides converted-host regression coverage for the intended fix, including the precheck-disabled path. It does not test physical PS5 execution, implement indexed primitive restart, or establish full-game compatibility. The demo and evidence remain outside the library repository.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5864952758 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/60#issuecomment-5864952758). Originally posted by [SamG-Coder](https://github.com/SamG-Coder) on 2026-09-28T06:52:33Z. --- Independently reproduced the regression and validated this fix with a small PS5 SDK demo converted to a Windows executable. The demo draws two triangles and explicitly writes `GE_MULTI_PRIM_IB_RESET_EN` (`0x24b`) through `sceAgcDcbSetUcRegistersIndirect`. It selects either `DRAW_INDEX_AUTO` or `DRAW_INDEX` and tests restart off/on. Baseline: `SamG-Coder/AnyPS5@fa787cf` (upstream `c368817` plus the BGRA fix in #65). Patched runtime: the same baseline with this PR's `0479a5f` applied without conflicts, producing local test commit `830f8ec`. The baseline relinker was used for both variants, and the exact same PS5 ELF inputs were reused; only the linked runtime directory changed. | Draw type | Restart | Baseline | With this PR | |---|---|---|---| | Non-indexed | Off | Renders correctly | Renders correctly | | Non-indexed | On | Draws skipped; blank frames | Renders correctly | | Indexed | Off | Renders correctly | Renders correctly | | Indexed | On | Rejected | Still rejected as unsupported | Each combination was tested with the draw precheck enabled and with `APS5_NO_DRAW_PRECHECK=1`: **16 runs total**, 140 completed flips per run, with both final framebuffers checked. The useful regression signal is that the baseline non-indexed/restart-on case completes every flip but renders no triangles. The independent pixel checker rejects that blank output. With this PR, it passes both with and without the precheck. Validation details: - Independent triangle coverage, bounds, and barycentric color/lighting checks pass for every expected rendered frame: 112,896 covered pixels, bounds `(192,235)`–`(1087,485)`, maximum sampled channel error `1/255`. - All successful framebuffer captures across both runtimes and all tested modes are byte-for-byte identical. - Negative cases require the specific `GE_MULTI_PRIM_IB_RESET_EN` rejection diagnostic and an exactly uniform background; successful flip completion alone is not counted as rendering success. - Indexed restart remains rejected with the precheck disabled, confirming the additional driver guard is exercised. This provides converted-host regression coverage for the intended fix, including the precheck-disabled path. It does not test physical PS5 execution, implement indexed primitive restart, or establish full-game compatibility. The demo and evidence remain outside the library repository.
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!60
No description provided.