fix(shader): set a BDA-written page's bit inside the slot probe loop #3472

Merged
oneandonlydean merged 1 commit from upstream-pr/3472 into main 2026-10-11 11:51:43 +00:00
oneandonlydean commented 2026-10-11 11:07:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T11:07:30Z.


What

Since #3175, six tests lose the device on NVIDIA 610.57.04 (Linux, RTX 4090): agc_driver_bda_device and agc_driver_flat_apertures_0, _2, _3, _4, _5. Every run fails; they pass on main with #3175 reverted. #3175's author passed on 615.71.09, and CI (lavapipe) passes. The RTX 5080 run on Windows 610.62 in #3291 (comment of 2026-10-11T09:04Z, main ccf9ff90, which has #3175) fails the same five aperture parts the same way.

157 - agc_driver_bda_device (Failed)
AGC graphics: vkWaitForFences graphics: Vulkan result -4

428 - agc_driver_flat_apertures_0 (Subprocess aborted)
  what():  guest allocation 0x560d7aaf0000+0x10000 is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS))

NVRM: Xid (PCI:0000:01:00): 109, pid=2805970, name=agc_driver_bda_, channel 0x00000022, errorString CTX SWITCH TIMEOUT, Info 0xac014
NVRM: Xid (PCI:0000:01:00): 109, pid=2807835, name=agc_driver_flat, channel 0x00000022, errorString CTX SWITCH TIMEOUT, Info 0x10c014

The dispatch that never finishes is one that reaches note_bda_write from write_bda_bytes. In agc_driver_bda_device it is the first unaligned store, write(guest + 41, 4, 16, ...), with one workgroup; the aligned stores before it pass. Its SPIR-V passes spirv-val --target-env vulkan1.2, and both loops in it are bounded (8 probes, 4 bytes), so the module is valid and the driver's compiler is at fault.

#3175 made note_bda_write keep the found slot in a function variable and, after the probe loop, load the chunk's page mask (OpAtomicLoad) and set the page's bit (OpAtomicOr) if it was clear. Variants of that block on this driver, with agc_driver_bda_device:

note_bda_write Result
main device lost at the first write_bda_bytes store
main, function marked DontInline device lost earlier, at an aligned 3-dword store
OpAtomicOr after the loop without the load and test pass
mask read after the loop with OpLoad instead of OpAtomicLoad pass
the same OpAtomicLoad and conditional OpAtomicOr in the loop body (this PR) pass

So this PR moves the block into the loop body, on the iteration that finds or claims the slot, and drops the variable. The atomics, their order and the record are the same as #3175's: a page already noted still costs one atomic load and no write, and the claim list, count and overflow word are unchanged. BdaAbi.hpp and BdaResources.cpp are untouched.

No new test: the existing tests above fail without the change on this driver, and no test can show it on lavapipe.

Tested

Linux (CachyOS, GCC 16.2.1, Release, BUILD_TESTING=ON), RTX 4090, NVIDIA 610.57.04, i9-14900KF, on main f0c6cf27:

Tree agc_driver_bda_device agc_driver_flat_apertures_0-_5 Full ctest
main fails 4 of 4 _0, _2, _3, _4, _5 fail 3 of 3; _1 passes 815/821 (those six)
main with #3175 reverted passes 3 of 3 all pass 2 of 2 not run
this branch passes 4 of 4 all pass 4 of 4 821/821
  • tools/check_conventions.py passes.
  • agc_driver_bda_device on this branch still checks that exactly the stored pages are noted and that each chunk is claimed once, also with 64 workgroups storing to one page.

