fix(shader): end a pixel shader's failed BDA reads through one exit #7377

Merged
EagleBearerYS merged 1 commit from upstream-pr/7377 into main 2026-10-19 05:22:07 +00:00
EagleBearerYS commented 2026-10-18 03:38:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T03:38:47Z.


What

On AMD's Windows driver, two titles crash the shader compiler inside vkCreateGraphicsPipelines:

  • Demon's Souls (PPSA01342): Cleverdee's report on #1283, RX 6600 XT, driver 32.0.21045.11001 (Adrenalin 26.9.2), on main 143f13055 with #6379, #6488, #6417 and #6504. The crash happens at boot: an access violation at amdvlk64.dll+0x9e251f on a driver thread, on pixel shaders with up to 112 BDA-fault exits. Cleverdee got past it with poonasor's commit below. Demon's Souls also needed #6379 for a separate mesh gl_Layer link crash on AMD.
  • NHL 27 (PPSA34063): stop 17 in poonasor's #4275, RX 6700 XT, on poonasor's fork (upstream 379d8b4e plus their commits). It's the same access violation at amdvlk64.dll+0x9e251f in vkCreateGraphicsPipelines, after START. One main-menu fragment shader is 662,679 SPIR-V words with 216 OpTerminateInvocation/OpKill exits. poonasor reproduced the crash offline with a stand-alone pipeline-creation tool, and the module passes the validation layer.

StopBdaInvocationIf (SpirvBdaFault.cpp) ends a pixel invocation at every guest-memory read that faults. That's an OpTerminateInvocation when SPV_KHR_terminate_invocation is supported (#5804), and an OpKill otherwise. A large shader therefore carries one exit per read.

This is poonasor's fix from poonasor/AnyPS5@eb2e2309, ported to current main with them as co-author:

  • the pixel shader's guest code becomes its own function, and a failed read sets a Private flag and returns;
  • the entry point calls that function and terminates once if the flag is set;
  • primitive-ordered pixel shaders keep the old per-site form, because their interlock instructions must stay in the entry point.

Two changes from eb2e2309:

  • The flag's interface listing: the flag is listed in the entry point's interface only from SPIR-V 1.4 on, as other Private variables are. Earlier versions list only Input and Output variables there.
  • Shaders without a fault site: these keep a plain entry point, with no exit and no SPV_KHR_terminate_invocation. Otherwise every unordered pixel shader would declare the extension. agc_driver_layered_volume_draw validates its mesh pipeline without shaderTerminateInvocation enabled, and rejects such a shader with "SPV_KHR_terminate_invocation requires enabled shaderTerminateInvocation in a fragment shader".

Tests: orderedPixelShaderTests (agc_driver_graphics) now expects these exits:

shader with SPV_KHR_terminate_invocation without it
unordered pixel shader with BDA reads one OpTerminateInvocation in the module, in the entry point one OpKill in the entry point, plus the shader's own
unordered pixel shader without BDA reads no exit in the entry point; the module passes ValidateShaders without shaderTerminateInvocation the same
primitive-ordered pixel shader unchanged unchanged

#6416 also edits StopBdaInvocationIf. Its write masking applies to every stage except pixel shaders, and this PR changes only pixel shaders, so the two compose. They merge without conflicts.

