feat(agc): implement deferred faults for descriptors read through null SRT pointers #1292

Merged
Celegans12 merged 2 commits from upstream-pr/1292 into main 2026-10-09 22:48:27 +00:00
Celegans12 commented 2026-10-07 22:37:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T22:37:34Z.


What

Stacked on #759; please review the last commit only.

A capture evaluates every V#, T# and S# a shader uses, even behind a branch the wave won't take. If one is loaded through a null or unmapped pointer read from memory, the capture throws (null or misaligned address, guest memory is not readable), while the console only faults when a wave runs that s_load. #759 covers only flat SRT reads.

  • Record time: in EvaluateRuntimeSourcesImpl, a descriptor dword read that #759 would record makes the whole descriptor zero; the flat walk records the s_load's dwords as before. If no record names that read, it still throws.
  • Run time is #759's runtime check, so it follows boykopovar's guidance the same way: the guarded ReadConst faults at the s_load's pc. On main a zero V# is an absent buffer, a zero T# a null descriptor and a zero S# a valid sampler, so a zeroed descriptor binds and specializes like zeros read from memory: no new key.
  • Still throws: branch conditions, uniform fills, table bases, user-data pointers and descriptor reads no flat slot records.
  • PPSA26344 v1.008: about 40 draws a frame use six vertex shaders that load V#s at *(SRT + 0x98) only if s_buffer_load_dword ..., 0x120 is nonzero; the pointer is null in the skipped draws.
  • Overlaps: #1747 also edits EvaluateRuntimeSourcesImpl.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main 1be6f9f1 with #759: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 486/486 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 485/485 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • agc_driver_guarded_null_pointer: a V# loaded through a pointer behind an SCC branch reads its payload when mapped, faults at the s_load's pc and address when null or unmapped and taken, and doesn't fault when skipped; a zero V# from memory and a zeroed one share one pipeline variant.
  • agc_shader_memory: a compute V# through a null or unmapped pointer and a vertex V# through a null one get four records and zero words, with the variant, specialization and module of a zero V# from memory. Both tests fail on #759 alone.
  • PPSA26344 v1.008, before #639: two 2,700 s runs had no such draw skips (13,213 without it). Not run again.
  • Not tested: graphics-stage execution on a GPU, console behaviour.

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: #759
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4779327170 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1292). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T22:37:34Z. --- ### What Stacked on #759; please review the last commit only. A capture evaluates every V#, T# and S# a shader uses, even behind a branch the wave won't take. If one is loaded through a null or unmapped pointer read from memory, the capture throws (`null or misaligned address`, `guest memory is not readable`), while the console only faults when a wave runs that `s_load`. #759 covers only flat SRT reads. - Record time: in `EvaluateRuntimeSourcesImpl`, a descriptor dword read that #759 would record makes the whole descriptor zero; the flat walk records the `s_load`'s dwords as before. If no record names that read, it still throws. - Run time is #759's runtime check, so it follows boykopovar's guidance the same way: the guarded `ReadConst` faults at the `s_load`'s pc. On `main` a zero V# is an absent buffer, a zero T# a null descriptor and a zero S# a valid sampler, so a zeroed descriptor binds and specializes like zeros read from memory: no new key. - Still throws: branch conditions, uniform fills, table bases, user-data pointers and descriptor reads no flat slot records. - PPSA26344 v1.008: about 40 draws a frame use six vertex shaders that load V#s at `*(SRT + 0x98)` only if `s_buffer_load_dword ..., 0x120` is nonzero; the pointer is null in the skipped draws. - Overlaps: #1747 also edits `EvaluateRuntimeSourcesImpl`. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` 1be6f9f1 with #759: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 486/486 tests pass (`ctest --output-on-failure`) - Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, `VK_DRIVER_FILES`): 485/485 pass; `agc_driver_flat_store` is left out there because it takes several minutes on Windows llvmpipe - `agc_driver_guarded_null_pointer`: a V# loaded through a pointer behind an SCC branch reads its payload when mapped, faults at the `s_load`'s pc and address when null or unmapped and taken, and doesn't fault when skipped; a zero V# from memory and a zeroed one share one pipeline variant. - `agc_shader_memory`: a compute V# through a null or unmapped pointer and a vertex V# through a null one get four records and zero words, with the variant, specialization and module of a zero V# from memory. Both tests fail on #759 alone. - PPSA26344 v1.008, before #639: two 2,700 s runs had no such draw skips (13,213 without it). Not run again. - Not tested: graphics-stage execution on a GPU, console behaviour. ### 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) - [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: #759 - [x] AI-assisted: yes
adriadam10 commented 2026-10-09 22:48:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:48:24Z.


Checked on a build merged onto current main: full ctest green (552/552); agc_shader_memory and agc_driver_guarded_null_pointer fail with the change reverted; CI green on this head. TechnicalDebt lines match the new behaviour. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090574779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1292#issuecomment-6090574779). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:48:24Z. --- Checked on a build merged onto current `main`: full ctest green (552/552); `agc_shader_memory` and `agc_driver_guarded_null_pointer` fail with the change reverted; CI green on this head. TechnicalDebt lines match the new behaviour. 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!1292
No description provided.