Intel Mesa < 26.2: flat_store and masked_global_store (earlier flat_loads_x2_x3) fail to compile (SIMD32 scratch over 256 KiB) because each inlined BDA lookup records faults from 16 sites; fix branch ready #2972

Open
opened 2026-10-10 19:08:01 +00:00 by milescoviello · 6 comments
milescoviello commented 2026-10-10 19:08:01 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-10T19:08:01Z.


agc_driver_flat_loads_x2_x3 and agc_driver_masked_global_store fail on an Intel Arrow Lake iGPU with Mesa 26.1.8 ANV:

vkCreateComputePipelines: Vulkan result -13

With INTEL_DEBUG=perf:

MESA: warning: ../mesa-26.1.8/src/intel/vulkan/anv_shader_compile.c:2294: Can't compile shader:
  SIMD8 'Different than required dispatch width', SIMD16 'Different than required dispatch width' and
  SIMD32 'SIMD32 CS compile failed: Scratch space required is larger than supported'.

Both pass on NVIDIA. Neither is in the failure lists for Arrow Lake on Intel's Windows driver (#2815, #2822) or for Meteor Lake on Mesa 26.2.3 (#2805).

Setup: Gentoo, kernel 7.2.8 (xe), GCC 15.3.0, Release with CI's configure flags (-DANYPS5_ENABLE_SPIRV_TOOLS=ON), main 1476f769. Intel Arrow Lake iGPU (0x7d67), Mesa 26.1.8 ANV; RTX 5090 Laptop GPU (610.57.04) for comparison.

