Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:fix/agc-library-modules-after-prebuild
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
LeandroLP23:fix/agc-library-modules-after-prebuild

Conversation

@LeandroLP23

Copy link
Copy Markdown
Contributor

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 perf(agc): build shader pipeline libraries when shaders are registered #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)

…kground linking

boykopovar#4152 dropped the device-wide module list that boykopovar#3173 added, so Pipeline
destroys the shader modules right after the library parts are created, also
for the parts prebuilt at registration. AMD's Windows driver still reads
them during the background link-time-optimized link and faults inside
amdvlk64.dll. Hand the modules of each new part to the device's library
store again and destroy them in ClearPipelineLibraries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@LeandroLP23

Copy link
Copy Markdown
Contributor Author

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AMD Windows: since #4152, 47 AGC tests crash in amdvlk64.dll because library shader modules are destroyed before the background link

2 participants