fix(agc): keep shader modules of pipeline library parts alive for background linking #4445

Merged
LeandroLP23 merged 1 commit from upstream-pr/4445 into main 2026-10-12 15:50:19 +00:00
LeandroLP23 commented 2026-10-12 11:48:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T11:48:25Z.


What

Fixes #4435. On AMD's Windows driver, 47 AGC tests have crashed inside amdvlk64.dll since #4152. The driver still reads a pipeline library part's shader modules during the background link-time-optimized link, after Pipeline has destroyed them. Destroying them is legal Vulkan, so this works around a driver bug.

#3173 handed the modules of each newly created part to the device's library store and destroyed them in ClearPipelineLibraries. #4152 reworked LinkPipelineFromLibraries and that store went away. This puts it back on the current code:

  • LinkPipelineFromLibraries takes the caller's modules again. When background linking is on, it moves the ones a new part uses into DeviceLibraries::modules and clears them in the caller's span.
  • Both callers in Pipeline.cpp pass _modules: the draw path and #4152's prebuild-at-registration path. Their existing destroy loops then skip the handed-over modules, since they are VK_NULL_HANDLE.
  • ClearPipelineLibraries destroys the stored modules after the parts and layouts.

A part that loses the race to another thread is destroyed as before, and its modules stay with the caller.

Tested

Radeon 860M (RDNA 3.5, AMD Windows driver 32.0.13058.8001), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release. Tests run one at a time, with the shader cache emptied first.

build ctest -R '^agc_' -j 1
main e7c70a2df 384/431 (19 SegFaults in amdvlk64.dll, 27 non-zero exits, 1 timeout)
main with APS5_NO_PIPELINE_LTO=1 431/431
this change on main 431/431
  • The non-AGC suite passes on this change, 513/513 (ctest -E '^agc_' -j 4).
  • tools/check_conventions.py --base main and git diff --check pass.
  • Fork CI run on the full Linux, Windows and relinker jobs (lavapipe): everything passes except conventions_ci_gate. That test flags the pre-0ab2a04d build.yml the fork uses to run full builds, not this change.

Upstream CI runs the GPU tests on lavapipe, which doesn't show the fault, so CI can't tell this change from main.

#4363 changes the same function (LinkPipelineFromLibraries, the part keys). With it merged and without this change, the failing tests still fail. The two touch different lines, but whichever merges second may need a rebase.

Checklist

  • Based on current main; no other open PR implements the same change
  • 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
  • Unblocks: none
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4828949073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4445). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-12T11:48:25Z. --- ### What Fixes #4435. On AMD's Windows driver, 47 AGC tests have crashed inside `amdvlk64.dll` since #4152. The driver still reads a pipeline library part's shader modules during the background link-time-optimized link, after `Pipeline` has destroyed them. Destroying them is legal Vulkan, so this works around a driver bug. #3173 handed the modules of each newly created part to the device's library store and destroyed them in `ClearPipelineLibraries`. #4152 reworked `LinkPipelineFromLibraries` and that store went away. This puts it back on the current code: - `LinkPipelineFromLibraries` takes the caller's modules again. When background linking is on, it moves the ones a new part uses into `DeviceLibraries::modules` and clears them in the caller's span. - Both callers in `Pipeline.cpp` pass `_modules`: the draw path and #4152's prebuild-at-registration path. Their existing destroy loops then skip the handed-over modules, since they are `VK_NULL_HANDLE`. - `ClearPipelineLibraries` destroys the stored modules after the parts and layouts. A part that loses the race to another thread is destroyed as before, and its modules stay with the caller. ### Tested Radeon 860M (RDNA 3.5, AMD Windows driver 32.0.13058.8001), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release. Tests run one at a time, with the shader cache emptied first. | build | `ctest -R '^agc_' -j 1` | |---|---| | `main` `e7c70a2df` | 384/431 (19 SegFaults in `amdvlk64.dll`, 27 non-zero exits, 1 timeout) | | `main` with `APS5_NO_PIPELINE_LTO=1` | 431/431 | | this change on `main` | **431/431** | - The non-AGC suite passes on this change, 513/513 (`ctest -E '^agc_' -j 4`). - `tools/check_conventions.py --base main` and `git diff --check` pass. - [Fork CI run](https://github.com/LeandroLP23/AnyPS5/actions/runs/38241374970) on the full Linux, Windows and relinker jobs (lavapipe): everything passes except `conventions_ci_gate`. That test flags the pre-`0ab2a04d` `build.yml` the fork uses to run full builds, not this change. Upstream CI runs the GPU tests on lavapipe, which doesn't show the fault, so CI can't tell this change from `main`. #4363 changes the same function (`LinkPipelineFromLibraries`, the part keys). With it merged and without this change, the failing tests still fail. The two touch different lines, but whichever merges second may need a rebase. ### Checklist - [x] Based on current `main`; no other open PR implements the same change - [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] Unblocks: none - [x] AI-assisted: yes (Claude Code)
LeandroLP23 commented 2026-10-12 15:53:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T15:53:06Z.


