Repository navigation
fix(shader): keep faulting invocations in their wave and mask their later writes - #6416
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
|
@Celegans12 a data point from Ghost of Yōtei (PPSA26344): RTX 4090, driver 617.42, Windows 11. This PR on main 0dab493 + #5815 #5781 #6227 #5405 #6402 #6174, with In our base, this PR conflicted in It still loses the device, at ~1,460 s (frame ~817):
That's the same signature as our earlier spanned runs without this PR. The non-spanned build of 0x80001e5f00 (839,036 words) dispatched fine. The spanned pipeline (838,306 words) was created about 5 minutes before the loss, but the log has no dispatch line for it. After it came several minutes of cold compiles of new 0x801d* programs, and the loss hit while 0x801d29eb00 was being created. So I can't tell whether that program or another spanned one hung. With spanned waves off, the same base runs well past that point. If you have a suspect, I can rerun with more logging. |
|
A cost I measured tonight that reviewers should know about: on NVIDIA, the write mask roughly doubles pipeline compile time for PPSA26344's giant two-lane compute programs. Compiled side by side on the same machine, compute 0x801cdd2700 (about 1.75M SPIR-V words) takes 700 s with the earlier "reads continue, nothing masked" version and 1,411 s with this PR. The module is only about 0.5% bigger: roughly 90 more branches and about 550 more stores and loads of the per-lane faulted flag. So the extra time looks like NVIDIA's compiler handling a flag that stays live across the whole program, not the extra code itself. For now our game branch keeps the older version, so our precompiles don't take twice as long. I'll look at making the mask cheaper, for example only guarding writes that a fault can reach, or keeping the flag in a form the compiler handles better, and post numbers here. If anyone has a preferred shape for this, I'm happy to hear it before I start. Details
|
|
Tested on Linux with lavapipe, the CI device: llvmpipe (Mesa 26.2.4, LLVM 23.1.1), CachyOS, GCC 16.2.1, CMake 4.4.3, default build type, full build with This PR (
The reason, from the code: lavapipe reports 8-wide subgroups ( if (device->Target().subgroupSize != 32u) {
std::printf("skipped, the device runs wave64 programs on %u-wide subgroups\n", device->Target().subgroupSize);
return VulkanTestSkipped;
}would make lavapipe report a device-limited skip ( This may be useful for the mask rework you mention: on lavapipe the test passes even with the fix reverted, so it can't show whether a cheaper mask still handles the two-lane cases. That can only be checked on a 32-wide device, such as your RTX 3080 Laptop GPU. Merged together with #6402 (on
Apart from those, the failed and skipped lists match Not tested: NVIDIA, AMD, Intel, PPSA26344. AI-assisted: yes |
|
Barrier-program follow-up: #6689. I reproduced later guest writes after an unmapped BDA read plus Proposed follow-up reuses your per-lane mask, keeps the invocations at their barriers, and carries the checked BDA helper's fault result back to the correct lane half. All-fault and mixed valid/faulting lane tests pass 5/5 per GPU. The full Windows build and focused checks passed, but broader regression/static-analysis gates remain incomplete; the current checkpoint and remaining checks are recorded in #6689. This prototype is deferred while we pivot to PR maintenance. Proposed ordering is #6416 first, then this compute follow-up. If you prefer to incorporate it here, the focused commit is available to take. No competing upstream PR is open. AI-assisted: yes. |
|
While preparing the barrier follow-up, I checked the narrow-subgroup case raised in the review. The current |
|
I opened stacked follow-up #6751 for the test-only subgroup guard discussed here. The |
|
Rebase handoff — rebased onto current Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
|
Thanks. Main has moved under this PR: since bd6ed97, |
|
Correction to my earlier note: spanned waves are opt-in on |
jotitadev
left a comment
There was a problem hiding this comment.
Apple GPU / MoltenVK run. Apple's subgroup size is exactly 32, the case agc_driver_faulting_wave_invocation needs (see #6751): red without the fix, green with it, and no other change.
Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head 9c76817, PR diff applied cleanly. Driver: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), subgroup=32.
Tested: the tree is main a373e85 + mugurc's macOS series (ci/macos-series-2) + 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, the same known failures in every run below unless noted.
agc_driver_faulting_wave_invocationwith the PR: passes 3 of 3.- The test alone on the base tree: fails with
lane 0 left the EXEC loop after 100 passes, expected 4 (the loop stops at 100). - Full
^agcsuite with the PR: 40 of 728 fail, the same 40 as the base.
About the spanned-wave gap @oneandonlydean described: it can't occur on MoltenVK today. With APS5_SPANNED_WAVE=1 the driver logs spans two full 32-lane subgroups: 0, because MoltenVK doesn't give full compute subgroups, so wave64 always takes the two-lane path here and the masking stays on.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
|
@oneandonlydean, thanks for doing the rebase and for sorting out the spanned-wave question. Yes, I'll take the spanned-wave masking as a follow-up PR once this one is in. The plan is what you describe: record the fault in About Yōtei: our runs do use |
…x for named wave-operation programs (boykopovar#6416 masks elsewhere)
22e2f3a to
9588d31
Compare
… faulting wave code
|
@Celegans12, cc @oneandonlydean (your 10-27 question about late level starts in ASTRO BOT): we ran the cold-start comparison on AMD and Windows, and with this PR the level did not start late. Setup. ASTRO BOT (PPSA21567, 01.019.000), AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1, Windows 11 build 26300, Ryzen 7 5800X3D. Two layouts from one clone: plain Level start (the
The texture-budget step. The Limits.
AI-assisted: yes (Claude Code) |
|
@Celegans12, cc @oneandonlydean, one note on our ASTRO BOT level-start runs (AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1, Windows 11 build 26300): their base AI-assisted: yes (Claude Code) |
|
@oneandonlydean, cc @Celegans12: a repeat of your 10-27 ASTRO BOT check as you described it (unprofiled and draw-profiler runs, time to the level, the texture-budget line), this time on a base without #16053. On AMD / Windows the PR started the level on time in every run, and the texture-budget line was there in every PR run. Setup. ASTRO BOT (PPSA21567, 01.019.000), AMD Radeon RX 9070 XT, AMD proprietary driver 26.11.1 (the summary line names it
The game's So on this machine neither symptom shows: no late level start in 6 of 6 PR runs, and the budget line is present in all 7 PR runs including the cold one. Limits.
AI-assisted: yes (Claude Code) |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — comments
Changes are required before merge: please confirm the invocation fault mask is correct for memory writes that happen inside emitted helper functions.
What I ran
Reviewed head ab3e21c97c54ce34cff2611cc5dd33f3bb02fb3a using the prepared diff and the pinned repo_read.py reader. No build or tests were run by me; test results in the PR description are author reported.
Results
| Check | Result | Note |
|---|---|---|
| Diff and targeted source review | passed | Emitter, fault, read and test paths inspected |
| Build and tests | not run | No commands executed |
Findings
Blocking
None verified.
Non-blocking
- The new guard in
EmitUnlessInvocationFaultedapplies only to instructions emitted directly from the structured block. Please verify that writes performed by helper functions called from a later instruction are also suppressed after a lane faults. I did not trace all helper call paths, so this is a question for follow-up rather than a verified defect. The relevant dispatch is atcore/shader/recompiler/SpirvBackend/src/SpirvFlowEmitter.cpp:837.
Not verified
ShaderMemory.cppwas read through the pinned reader around the changed guarded-pointer checks; the rest of that large file was not read. All other changed source files listed as included in the manifest were read in targeted sections, along with the addedFaultingWaveInvocation.cpp.repo_read.pyreportsShaderMemory.cppas excluded from the review folder for size; the remaining changed files were included.files.jsonwas unavailable as a review-folder file, so exclusions are reported from the manifest and reader listing.- Build, current-head tests, CI, console behavior, and the complete set of helper-function write paths were not verified. Test outcomes in
description.mdare author reported.
To get this to a good state
Nothing is required. Optional: confirm and, if needed, test that helper-function writes are masked after the faulting read.
Keep FormatVersion 90 (main is at 88) and keep both main's NaN region emitters and this branch's write masking helpers in SpirvFlowEmitter.cpp.
|
@Celegans12 I merged main into the branch (e16be77) to clear the conflicts. ShaderDiskCache.hpp keeps FormatVersion 90 (main is at 88, and the other open shader PRs now use 101 and 103). In SpirvFlowEmitter.cpp main's new NaN region emitters and your WritesGuestState and EmitUnlessInvocationFaulted helpers landed in the same place; I kept both blocks whole. agc_driver_faulting_wave_invocation and the agc_shader_memory tests pass on Linux at the merge head. Please pull before your next push. |
|
Ran the faulting-wave case and the neighbouring guarded-pointer and BDA tests at the current head on Linux, which the description lists as not tested, with NVIDIA's proprietary driver and the Khronos validation layer. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
Negative control: this PR's build with No new AI-assisted: yes (Claude Code) |
Keeps this branch's FormatVersion at 93, above main's 90 (#6416).
What
Stopping a faulting invocation can leave wave ballots unable to converge and stop its healthy partner lane. Eligible non-pixel programs with two lanes per invocation, ballots or shuffles now keep voting with the failed read's zero and mask that lane's later writes, atomics and exports. Existing spanned-wave, barrier and mesh exclusions remain.
Continuing exposed a guarded-SRT reporting regression: the second word of a null pointer replaced the first fault record. Adopt ThatsLeo's first-fault latch from #7922, adapted so masked lanes count as continuing. The existing guarded-pointer runtime oracle stays unchanged, and its host checks require compare-from-zero latches without unconditional overwrites. No spanned-wave policy from #7922 is included.
Masking adds work even without faults. Astro Bot's reported startup delay remains unexplained; no performance claim. The barrier-safe extension and subgroup-specific skip remain separate in #7392 and #6751.
Tested
Based on
mainb4a8272 (rebased 2026-11-13 as one commit; the only conflict was the cache format, nowShaderDiskCache::FormatVersion90). On that tip, 61 focused host and NVIDIA tests (fault, guarded-pointer and guarded-load, faulting-wave, BDA span and anchor reads, GPU buffer format, wave decoding, shader memory and shader cache) passed three times with validation 1.4.363 loaded and no VUIDs or skips.Earlier rounds, on
maine6f5730: Windows 11, MinGW-w64 GCC 15.2.0: Release, -DBUILD_TESTING=ON, SPIR-V Tools ON. Before repair, main passesagc_driver_guarded_null_pointer; the merged PR fails 3/3 at address4 instead of0, PC0x24. One diagnostic run confirms the overwrite.Repaired head
771c8bdae4: 13/13 focused processes pass: host shader-memory; NVIDIA guarded-pointer x3, faulting-wave, GPU-buffer-format, BDA-device and span-reads; the same five GPU tests once on Windows lavapipe. All GPU runs require Vulkan, disable application shader caching and load validation 1.4.363; zero skips, timeouts or validation diagnostics. Lavapipe subgroup8 does not establish paired wave64-on32 behavior. Test registration, conventions and source review pass.Earlier baseline
e2df06e661plus the faulting-wave fixture fails on main because partner lane37 stays untouched. Not tested: current-head Linux, AMD/Intel hardware, console behavior or titles.On the merge with main
98346b748c, the wave invocation case initially failed on the hardware-spanning wave path. The follow-up keeps those lanes active but masks writes after a fault, and guards byte loads when the lane continues. Six selected fault, guarded-load, wave-decode and cache tests passed twice on Windows with an NVIDIA RTX 3080 Laptop GPU and Vulkan validation enabled. The updated emitter, BDA read and shader-cache sources also passed Linux C++ syntax and layout-guard compilation. No Linux GPU run was performed.Checklist
main; the first-fault latch from perf(shader): span single-wave wave64 compute by default after a uniformity check #7922 is adopted with attributionNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)