Cause:

  • Wave32 compute programs require a 32-lane subgroup (requiredSubgroupSize, VulkanDevice.cpp:3768), which on Intel means SIMD32 only.
  • DefineBdaLookup (SpirvBdaLookup.cpp) returns from each of its 16 checks through its own record_bda_fault call (ReturnBdaFailureIf, SpirvBdaFault.cpp:89). The lookups are DontInline (#174), but NIR inlines every call: flat_loads_x2_x3 ends up with 48 inlined get_bda_pointer copies, 768 fault records and 435 ssbo_atomic_swap in its final NIR (INTEL_DEBUG=cs). The module itself passes spirv-val --target-env vulkan1.3.
  • Xe-HPG and later cap per-thread scratch at 256 KiB (intel_device_info.c: verx10 >= 125 ? 256 KiB : 2 MiB), and before 26.2 Mesa gives every spilled VGRF its own scratch slot (brw_reg_allocate.cpp), so the SIMD32 spills pass the cap and brw_shader.cpp fails the compile. Mesa 26.2 shares spill slots between disjoint live ranges (alloc_spill_scratch), which is why Meteor Lake on 26.2.3 passes. Alder Lake (gfx12.0, 2 MiB) is not affected, as in #1408.

So any Xe-HPG or later GPU (Arc, Meteor/Arrow/Lunar Lake) on Mesa 26.1 or older hits it, and shaders with more global accesses than these tests can too.

Fix: milescoviello/AnyPS5:fix/bda-lookup-one-fault-exit (one commit, 934348f2, on main 1476f769; the 13 commits on main since then do not touch these files).

  • A failing check stores its FaultReason and leaves through nested selections to one exit, which records the fault once and returns 0, or returns the address. The checks, their order and the recorded reason, address, bytes and instruction are unchanged. The probe lookups (recordFaults == false) are emitted as before.
  • RecordBdaFaultReason takes the reason as an id; the unused ReturnBdaFailureIf is removed.
  • agc_shader_memory (verifyBdaReadFallbackFunctions) gains a check that get_bda_pointer records faults from one call site; it fails on main.
  • Overlap: #2837 also edits DefineBdaLookup and keeps the 16 exits. Whichever lands second needs a small rebase, and #2837's new Private variables are worth re-testing on Intel with these two tests.

Tested: full ctest --parallel 4 on both GPUs. Intel excludes agc_driver_lds_beyond_device_limit (#2805); the three guest_video_out_* tests were excluded because the displays were powered off, which hangs their window creation.

main 1476f769 Intel ANV NVIDIA
with the fix 695/700. The 5 failures are pre-existing: mesh, f64_fma_subnormals, gated_dispatch_capture (#2832), vop1_float_unary, vopc_compare 700/701: dcc_keys_first_write (#2767)
without flat_loads_x2_x3 and masked_global_store fail with -13

agc_driver_bda_device_tests (each recorded fault reason: Unmapped, Overflow, InvalidTable, Permission) passes on both GPUs with the fix. tools/check_conventions.py passes.

Cold compiles (driver and AnyPS5 shader caches off, measured on main 57f96fd2), main → fix:

Test Intel cold run Intel spills / fills NVIDIA binary bytes
flat_loads_x2_x3 8.2 s (fails) → 1.2 s fails → 669 / 1,190 43,904 → 35,712
masked_global_store 22.1 s (fails) → 6.0 s fails → 3,378 / 5,840 320,256 → 260,352
flat_loads 5.1 s → 0.8 s 3,294 / 3,919 → 60 / 120 48,512 → 41,472
flat_store 74.8 s → 28.5 s 9,893 / 26,071 → 3,860 / 7,442 382,464 → 340,992
global_vcc_base 47.1 s → 14.7 s 11,189 / 29,545 → 8,092 / 11,541 516,480 → 379,904

Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5794391912 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-10T19:08:01Z. --- `agc_driver_flat_loads_x2_x3` and `agc_driver_masked_global_store` fail on an Intel Arrow Lake iGPU with Mesa 26.1.8 ANV: ``` vkCreateComputePipelines: Vulkan result -13 ``` With `INTEL_DEBUG=perf`: ``` MESA: warning: ../mesa-26.1.8/src/intel/vulkan/anv_shader_compile.c:2294: Can't compile shader: SIMD8 'Different than required dispatch width', SIMD16 'Different than required dispatch width' and SIMD32 'SIMD32 CS compile failed: Scratch space required is larger than supported'. ``` Both pass on NVIDIA. Neither is in the failure lists for Arrow Lake on Intel's Windows driver (#2815, #2822) or for Meteor Lake on Mesa 26.2.3 (#2805). **Setup:** Gentoo, kernel 7.2.8 (xe), GCC 15.3.0, Release with CI's configure flags (`-DANYPS5_ENABLE_SPIRV_TOOLS=ON`), `main` 1476f769. Intel Arrow Lake iGPU (0x7d67), Mesa 26.1.8 ANV; RTX 5090 Laptop GPU (610.57.04) for comparison. **Cause:** - Wave32 compute programs require a 32-lane subgroup (`requiredSubgroupSize`, `VulkanDevice.cpp:3768`), which on Intel means SIMD32 only. - `DefineBdaLookup` (`SpirvBdaLookup.cpp`) returns from each of its 16 checks through its own `record_bda_fault` call (`ReturnBdaFailureIf`, `SpirvBdaFault.cpp:89`). The lookups are `DontInline` (#174), but NIR inlines every call: `flat_loads_x2_x3` ends up with 48 inlined `get_bda_pointer` copies, 768 fault records and 435 `ssbo_atomic_swap` in its final NIR (`INTEL_DEBUG=cs`). The module itself passes `spirv-val --target-env vulkan1.3`. - Xe-HPG and later cap per-thread scratch at 256 KiB (`intel_device_info.c`: `verx10 >= 125 ? 256 KiB : 2 MiB`), and before 26.2 Mesa gives every spilled VGRF its own scratch slot (`brw_reg_allocate.cpp`), so the SIMD32 spills pass the cap and `brw_shader.cpp` fails the compile. Mesa 26.2 shares spill slots between disjoint live ranges (`alloc_spill_scratch`), which is why Meteor Lake on 26.2.3 passes. Alder Lake (gfx12.0, 2 MiB) is not affected, as in #1408. So any Xe-HPG or later GPU (Arc, Meteor/Arrow/Lunar Lake) on Mesa 26.1 or older hits it, and shaders with more global accesses than these tests can too. **Fix:** [`milescoviello/AnyPS5:fix/bda-lookup-one-fault-exit`](https://github.com/milescoviello/AnyPS5/tree/fix/bda-lookup-one-fault-exit) (one commit, `934348f2`, on `main` 1476f769; the 13 commits on `main` since then do not touch these files). - A failing check stores its `FaultReason` and leaves through nested selections to one exit, which records the fault once and returns 0, or returns the address. The checks, their order and the recorded reason, address, bytes and instruction are unchanged. The probe lookups (`recordFaults == false`) are emitted as before. - `RecordBdaFaultReason` takes the reason as an id; the unused `ReturnBdaFailureIf` is removed. - `agc_shader_memory` (`verifyBdaReadFallbackFunctions`) gains a check that `get_bda_pointer` records faults from one call site; it fails on `main`. - Overlap: #2837 also edits `DefineBdaLookup` and keeps the 16 exits. Whichever lands second needs a small rebase, and #2837's new Private variables are worth re-testing on Intel with these two tests. **Tested:** full `ctest --parallel 4` on both GPUs. Intel excludes `agc_driver_lds_beyond_device_limit` (#2805); the three `guest_video_out_*` tests were excluded because the displays were powered off, which hangs their window creation. | `main` 1476f769 | Intel ANV | NVIDIA | |---|---|---| | with the fix | 695/700. The 5 failures are pre-existing: `mesh`, `f64_fma_subnormals`, `gated_dispatch_capture` (#2832), `vop1_float_unary`, `vopc_compare` | 700/701: `dcc_keys_first_write` (#2767) | | without | `flat_loads_x2_x3` and `masked_global_store` fail with -13 | | `agc_driver_bda_device_tests` (each recorded fault reason: Unmapped, Overflow, InvalidTable, Permission) passes on both GPUs with the fix. `tools/check_conventions.py` passes. Cold compiles (driver and AnyPS5 shader caches off, measured on `main` 57f96fd2), `main` → fix: | Test | Intel cold run | Intel spills / fills | NVIDIA binary bytes | |---|---|---|---| | `flat_loads_x2_x3` | 8.2 s (fails) → 1.2 s | fails → 669 / 1,190 | 43,904 → 35,712 | | `masked_global_store` | 22.1 s (fails) → 6.0 s | fails → 3,378 / 5,840 | 320,256 → 260,352 | | `flat_loads` | 5.1 s → 0.8 s | 3,294 / 3,919 → 60 / 120 | 48,512 → 41,472 | | `flat_store` | 74.8 s → 28.5 s | 9,893 / 26,071 → 3,860 / 7,442 | 382,464 → 340,992 | | `global_vcc_base` | 47.1 s → 14.7 s | 11,189 / 29,545 → 8,092 / 11,541 | 516,480 → 379,904 | Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit. AI-assisted: yes
milescoviello commented 2026-10-11 06:45:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-11T06:45:07Z.


Update on current main 1690db9a (Intel Arrow Lake ANV, Mesa 26.1.8): agc_driver_flat_store now fails the same way, while flat_loads_x2_x3 passes. The branch still merges cleanly and fixes both remaining failures.

Test main 1690db9a main + 934348f2
agc_driver_flat_store fails: SIMD32 CS compile failed: Scratch space required is larger than supported (-13) passes (27.4 s)
agc_driver_masked_global_store fails: same error (-13) passes
agc_driver_flat_loads_x2_x3 passes passes
flat_loads, bda_device, shader_memory, prepared_shaders pass pass

My guess is that these shaders sit close to the 256 KiB per-thread scratch limit, so unrelated codegen changes move individual tests across it in either direction. I haven't measured that. Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106362848 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6106362848). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-11T06:45:07Z. --- Update on current `main` 1690db9a (Intel Arrow Lake ANV, Mesa 26.1.8): `agc_driver_flat_store` now fails the same way, while `flat_loads_x2_x3` passes. The branch still merges cleanly and fixes both remaining failures. | Test | `main` 1690db9a | `main` + 934348f2 | |---|---|---| | `agc_driver_flat_store` | fails: `SIMD32 CS compile failed: Scratch space required is larger than supported` (-13) | passes (27.4 s) | | `agc_driver_masked_global_store` | fails: same error (-13) | passes | | `agc_driver_flat_loads_x2_x3` | passes | passes | | `flat_loads`, `bda_device`, `shader_memory`, `prepared_shaders` | pass | pass | My guess is that these shaders sit close to the 256 KiB per-thread scratch limit, so unrelated codegen changes move individual tests across it in either direction. I haven't measured that. Not opened as a PR because intake is paused for new contributors; a maintainer is welcome to carry the commit. AI-assisted: yes
MarcZX10 commented 2026-10-13 17:01:19 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T17:01:19Z.


I rebased Miles’s 934348f2 fix onto current main (now commit 56523bf5, preserving his author metadata) and verified the focused Linux test locally: agc_shader_memory passed 1/1; git diff --check is clean. The change is viable, but I did not open another PR because the same lookup is now touched by both #2837 and #3655, with #2837’s overlap check already flagging #3655. A third PR would add another sequencing/rebase dependency. The issue reproduction and Intel/NVIDIA results remain useful for whichever of those is integrated first; this fix should be reevaluated on top of that result.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6150826450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6150826450). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-13T17:01:19Z. --- I rebased Miles’s `934348f2` fix onto current `main` (now commit `56523bf5`, preserving his author metadata) and verified the focused Linux test locally: `agc_shader_memory` passed 1/1; `git diff --check` is clean. The change is viable, but I did not open another PR because the same lookup is now touched by both #2837 and #3655, with #2837’s overlap check already flagging #3655. A third PR would add another sequencing/rebase dependency. The issue reproduction and Intel/NVIDIA results remain useful for whichever of those is integrated first; this fix should be reevaluated on top of that result.
MarcZX10 commented 2026-10-14 12:03:25 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T12:03:25Z.


After #3655 merged, I carried Miles's one-fault-site follow-up as #5814, preserving the original commit metadata. It reduces flat_store cold compile time from 65 s to 51 s and masked_global_store from 4.7 s to 3.8 s in Miles's post-#3655 Arrow Lake / Mesa 26.1.8 measurements. I have not rerun those measurements or built this follow-up locally; the PR states that explicitly. This follow-up reduces compiler work and does not claim to fix current Mesa failures by itself.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6167892719 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6167892719). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-14T12:03:25Z. --- After #3655 merged, I carried Miles's one-fault-site follow-up as [#5814](https://github.com/boykopovar/AnyPS5/pull/5814), preserving the original commit metadata. It reduces `flat_store` cold compile time from 65 s to 51 s and `masked_global_store` from 4.7 s to 3.8 s in Miles's post-#3655 Arrow Lake / Mesa 26.1.8 measurements. I have not rerun those measurements or built this follow-up locally; the PR states that explicitly. This follow-up reduces compiler work and does not claim to fix current Mesa failures by itself.
MarcZX10 commented 2026-10-18 19:53:11 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T19:53:11Z.


Follow-up on the proposed one-exit fix: it was carried as PR #5814 and then closed after a Gen9 Intel HD 520 / Mesa 25.2.8 run showed a material runtime regression on DOOM Shareware. The presentation dispatch median rose from about 527 ms to 874 ms, and 5/6 runs hit an i915 preemption reset versus 0/6 on main. The compile-time reductions were real, but the merged exit increased register pressure and spills on this GPU. Maintainers said a reworked variant may be reopened if it keeps the compile benefit without that regression and reports the HD 520 timing/reset counts. I have not found an open replacement PR; the closed implementation should not be carried forward unchanged.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254406216 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6254406216). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-18T19:53:11Z. --- Follow-up on the proposed one-exit fix: it was carried as PR #5814 and then closed after a Gen9 Intel HD 520 / Mesa 25.2.8 run showed a material runtime regression on DOOM Shareware. The presentation dispatch median rose from about 527 ms to 874 ms, and 5/6 runs hit an i915 preemption reset versus 0/6 on main. The compile-time reductions were real, but the merged exit increased register pressure and spills on this GPU. Maintainers said a reworked variant may be reopened if it keeps the compile benefit without that regression and reports the HD 520 timing/reset counts. I have not found an open replacement PR; the closed implementation should not be carried forward unchanged.
milescoviello commented 2026-10-18 19:54:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T19:54:13Z.


@MarcZX10 thanks for the summary. I'll leave this open as the known limit. I don't have a Gen9 GPU, so I can't produce the HD 520 timing and reset counts for a reworked variant myself.

It matters for #7571, which also restructures the BDA lookup. It doesn't merge fault-recording sites like #5814; it makes the lookup functions leave through one return, a one-pass loop with a phi. The register-pressure risk is related, though. I'll measure #7571 on the Arrow Lake iGPU (ANV): Mesa's per-shader statistics, including spills and fills, for the BDA tests' shaders with and without it, plus their run times, and post them on #7571. Arrow Lake is Gen12.7, not Gen9, so it won't replace an HD 520 run, and the PR will say so.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254416178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6254416178). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T19:54:13Z. --- @MarcZX10 thanks for the summary. I'll leave this open as the known limit. I don't have a Gen9 GPU, so I can't produce the HD 520 timing and reset counts for a reworked variant myself. It matters for #7571, which also restructures the BDA lookup. It doesn't merge fault-recording sites like #5814; it makes the lookup functions leave through one return, a one-pass loop with a phi. The register-pressure risk is related, though. I'll measure #7571 on the Arrow Lake iGPU (ANV): Mesa's per-shader statistics, including spills and fills, for the BDA tests' shaders with and without it, plus their run times, and post them on #7571. Arrow Lake is Gen12.7, not Gen9, so it won't replace an HD 520 run, and the PR will say so. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 20:44:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T20:44:03Z.


@MarcZX10 the Arrow Lake measurement I mentioned is on #7571 (comment). On Mesa 26.1.6 ANV, all 107 compiled variants of agc_driver_bda_device come out the same with and without #7571: identical assembly, no spills in either build, and the same run times. It's Gen12.7, so the HD 520 question stays open.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6254924601 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/2972#issuecomment-6254924601). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T20:44:03Z. --- @MarcZX10 the Arrow Lake measurement I mentioned is on #7571 ([comment](https://github.com/boykopovar/AnyPS5/pull/7571#issuecomment-6254923176)). On Mesa 26.1.6 ANV, all 107 compiled variants of `agc_driver_bda_device` come out the same with and without #7571: identical assembly, no spills in either build, and the same run times. It's Gen12.7, so the HD 520 question stays open. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
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#2972
No description provided.