Tested

  • GitHub's Linux (lavapipe, Mesa 25.2.8) and Windows runners (verify run):
    • Red, on main's code: agc_driver_graphics fails with "AGC graphics: a pixel shader with BDA reads and SPV_KHR_terminate_invocation did not end its BDA faults through one OpTerminateInvocation in its entry point (5 in the module)".
    • Green, with the fix: all 15 selected AGC tests, agc_driver_graphics, agc_driver_layered_volume_draw and agc_driver_gpu_buffer_format among them, pass 10 of 10 runs on both runners. Two of them skip on the Windows runner, which has no Vulkan device.
    • Suites: libkernel passes on both runners, and libc on Windows. On the Linux runner, libc's precise_wait timing test failed in this run. It also failed there on main's code in an earlier run of the same tree, and it passes in the Linux mirror below.
  • Windows, the full CI build (fork Build): 1442 of 1442 tests pass, and check_skips passes.
  • Linux, a run that mirrors CI's Linux job (a cloud machine, Ubuntu 24.04, GCC 13.3, Mesa lavapipe 25.2.8 with LLVM 20.1.2, ANYPS5_ENABLE_SPIRV_TOOLS=ON, run as an unprivileged user):
    • Totals: 1415 tests. 5 fail, the IPv6 tests that machine fails on main too, and no test changes status against main 195d0d08a8.
    • check_skips flags only that machine's IPv6 skip, guest_sce_net, which main shows too.
    • SPIR-V validity: SPIRV-Tools validates the test's unordered pixel shader with BDA reads before and after optimization, at SPIR-V 1.3, 1.4, 1.5 and 1.6, with and without the extension. The flag is in the interface at 1.4 and later, and not at 1.3.
  • AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, run by LeandroLP23 at e8b3198337 on main 6efb7261b with 13 other open PRs, built once as one tree (comment):
    • agc_driver_gpu_buffer_format, agc_driver_graphics and agc_driver_layered_volume_draw pass 3 of 3 runs;
    • of all the agc_* tests, 713 of 716 pass. LeandroLP23 reports that the 3 that fail (agc_driver_host_import_lifetime, agc_driver_quad_pixel_mask and agc_driver_layered_volume_vertex_no_gpl) fail the same way on unchanged main there.
  • Not tested: either title. The tests have now run on AMD hardware (above), but the crash, and the fact that one exit avoids it, still come only from the two reports above: poonasor's offline reproduction, and Cleverdee's and poonasor's runs past the crash with eb2e2309.

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 (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA01342 #1283 (on AMD, together with #6379), PPSA34063 #4275
  • GPUs tested: Mesa lavapipe 25.2.8 (llvmpipe, LLVM 20.1.2), Linux (GitHub's runner and a cloud machine); AMD Radeon 860M (driver 32.0.13058.8001), Windows 11, the tests only (LeandroLP23)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4906114558 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-18T03:38:47Z. --- ### What On AMD's Windows driver, two titles crash the shader compiler inside `vkCreateGraphicsPipelines`: - **Demon's Souls (PPSA01342):** [Cleverdee's report on #1283](https://github.com/boykopovar/AnyPS5/discussions/1283#discussioncomment-19008332), RX 6600 XT, driver 32.0.21045.11001 (Adrenalin 26.9.2), on `main` 143f13055 with #6379, #6488, #6417 and #6504. The crash happens at boot: an access violation at `amdvlk64.dll+0x9e251f` on a driver thread, on pixel shaders with up to 112 BDA-fault exits. Cleverdee got past it with poonasor's commit below. Demon's Souls also needed #6379 for a separate mesh `gl_Layer` link crash on AMD. - **NHL 27 (PPSA34063):** stop 17 in [poonasor's #4275](https://github.com/boykopovar/AnyPS5/discussions/4275), RX 6700 XT, on poonasor's fork (upstream 379d8b4e plus their commits). It's the same access violation at `amdvlk64.dll+0x9e251f` in `vkCreateGraphicsPipelines`, after START. One main-menu fragment shader is 662,679 SPIR-V words with 216 `OpTerminateInvocation`/`OpKill` exits. poonasor reproduced the crash offline with a stand-alone pipeline-creation tool, and the module passes the validation layer. `StopBdaInvocationIf` (`SpirvBdaFault.cpp`) ends a pixel invocation at every guest-memory read that faults. That's an `OpTerminateInvocation` when `SPV_KHR_terminate_invocation` is supported (#5804), and an `OpKill` otherwise. A large shader therefore carries one exit per read. This is poonasor's fix from poonasor/AnyPS5@eb2e2309, ported to current `main` with them as co-author: - the pixel shader's guest code becomes its own function, and a failed read sets a Private flag and returns; - the entry point calls that function and terminates once if the flag is set; - primitive-ordered pixel shaders keep the old per-site form, because their interlock instructions must stay in the entry point. **Two changes from eb2e2309:** - **The flag's interface listing:** the flag is listed in the entry point's interface only from SPIR-V 1.4 on, as other Private variables are. Earlier versions list only Input and Output variables there. - **Shaders without a fault site:** these keep a plain entry point, with no exit and no `SPV_KHR_terminate_invocation`. Otherwise every unordered pixel shader would declare the extension. `agc_driver_layered_volume_draw` validates its mesh pipeline without `shaderTerminateInvocation` enabled, and rejects such a shader with "SPV_KHR_terminate_invocation requires enabled shaderTerminateInvocation in a fragment shader". **Tests:** `orderedPixelShaderTests` (`agc_driver_graphics`) now expects these exits: | shader | with `SPV_KHR_terminate_invocation` | without it | |---|---|---| | unordered pixel shader with BDA reads | one `OpTerminateInvocation` in the module, in the entry point | one `OpKill` in the entry point, plus the shader's own | | unordered pixel shader without BDA reads | no exit in the entry point; the module passes `ValidateShaders` without `shaderTerminateInvocation` | the same | | primitive-ordered pixel shader | unchanged | unchanged | #6416 also edits `StopBdaInvocationIf`. Its write masking applies to every stage except pixel shaders, and this PR changes only pixel shaders, so the two compose. They merge without conflicts. ### Tested - **GitHub's Linux (lavapipe, Mesa 25.2.8) and Windows runners** ([verify run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39093062169)): - **Red, on `main`'s code:** `agc_driver_graphics` fails with "AGC graphics: a pixel shader with BDA reads and SPV_KHR_terminate_invocation did not end its BDA faults through one OpTerminateInvocation in its entry point (5 in the module)". - **Green, with the fix:** all 15 selected AGC tests, `agc_driver_graphics`, `agc_driver_layered_volume_draw` and `agc_driver_gpu_buffer_format` among them, pass 10 of 10 runs on both runners. Two of them skip on the Windows runner, which has no Vulkan device. - **Suites:** libkernel passes on both runners, and libc on Windows. On the Linux runner, libc's `precise_wait` timing test failed in this run. It also failed there on `main`'s code in [an earlier run of the same tree](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39092045087), and it passes in the Linux mirror below. - **Windows, the full CI build** ([fork Build](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39092083206)): 1442 of 1442 tests pass, and `check_skips` passes. - **Linux, a run that mirrors CI's Linux job** (a cloud machine, Ubuntu 24.04, GCC 13.3, Mesa lavapipe 25.2.8 with LLVM 20.1.2, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, run as an unprivileged user): - **Totals:** 1415 tests. 5 fail, the IPv6 tests that machine fails on `main` too, and no test changes status against `main` 195d0d08a8. - **check_skips** flags only that machine's IPv6 skip, `guest_sce_net`, which `main` shows too. - **SPIR-V validity:** SPIRV-Tools validates the test's unordered pixel shader with BDA reads before and after optimization, at SPIR-V 1.3, 1.4, 1.5 and 1.6, with and without the extension. The flag is in the interface at 1.4 and later, and not at 1.3. - **AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300**, WinLibs GCC 15.2.0 r7, Release, run by LeandroLP23 at e8b3198337 on `main` 6efb7261b with 13 other open PRs, built once as one tree ([comment](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6252346275)): - `agc_driver_gpu_buffer_format`, `agc_driver_graphics` and `agc_driver_layered_volume_draw` pass 3 of 3 runs; - of all the `agc_*` tests, 713 of 716 pass. LeandroLP23 reports that the 3 that fail (`agc_driver_host_import_lifetime`, `agc_driver_quad_pixel_mask` and `agc_driver_layered_volume_vertex_no_gpl`) fail the same way on unchanged `main` there. - **Not tested:** either title. The tests have now run on AMD hardware (above), but the crash, and the fact that one exit avoids it, still come only from the two reports above: poonasor's offline reproduction, and Cleverdee's and poonasor's runs past the crash with eb2e2309. ### 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 (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA01342 #1283 (on AMD, together with #6379), PPSA34063 #4275 - [x] GPUs tested: Mesa lavapipe 25.2.8 (llvmpipe, LLVM 20.1.2), Linux (GitHub's runner and a cloud machine); AMD Radeon 860M (driver 32.0.13058.8001), Windows 11, the tests only (LeandroLP23) - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-18 03:59:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T03:59:38Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5021 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
PR 5441 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5499 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5500 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6177 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
PR 6188 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6529 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6535 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6563 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6612 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6639 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6647 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6762 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6804 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6808 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6941 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6947 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6972 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6977 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7201 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 7254 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7390 core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp
PR 7392 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
core/shader/recompiler/SpirvBackend/src/SpirvBdaFault.cpp
PR 7484 core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6245429219 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6245429219). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-18T03:59:38Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` | | [PR 5441](https://www.github.com/boykopovar/AnyPS5/pull/5441) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6194](https://www.github.com/boykopovar/AnyPS5/pull/6194) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6529](https://www.github.com/boykopovar/AnyPS5/pull/6529) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6535](https://www.github.com/boykopovar/AnyPS5/pull/6535) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6563](https://www.github.com/boykopovar/AnyPS5/pull/6563) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6612](https://www.github.com/boykopovar/AnyPS5/pull/6612) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6639](https://www.github.com/boykopovar/AnyPS5/pull/6639) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6647](https://www.github.com/boykopovar/AnyPS5/pull/6647) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6762](https://www.github.com/boykopovar/AnyPS5/pull/6762) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6804](https://www.github.com/boykopovar/AnyPS5/pull/6804) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6941](https://www.github.com/boykopovar/AnyPS5/pull/6941) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 6970](https://www.github.com/boykopovar/AnyPS5/pull/6970) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6972](https://www.github.com/boykopovar/AnyPS5/pull/6972) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 7254](https://www.github.com/boykopovar/AnyPS5/pull/7254) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 7256](https://www.github.com/boykopovar/AnyPS5/pull/7256) | `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` | | [PR 7390](https://www.github.com/boykopovar/AnyPS5/pull/7390) | `core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp` | | [PR 7392](https://www.github.com/boykopovar/AnyPS5/pull/7392) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvBdaFault.cpp` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp` |
LeandroLP23 commented 2026-10-18 16:33:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:33:22Z.


AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.

Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release. main 6efb7261b with this PR (e8b319833) merged, together with #7296, #7446, #7445, #6708, #6748, #6785, #6706, #6613, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.

  • agc_driver_gpu_buffer_format, agc_driver_graphics, agc_driver_layered_volume_draw: pass, 3 runs of 3.
  • Every agc_* test on the combined build: 713 of 716 pass. The 3 that fail, agc_driver_host_import_lifetime, agc_driver_quad_pixel_mask and agc_driver_layered_volume_vertex_no_gpl, fail the same way on unchanged main here, so none comes from these PRs.

AI-assisted

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252346275 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6252346275). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-18T16:33:22Z. --- AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release. `main` `6efb7261b` with this PR (`e8b319833`) merged, together with #7296, #7446, #7445, #6708, #6748, #6785, #6706, #6613, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean. - `agc_driver_gpu_buffer_format`, `agc_driver_graphics`, `agc_driver_layered_volume_draw`: pass, 3 runs of 3. - Every `agc_*` test on the combined build: 713 of 716 pass. The 3 that fail, `agc_driver_host_import_lifetime`, `agc_driver_quad_pixel_mask` and `agc_driver_layered_volume_vertex_no_gpl`, fail the same way on unchanged `main` here, so none comes from these PRs. AI-assisted
EagleBearerYS commented 2026-10-18 16:39:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-18T16:39:22Z.


@LeandroLP23 thanks for running them on the Radeon 860M. Your run is now in the Tested section, with your note that the three agc_* failures fail the same way on unchanged main there.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252408481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6252408481). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-18T16:39:22Z. --- @LeandroLP23 thanks for running them on the Radeon 860M. Your run is now in the Tested section, with your note that the three `agc_*` failures fail the same way on unchanged `main` there.
thuanquang commented 2026-10-18 20:38:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-18T20:38:27Z.


A reproduction of the crash on a discrete RDNA 2 card, red on main and green with this PR. RX 6700 XT (gfx1031, poonasor's model), AMD Windows driver 32.0.21045.5002 (the 21045 branch of Cleverdee's 32.0.21045.11001), Windows 11 26200, WinLibs GCC 15.2.0 r7, Release.

The test, agc_driver_pixel_bda_stops: a pixel shader that does N chained global_load_dword reads of mapped guest memory and exports the result, drawn once over mapped memory (all pixels must come out white) and once with the reads pointed past it (the draw must report the failed read and leave the target unchanged). It also counts the module's invocation exits. Each run below is a fresh renamed copy of the test executable, so AMD's per-executable pipeline cache starts empty, with ANYPS5_NO_SHADER_CACHE=1. Two runs per row:

N reads main c4c2b3aa7 main + this PR (e8b319833)
96 the pipeline is created; the test then fails its exit count (97 exits) passes, 2 exits
128 FATAL: unhandled exception 0xc0000005, rip amdvlk64.dll+0x9e251f passes, 2 exits
160 the same crash passes, 2 exits
216 (NHL 27's exit count) the same crash passes, 2 exits
250 the same crash passes, 2 exits (one run)

On main the process dies in the first draw, at amdvlk64.dll+0x9e251f, the offset in both reports above. With this PR the module ends the invocation in 2 places, the one BDA exit and the valid-mask kill, and every draw is correct.

With this PR, the three tests the description names and this one pass 3 of 3 runs each under ctest on this GPU: agc_driver_graphics, agc_driver_gpu_buffer_format, agc_driver_layered_volume_draw and agc_driver_pixel_bda_stops. The first, cold run of the 160-read pipeline took 167 s here, while parallel builds kept the CPU busy; the later runs, served from the driver cache, took about 5 s. I haven't timed it on an idle machine.

The test is on my fork as one commit on top of this PR's head: thuanquang/AnyPS5@d95a7903a (tests/execution/PixelBdaStops.cpp, 160 reads). Feel free to take it into this PR if you want an execution test of the crash. On a device that compiles the per-read form, it still fails on main, at the exit count.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254867040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6254867040). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-18T20:38:27Z. --- A reproduction of the crash on a discrete RDNA 2 card, red on `main` and green with this PR. RX 6700 XT (gfx1031, poonasor's model), AMD Windows driver 32.0.21045.5002 (the 21045 branch of Cleverdee's 32.0.21045.11001), Windows 11 26200, WinLibs GCC 15.2.0 r7, Release. The test, `agc_driver_pixel_bda_stops`: a pixel shader that does N chained `global_load_dword` reads of mapped guest memory and exports the result, drawn once over mapped memory (all pixels must come out white) and once with the reads pointed past it (the draw must report the failed read and leave the target unchanged). It also counts the module's invocation exits. Each run below is a fresh renamed copy of the test executable, so AMD's per-executable pipeline cache starts empty, with `ANYPS5_NO_SHADER_CACHE=1`. Two runs per row: | N reads | `main` `c4c2b3aa7` | `main` + this PR (`e8b319833`) | |---|---|---| | 96 | the pipeline is created; the test then fails its exit count (97 exits) | passes, 2 exits | | 128 | `FATAL: unhandled exception 0xc0000005`, `rip amdvlk64.dll+0x9e251f` | passes, 2 exits | | 160 | the same crash | passes, 2 exits | | 216 (NHL 27's exit count) | the same crash | passes, 2 exits | | 250 | the same crash | passes, 2 exits (one run) | On `main` the process dies in the first draw, at `amdvlk64.dll+0x9e251f`, the offset in both reports above. With this PR the module ends the invocation in 2 places, the one BDA exit and the valid-mask kill, and every draw is correct. With this PR, the three tests the description names and this one pass 3 of 3 runs each under ctest on this GPU: `agc_driver_graphics`, `agc_driver_gpu_buffer_format`, `agc_driver_layered_volume_draw` and `agc_driver_pixel_bda_stops`. The first, cold run of the 160-read pipeline took 167 s here, while parallel builds kept the CPU busy; the later runs, served from the driver cache, took about 5 s. I haven't timed it on an idle machine. The test is on my fork as one commit on top of this PR's head: [`thuanquang/AnyPS5@d95a7903a`](https://github.com/thuanquang/AnyPS5/commit/d95a7903a9309e5684fd11241a8e7ecefc438771) (`tests/execution/PixelBdaStops.cpp`, 160 reads). Feel free to take it into this PR if you want an execution test of the crash. On a device that compiles the per-read form, it still fails on `main`, at the exit count.
wachi35676 commented 2026-10-19 00:13:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T00:13:16Z.


AMD hardware result, which the PR lists as not tested. Tested at e8b319833 on Windows 11 (GCC 15.2.0, Release), merged onto main 9f25d0bf5, on an AMD Radeon iGPU, RDNA2 (1002:13c0, 32.0.21042.62, ANYPS5_GPU=AMD) and an RTX 5070 Ti (617.42).

  • agc_driver_graphics, agc_driver_layered_volume_draw and agc_driver_gpu_buffer_format pass on both.
  • In the 715-test agc_|shader|recompiler set, no test changes status against main on either GPU.
  • With the three shader files set back to main, agc_driver_graphics fails on both GPUs with ... did not end its BDA faults through one OpTerminateInvocation in its entry point (5 in the module).

I didn't reproduce the amdvlk crash itself; that needs the titles' large shaders.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6256919731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#issuecomment-6256919731). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T00:13:16Z. --- AMD hardware result, which the PR lists as not tested. Tested at `e8b319833` on Windows 11 (GCC 15.2.0, Release), merged onto `main` `9f25d0bf5`, on an AMD Radeon iGPU, RDNA2 (`1002:13c0`, 32.0.21042.62, `ANYPS5_GPU=AMD`) and an RTX 5070 Ti (617.42). - `agc_driver_graphics`, `agc_driver_layered_volume_draw` and `agc_driver_gpu_buffer_format` pass on both. - In the 715-test `agc_|shader|recompiler` set, no test changes status against `main` on either GPU. - With the three shader files set back to `main`, `agc_driver_graphics` fails on both GPUs with `... did not end its BDA faults through one OpTerminateInvocation in its entry point (5 in the module)`. I didn't reproduce the amdvlk crash itself; that needs the titles' large shaders. AI-assisted: yes (Claude Code); results above were run on this machine.
jotitadev commented 2026-10-19 02:19:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T02:19:07Z.

Review: COMMENTED


Apple GPU / MoltenVK run. One regression on Metal: agc_driver_stencil_ref_export_unused fails with this PR and passes without it.

Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head e8b319833, PR diff applied cleanly on top of the tree below. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.

Tested: the tree is main a373e85e5 + mugurc's macOS series (ci/macos-series-2, includes ImportWatched) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plain main (it doesn't build on macOS yet). Base on that tree: 40 ^agc failures with MoltenVK 1.4.2, the same known failures in every run below unless noted.

  • agc_driver_graphics, agc_driver_gpu_buffer_format, agc_driver_layered_volume_draw pass (the mesh case skips: no VK_EXT_mesh_shader).
  • thuanquang's PixelBdaStops.cpp (d95a7903a) passes: 160 chained reads, 2 invocation exits. Without the PR (exit-count check disabled) Metal also compiles the 161-exit module and both draws are correct, so Apple doesn't have the amdvlk crash.
  • Full ^agc suite: 40 of 728 fail, as on the base, but one of them is new: agc_driver_stencil_ref_export_unused fails 5 of 5 runs with the PR on MoltenVK 1.4.2 and also on MoltenVK main + #2704, and passes on the base tree. (The count matches only because agc_driver_cross_workgroup_flag, intermittent on Apple, passed in this run.)

MoltenVK rejects the fragment shader:

program_source:56:5: error: no matching function for call to '_22'
    _22(gl_HelperInvocation, gl_FragStencilRefARB, out.out_mrt_0, vsharp);
program_source:25:6: note: candidate function not viable: no known conversion from 'int' to 'uint &' (aka 'unsigned int &') for 2nd argument
[gpu] driver failure: AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3

The guest code is now its own function (%22), and gl_FragStencilRefARB (BuiltIn FragStencilRefEXT, OpVariable %_ptr_Output_int) is stored there. In this test the pipeline doesn't export stencil, so SPIRV-Cross makes the builtin a local int gl_FragStencilRefARB; in main0. It still declares the helper's parameter with the builtin's MSL type, thread uint&, so the call doesn't compile. Before this PR the store stayed in the entry point and no parameter was needed. agc_driver_stencil_ref_export, where the stencil output is live, passes.

That's a SPIRV-Cross issue, but this PR is what exposes it. Possible ways around it: declare the stencil reference output as a 32-bit uint (FragStencilRefEXT takes a scalar 32-bit integer), or keep the per-site form for pixel shaders that write FragStencilRefEXT, as for primitive-ordered ones. I haven't tried either. The MSL and SPIR-V dumps are available if useful.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704 for the stencil failure)

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5566288581 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7377#pullrequestreview-5566288581). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-19T02:19:07Z. **Review:** COMMENTED --- <!-- head: e8b319833 --> Apple GPU / MoltenVK run. One regression on Metal: `agc_driver_stencil_ref_export_unused` fails with this PR and passes without it. Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head e8b319833, PR diff applied cleanly on top of the tree below. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704. **Tested:** the tree is `main` a373e85e5 + mugurc's macOS series (`ci/macos-series-2`, includes ImportWatched) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plain `main` (it doesn't build on macOS yet). Base on that tree: 40 `^agc` failures with MoltenVK 1.4.2, the same known failures in every run below unless noted. - `agc_driver_graphics`, `agc_driver_gpu_buffer_format`, `agc_driver_layered_volume_draw` pass (the mesh case skips: no `VK_EXT_mesh_shader`). - thuanquang's `PixelBdaStops.cpp` (d95a7903a) passes: `160 chained reads, 2 invocation exits`. Without the PR (exit-count check disabled) Metal also compiles the 161-exit module and both draws are correct, so Apple doesn't have the amdvlk crash. - Full `^agc` suite: 40 of 728 fail, as on the base, but one of them is new: **`agc_driver_stencil_ref_export_unused` fails 5 of 5 runs** with the PR on MoltenVK 1.4.2 and also on MoltenVK main + #2704, and passes on the base tree. (The count matches only because `agc_driver_cross_workgroup_flag`, intermittent on Apple, passed in this run.) MoltenVK rejects the fragment shader: ``` program_source:56:5: error: no matching function for call to '_22' _22(gl_HelperInvocation, gl_FragStencilRefARB, out.out_mrt_0, vsharp); program_source:25:6: note: candidate function not viable: no known conversion from 'int' to 'uint &' (aka 'unsigned int &') for 2nd argument [gpu] driver failure: AGC graphics: vkCreateGraphicsPipelines: Vulkan result -3 ``` The guest code is now its own function (`%22`), and `gl_FragStencilRefARB` (`BuiltIn FragStencilRefEXT`, `OpVariable %_ptr_Output_int`) is stored there. In this test the pipeline doesn't export stencil, so SPIRV-Cross makes the builtin a local `int gl_FragStencilRefARB;` in `main0`. It still declares the helper's parameter with the builtin's MSL type, `thread uint&`, so the call doesn't compile. Before this PR the store stayed in the entry point and no parameter was needed. `agc_driver_stencil_ref_export`, where the stencil output is live, passes. That's a SPIRV-Cross issue, but this PR is what exposes it. Possible ways around it: declare the stencil reference output as a 32-bit uint (FragStencilRefEXT takes a scalar 32-bit integer), or keep the per-site form for pixel shaders that write `FragStencilRefEXT`, as for primitive-ordered ones. I haven't tried either. The MSL and SPIR-V dumps are available if useful. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704 for the stencil failure) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!7377
No description provided.