fix(shader): split a BDA span read's in-place loads from its fallback #3289

Closed
fdfawef324 wants to merge 1 commit from upstream-pr/3289 into main
fdfawef324 commented 2026-10-11 05:33:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-11T05:33:32Z.


What

read_bda_span (the shared DontInline BDA dword read added in 5623c0e9) had its in-place dword loads and its per-dword byte fallback as the two arms of one selection. On an NVIDIA RTX 3060 (Windows Server 2025, driver 32.0.15.9186), a dispatch whose lanes split between those arms never finishes. Windows resets the GPU after about 3 s and the recorder's fence wait returns VK_ERROR_DEVICE_LOST.

The two arms are now two selections, joined after both: the loads under the span's condition (mapped && aligned), then the fallback under its negation. Every lane still takes exactly the path it took before. Loads, lookups, fault records, Volatile and invocation stops are unchanged, and DontInline stays, so the compile-time win of 5693c77e/5623c0e9 is kept. The SPIR-V passes spirv-val --target-env vulkan1.2 before and after.

How it was narrowed down

All on the RTX 3060, with agc_driver_flat_loads (result: hang or pass):

Variant Result
main hang, ~3 s then device lost
APS5_BDA_BYTE_READS=1 (no span function) pass, ~1 ms
span function without DontInline pass
fallback arm only (in-place arm removed) pass
in-place arm loads replaced by byte loads hang
in-place arm without loads no hang
every mapped lane in place, only unmapped lanes fall back pass
this PR pass
this PR with about half the lanes forced into the fallback pass

The hang needs lanes in the in-place loads and lanes in the fallback's nested calls (read_bda_dword_bytes → get_bda_pointer) at the same time, inside the non-inlined function. It is not the 32-bit load, alignment, a wrapped address, the early returns of the stop variant, the probe call, or the OBS/Steam implicit layers. All of these were ruled out separately.

The failure was hidden behind another error: the lost batch keeps its lease, so each test's teardown (GuestBlock::~GuestBlock → Mutation().Remove) waited the 60 s APS5_PIN_WAIT_MS for the pinned allocation and aborted with still pinned by GPU work or an import. Making a device loss surface as itself is a separate change.

Tested

Windows Server 2025, WinLibs GCC 15.2.0 r7, Release, RTX 3060 (driver 32.0.15.9186), on main f5c0fe00:

  • Full ctest: 765/765 pass, 5 skipped as before. On main 10 fail on this machine, all from this hang: agc_driver_flat_loads, _x2_x3, _x4, agc_driver_global_loads, _x2_x3, _x4, agc_driver_flat_apertures_1, _2, _4, and agc_driver_pixel_interlock. The last now passes 5/5 repeats. Serial times of the aperture tests are 0.9–8.4 s.
  • Not reproducible on lavapipe, so CI on Linux passed before and after.
  • Dreaming Sarah (PPSA02929): title screen at 60 FPS, same log. The shader cache is invalidated by the new source version as expected.

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: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4816844192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3289). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-11T05:33:32Z. --- ### What `read_bda_span` (the shared `DontInline` BDA dword read added in 5623c0e9) had its in-place dword loads and its per-dword byte fallback as the two arms of one selection. On an NVIDIA RTX 3060 (Windows Server 2025, driver 32.0.15.9186), a dispatch whose lanes split between those arms never finishes. Windows resets the GPU after about 3 s and the recorder's fence wait returns `VK_ERROR_DEVICE_LOST`. The two arms are now two selections, joined after both: the loads under the span's condition (`mapped && aligned`), then the fallback under its negation. Every lane still takes exactly the path it took before. Loads, lookups, fault records, `Volatile` and invocation stops are unchanged, and `DontInline` stays, so the compile-time win of 5693c77e/5623c0e9 is kept. The SPIR-V passes `spirv-val --target-env vulkan1.2` before and after. ### How it was narrowed down All on the RTX 3060, with `agc_driver_flat_loads` (result: hang or pass): | Variant | Result | | --- | --- | | `main` | hang, ~3 s then device lost | | `APS5_BDA_BYTE_READS=1` (no span function) | pass, ~1 ms | | span function without `DontInline` | pass | | fallback arm only (in-place arm removed) | pass | | in-place arm loads replaced by byte loads | hang | | in-place arm without loads | no hang | | every mapped lane in place, only unmapped lanes fall back | pass | | this PR | pass | | this PR with about half the lanes forced into the fallback | pass | The hang needs lanes in the in-place loads and lanes in the fallback's nested calls (`read_bda_dword_bytes` → `get_bda_pointer`) at the same time, inside the non-inlined function. It is not the 32-bit load, alignment, a wrapped address, the early returns of the stop variant, the probe call, or the OBS/Steam implicit layers. All of these were ruled out separately. The failure was hidden behind another error: the lost batch keeps its lease, so each test's teardown (`GuestBlock::~GuestBlock` → `Mutation().Remove`) waited the 60 s `APS5_PIN_WAIT_MS` for the pinned allocation and aborted with `still pinned by GPU work or an import`. Making a device loss surface as itself is a separate change. ### Tested Windows Server 2025, WinLibs GCC 15.2.0 r7, Release, RTX 3060 (driver 32.0.15.9186), on `main` f5c0fe00: - Full `ctest`: 765/765 pass, 5 skipped as before. On `main` 10 fail on this machine, all from this hang: `agc_driver_flat_loads`, `_x2_x3`, `_x4`, `agc_driver_global_loads`, `_x2_x3`, `_x4`, `agc_driver_flat_apertures_1`, `_2`, `_4`, and `agc_driver_pixel_interlock`. The last now passes 5/5 repeats. Serial times of the aperture tests are 0.9–8.4 s. - Not reproducible on lavapipe, so CI on Linux passed before and after. - Dreaming Sarah (PPSA02929): title screen at 60 FPS, same log. The shader cache is invalidated by the new source version as expected. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-11 05:40:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T05:40:13Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105914276 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3289#issuecomment-6105914276). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T05:40:13Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

Pull request closed

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!3289
No description provided.