Not tested on 615.x, on Windows, on AMD or on lavapipe.

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 (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818602345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3472). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T11:07:30Z. --- ### What Since #3175, six tests lose the device on NVIDIA 610.57.04 (Linux, RTX 4090): `agc_driver_bda_device` and `agc_driver_flat_apertures_0`, `_2`, `_3`, `_4`, `_5`. Every run fails; they pass on `main` with #3175 reverted. #3175's author passed on 615.71.09, and CI (lavapipe) passes. The RTX 5080 run on Windows 610.62 in #3291 (comment of 2026-10-11T09:04Z, `main` ccf9ff90, which has #3175) fails the same five aperture parts the same way. ``` 157 - agc_driver_bda_device (Failed) AGC graphics: vkWaitForFences graphics: Vulkan result -4 428 - agc_driver_flat_apertures_0 (Subprocess aborted) what(): guest allocation 0x560d7aaf0000+0x10000 is still pinned by GPU work or an import (waited 60000 ms for the lease (APS5_PIN_WAIT_MS)) NVRM: Xid (PCI:0000:01:00): 109, pid=2805970, name=agc_driver_bda_, channel 0x00000022, errorString CTX SWITCH TIMEOUT, Info 0xac014 NVRM: Xid (PCI:0000:01:00): 109, pid=2807835, name=agc_driver_flat, channel 0x00000022, errorString CTX SWITCH TIMEOUT, Info 0x10c014 ``` The dispatch that never finishes is one that reaches `note_bda_write` from `write_bda_bytes`. In `agc_driver_bda_device` it is the first unaligned store, `write(guest + 41, 4, 16, ...)`, with one workgroup; the aligned stores before it pass. Its SPIR-V passes `spirv-val --target-env vulkan1.2`, and both loops in it are bounded (8 probes, 4 bytes), so the module is valid and the driver's compiler is at fault. #3175 made `note_bda_write` keep the found slot in a function variable and, after the probe loop, load the chunk's page mask (`OpAtomicLoad`) and set the page's bit (`OpAtomicOr`) if it was clear. Variants of that block on this driver, with `agc_driver_bda_device`: | `note_bda_write` | Result | |---|---| | `main` | device lost at the first `write_bda_bytes` store | | `main`, function marked `DontInline` | device lost earlier, at an aligned 3-dword store | | `OpAtomicOr` after the loop without the load and test | pass | | mask read after the loop with `OpLoad` instead of `OpAtomicLoad` | pass | | the same `OpAtomicLoad` and conditional `OpAtomicOr` in the loop body (this PR) | pass | So this PR moves the block into the loop body, on the iteration that finds or claims the slot, and drops the variable. The atomics, their order and the record are the same as #3175's: a page already noted still costs one atomic load and no write, and the claim list, count and overflow word are unchanged. `BdaAbi.hpp` and `BdaResources.cpp` are untouched. No new test: the existing tests above fail without the change on this driver, and no test can show it on lavapipe. ### Tested Linux (CachyOS, GCC 16.2.1, Release, `BUILD_TESTING=ON`), RTX 4090, NVIDIA 610.57.04, i9-14900KF, on `main` f0c6cf27: | Tree | `agc_driver_bda_device` | `agc_driver_flat_apertures_0`-`_5` | Full `ctest` | |---|---|---|---| | `main` | fails 4 of 4 | `_0`, `_2`, `_3`, `_4`, `_5` fail 3 of 3; `_1` passes | 815/821 (those six) | | `main` with #3175 reverted | passes 3 of 3 | all pass 2 of 2 | not run | | this branch | passes 4 of 4 | all pass 4 of 4 | 821/821 | - `tools/check_conventions.py` passes. - `agc_driver_bda_device` on this branch still checks that exactly the stored pages are noted and that each chunk is claimed once, also with 64 workgroups storing to one page. Not tested on 615.x, on Windows, on AMD or on lavapipe. ### 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: none - [x] AI-assisted: yes (Claude Code)
adriadam10 commented 2026-10-11 11:51:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:51:40Z.


Checked the diff: the mask load and OpAtomicOr now run in the probe iteration that finds or claims the slot (done is only set there), same atomics and order as #3175, held dropped. Built and ran the libSceAgc/libSceAgcDriver ctest scope on RADV (402/402). The NVIDIA hang itself can't be reproduced here, so that part rests on your table; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108725526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3472#issuecomment-6108725526). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:51:40Z. --- Checked the diff: the mask load and `OpAtomicOr` now run in the probe iteration that finds or claims the slot (`done` is only set there), same atomics and order as #3175, `held` dropped. Built and ran the libSceAgc/libSceAgcDriver ctest scope on RADV (402/402). The NVIDIA hang itself can't be reproduced here, so that part rests on your table; merging once CI is green.
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!3472
No description provided.