fix(shader): record BDA faults in hull programs instead of refusing them #4222

Merged
Celegans12 merged 3 commits from upstream-pr/4222 into main 2026-10-14 07:39:55 +00:00
Celegans12 commented 2026-10-12 01:45:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-12T01:45:14Z.


What

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

A hull (tessellation-control) program with a BDA read fails to compile with "BDA fault termination requires a barrier-safe tessellation-control execution protocol". The refusal dates from the first BDA commit and is now redundant: BdaInvocationsMayStop already switches any program that contains s_barrier to the non-stopping fault protocol, and a hull's only barriers come from guest s_barrier (EmitBarrier); the LDS-lock barrier runs before any guest code and wave-LDS barriers are compute-only.

  • The refusal is removed. A hull with s_barrier keeps every invocation to its barriers; a hull without one may stop a faulting invocation, since no barrier can be stranded.
  • BdaContracts asserted the refusal and now accepts a hull with s_barrier.

PPSA26344's terrain hull 0x80002fc700 has no s_barrier and reads guest memory through BDA. With this change, its replayed request recompiles completely (388,903 SPIR-V words) once GE_CNTL.BREAK_WAVE_AT_EOI is set in the request; the title clears that bit, which #4201 refuses and #4450 handles.

Tested

Based on main f265cd55 plus #4172 and #4201. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, targeted test builds, ctest.

  • Windows NVIDIA: agc_driver_tessellation, agc_shader_memory, agc_driver_graphics, agc_tessellation_factor_ring and agc_driver_bda_device pass (5/5)
  • Linux (upstream's job in WSL, GCC 13.3, llvmpipe), #4222's head merged with current main: the same 5 tests pass (5/5)
  • Full suite on #4222's head (which contains this commit): Windows NVIDIA 1110/1111, the failure is log_macros, which fails on main too; Linux (upstream's job in WSL) merged with main 5a81f608: 1089/1091, agc_driver_bc_block_copy and agc_driver_depth_compare_copy fail on that main as well

agc_driver_tessellation gains two hulls that scale their output by a float read through BDA, with and without s_barrier: both render correctly, and an unmapped read reports BDA access failed ... stage=7. Both this and agc_driver_bda_device fail on #4201's head with the refusal. The unmapped-read draws are skipped on llvmpipe, which segfaults on them although the loads are guarded by if (physical != 0) and removing just those guarded loads stops the crash; the mapped-read draws run there.

Not tested: 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 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: #4201
  • Unblocks: PPSA26344 #675
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.62, Windows 11; llvmpipe (Mesa 25.2.8), WSL Ubuntu 24.04
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4823960042 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4222). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-12T01:45:14Z. --- ### What Stacked on #4201; please review the last commit only. A hull (tessellation-control) program with a BDA read fails to compile with "BDA fault termination requires a barrier-safe tessellation-control execution protocol". The refusal dates from the first BDA commit and is now redundant: `BdaInvocationsMayStop` already switches any program that contains `s_barrier` to the non-stopping fault protocol, and a hull's only barriers come from guest `s_barrier` (`EmitBarrier`); the LDS-lock barrier runs before any guest code and wave-LDS barriers are compute-only. - The refusal is removed. A hull with `s_barrier` keeps every invocation to its barriers; a hull without one may stop a faulting invocation, since no barrier can be stranded. - `BdaContracts` asserted the refusal and now accepts a hull with `s_barrier`. PPSA26344's terrain hull 0x80002fc700 has no `s_barrier` and reads guest memory through BDA. With this change, its replayed request recompiles completely (388,903 SPIR-V words) once `GE_CNTL.BREAK_WAVE_AT_EOI` is set in the request; the title clears that bit, which #4201 refuses and #4450 handles. ### Tested Based on `main` f265cd55 plus #4172 and #4201. Windows 11 (MinGW-w64 GCC 15.2.0) and Linux: configure -DBUILD_TESTING=ON, targeted test builds, ctest. - Windows NVIDIA: `agc_driver_tessellation`, `agc_shader_memory`, `agc_driver_graphics`, `agc_tessellation_factor_ring` and `agc_driver_bda_device` pass (5/5) - Linux (upstream's job in WSL, GCC 13.3, llvmpipe), #4222's head merged with current `main`: the same 5 tests pass (5/5) - Full suite on #4222's head (which contains this commit): Windows NVIDIA 1110/1111, the failure is `log_macros`, which fails on `main` too; Linux (upstream's job in WSL) merged with `main` 5a81f608: 1089/1091, `agc_driver_bc_block_copy` and `agc_driver_depth_compare_copy` fail on that `main` as well `agc_driver_tessellation` gains two hulls that scale their output by a float read through BDA, with and without `s_barrier`: both render correctly, and an unmapped read reports `BDA access failed ... stage=7`. Both this and `agc_driver_bda_device` fail on #4201's head with the refusal. The unmapped-read draws are skipped on llvmpipe, which segfaults on them although the loads are guarded by `if (physical != 0)` and removing just those guarded loads stops the crash; the mapped-read draws run there. Not tested: 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 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: #4201 - [x] Unblocks: PPSA26344 #675 - [x] GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.62, Windows 11; llvmpipe (Mesa 25.2.8), WSL Ubuntu 24.04 - [x] AI-assisted: yes
blawesom commented 2026-10-12 13:18:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-12T13:18:31Z.


Rebase handoff — this PR is the 5th link of the hull/tessellation chain (it contains #4172 and #4201 underneath its own commit), so I stacked the rebase on the already-rebased chain: rebase/4114 → … → rebase/4201 → this. Authorship unchanged; applied cleanly.

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 952/952 passed

To pick it up (whole chain):

git fetch https://github.com/blawesom/AnyPS5 rebase/4114 rebase/4163 rebase/4172 rebase/4201 rebase/4222

Head is d321aca7b. Worth listing Depends on: #4114, #4163, #4172, #4201 in the description so the chain merges in order.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125083152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4222#issuecomment-6125083152). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-12T13:18:31Z. --- **Rebase handoff** — this PR is the 5th link of the hull/tessellation chain (it contains #4172 and #4201 underneath its own commit), so I stacked the rebase on the already-rebased chain: `rebase/4114` → … → `rebase/4201` → this. Authorship unchanged; applied cleanly. Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 952/952 passed** **To pick it up (whole chain):** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/4114 rebase/4163 rebase/4172 rebase/4201 rebase/4222 ``` Head is `d321aca7b`. Worth listing **Depends on:** #4114, #4163, #4172, #4201 in the description so the chain merges in order.
Celegans12 commented 2026-10-14 01:56:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-14T01:56:42Z.


Quick note: I restacked this on the new #4172 and #4201 heads. The only conflict was the order of the test calls in Tessellation.cpp; this commit's own diff is unchanged. On this head, agc_driver_tessellation, agc_shader_memory, agc_driver_graphics, agc_tessellation_factor_ring and agc_driver_bda_device pass on Windows (NVIDIA) and on Linux (llvmpipe, merged with main).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159163905 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4222#issuecomment-6159163905). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-14T01:56:42Z. --- Quick note: I restacked this on the new #4172 and #4201 heads. The only conflict was the order of the test calls in `Tessellation.cpp`; this commit's own diff is unchanged. On this head, `agc_driver_tessellation`, `agc_shader_memory`, `agc_driver_graphics`, `agc_tessellation_factor_ring` and `agc_driver_bda_device` pass on Windows (NVIDIA) and on Linux (llvmpipe, merged with `main`).
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!4222
No description provided.