The crash also reaches titles. I re-ran the homebrew catalog sweep on AMD Windows (Radeon 860M, driver 32.0.13058.8001), one 60-second run per title, relinked with --windows. Without this PR, on main d592d54e1, four titles crash inside amdvlk64.dll:

Title main d592d54e1 main + this PR
Stremio Plus (PPSA74126) 0xc0000005 at 12 s, rip amdvlk64.dll+0x2cc126d runs 60 s, 48 FPS
EVO Player (PPSA99039) 0xc0000005 at 12 s, rip amdvlk64.dll+0x1bb6442 runs 60 s, 15 FPS
Jelly5 (PPSA99505) 0xc0000005 at 42 s, rip amdvlk64.dll+0x4bc8c0 runs 60 s, 18 FPS
Emby5 (PPSA99515) 0xc0000005 at 27 s, rip amdvlk64.dll+0x4bc8c0 runs 60 s, 18 FPS

Jelly5 and Emby5 ran 60 s on main 8c4a295ff, before #4152. Stremio Plus and EVO Player stopped earlier on that main, on AGC checks that were fixed since (#4030, #4245).

Three more titles exit early on main and run 60 s with this PR, but their logs don't show where they stop, so I can't attribute them:

  • VITA5 (PPSA39410): 0xc0000005 at 22 s.
  • ProsperoStore (PPSA99000): exit 1 at 26 s.
  • Quake III Arena (PPSA99303): exit 0 after 1 s.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6127764978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4445#issuecomment-6127764978). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-12T15:53:06Z. --- The crash also reaches titles. I re-ran the homebrew catalog sweep on AMD Windows (Radeon 860M, driver 32.0.13058.8001), one 60-second run per title, relinked with `--windows`. Without this PR, on `main` `d592d54e1`, four titles crash inside `amdvlk64.dll`: | Title | `main` `d592d54e1` | `main` + this PR | |---|---|---| | Stremio Plus (PPSA74126) | `0xc0000005` at 12 s, rip `amdvlk64.dll+0x2cc126d` | runs 60 s, 48 FPS | | EVO Player (PPSA99039) | `0xc0000005` at 12 s, rip `amdvlk64.dll+0x1bb6442` | runs 60 s, 15 FPS | | Jelly5 (PPSA99505) | `0xc0000005` at 42 s, rip `amdvlk64.dll+0x4bc8c0` | runs 60 s, 18 FPS | | Emby5 (PPSA99515) | `0xc0000005` at 27 s, rip `amdvlk64.dll+0x4bc8c0` | runs 60 s, 18 FPS | Jelly5 and Emby5 ran 60 s on `main` `8c4a295ff`, before #4152. Stremio Plus and EVO Player stopped earlier on that `main`, on AGC checks that were fixed since (#4030, #4245). Three more titles exit early on `main` and run 60 s with this PR, but their logs don't show where they stop, so I can't attribute them: - VITA5 (PPSA39410): `0xc0000005` at 22 s. - ProsperoStore (PPSA99000): exit 1 at 26 s. - Quake III Arena (PPSA99303): exit 0 after 1 s. AI-assisted: yes (Claude Code)
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!4445
No description provided.