perf(vk): build Intel compute programs that cannot see their lanes without the 32-lane pin #2564
Open
thomas-montano wants to merge 1 commit from
thomas-montano/perf/intel-compute-pin into main
pull from: thomas-montano/perf/intel-compute-pin
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2564
Loading…
Reference in a new issue
No description provided.
Delete branch "thomas-montano/perf/intel-compute-pin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
On Intel/Mesa, game compute programs are required to run at 32 lanes even when they cannot see their subgroup. On an Iris Xe that makes some first builds take 5-26 seconds, leaving the effects they draw missing while the player waits.
Part of #1001
What changed
spirv_uses_subgroupsreads the SPIR-V's declared capabilities: GroupNonUniform*, the KHR ballot and vote, Groups and cooperative matrices mean the lane count matters. Unknown or malformed SPIR-V is treated as subgroup-using.pin_computeleaves a compute program without those capabilities unpinned, so the driver chooses its width. A program with shared memory and at most 32 invocations stays pinned: a compiler may drop barriers a single-warp workgroup does not need.pin_compute.RX_VK_PIN_ALL=1pins every program as before;=0enables the selective rule on any GPU.This complements #2513: that change reduces the SPIR-V for table-heavy programs; this one removes the SIMD32 requirement only from programs that cannot observe their subgroup.
Checks
tests/test_compute_pin.pychecks the capability scan, the pin decision, the shared-memory exception and every game compute pipeline's use ofpin_compute.tests/test_program_cache_cleanup.pycompiles the scan with the cache loader.tests/test_precompile_compute_guard.pycompiles the precompile's compute arm with apin_computestand-in; which programs are pinned is left totests/test_compute_pin.py.Tested in the game
Iris Xe (Raptor Lake-P, i9-13900H, 32 GB), Mesa ANV 26.2.4, Bazzite. Headless at the Deku Tree, with the serial queue's escape:
9790303532c0c309,76b54f5bb0d7ce97,37d9fd3069f0e5e4and0fe7f6c474c57be5each built in under 0.2 s without the pin, against 5.5, 26.4, 14.7 and 14.5 s pinned.RX_VK_PIN_ALL=1(9.2 against 9.1 fps).Not tested: other Intel GPUs, Windows.
I merged this into current main. tests/test_compute_pin.py, test_program_cache_cleanup.py and test_env_on.py pass. test_precompile_compute_guard.py needs Windows SEH, so it skipped here, but CI ran it green. The capability scan is correct, and anything it can't parse counts as subgroup-using. Other vendors keep the pin by default. The 5.5–26 s first builds against under 0.2 s on the Iris Xe are a measurement worth having.
One risk I'd like you to address or rule out. vk_draw.cpp:198 keeps the pin for shared-memory programs only when they have at most 32 invocations. Guest code written for Maxwell can also be warp-synchronous inside a larger workgroup. The classic case is a reduction tail through shared memory without BAR for the last 32 lanes. That needs no subgroup capability in the SPIR-V. It was safe at SIMD32, and on ANV's SIMD8/16 it can read stale values. Could you check whether the four slow programs use shared memory at all? If they don't, keeping every shared-memory program pinned costs nothing and removes the question. The picture matching RX_VK_PIN_ALL=1 at the Deku Tree is good, but it is a single scene.
You’re right @Joey-Magnus that the capability scan cannot rule out implicit warp-synchronous shared-memory access. I checked all four measured programs, including all 16 cached variants of 76b54f5bb0d7ce97: every one has shared_memory == 0, and their SPIR-V contains no Workgroup variables or control barriers. I’ll remove the invocations <= 32 exception and keep every shared-memory program pinned. The four measured programs will still be unpinned, so this removes the risk without giving up their compile-time improvement.
Do you want me to push those changes up to this PR or will you make them outside of this PR?
A test on a second Intel GPU, the gap your description names ("other Intel GPUs").
Hardware: Intel UHD 770 (Raptor Lake-S), Mesa ANV 26.2.5-arch1.1, Arch Linux 7.2.15-1-omarchy, i9-13900K. Built:
1ef2a295e43c85a287c29086e2ed256a8cdb3a8b. Your announced change to keep every shared-memory program pinned was not in this build.The selective rule did not clear this GPU's known false colours in these two bounded starts. Same Kokiri Forest save and fixed camera, windowless, 1920×1080 output, 75% rendering, game's upscaler, frame generation off. Startup precompile was off. Both starts used new private application and Mesa cache directories; no existing user cache was changed.
RX_VK_PIN_ALL=1I inspected 166 and 138 gameplay stills respectively. Matched captures at presents 2700 and 5610 show the same black/neon-coloured failure, with the HUD readable. Neither run reported a crash, device loss or kernel driver fault. This was ordinary shared-machine testing: one-minute load 34.89→23.03 and 121.24→51.89. No speed comparison is implied.
The writer still waits. Both runs completed 56 ordinary/fallback build jobs, then ended with fallback program
3b8c07f2eb4bb7d9still compiling. RGB9E5 writer6637ac1d052d22d4was requested but its build never started, and no dispatch was recorded. The selective rule correctly marked that writer unpinned (shared=0, workgroup128×1×1), but it still waited behind the serial queue. The typed upscale continued running. This is consistent with the missing-producer explanation already reported in #1001; it is not a new driver-colour diagnosis.The shared-memory question: both runs observed the same 93 compute key/variant records. The selective rule chose 65 to be unpinned; all 65 had zero shared memory. All 10 observed shared-memory variants declared subgroup use and remained pinned. Thus the requested list of observed unpinned, shared-memory programs with more than 32 invocations is empty. Your announced restriction would change none of these observed decisions; that is a classification of this inventory, not a test of the coming commit.
9790303532c0c30976b54f5bb0d7ce9737d9fd3069f0e5e40fe7f6c474c57be5So I cannot supply first-build times for those four, or an all-pipelines-ready image comparison. The cold timing comparison is held for the announced rule change. Similar broken pictures while compilation is incomplete do not prove equal compute results, and this scene did not exercise the risky shared-memory class.
The per-program records and retained durations come from an identical local logging-only patch: 31 added, 1 removed source lines on both arms. It logs pin decisions, compiler entry/completion and the first writer dispatch. The replaced line computes the same
msfrom one clock read, reused for the higher-resolution log. No scheduling, shaders, pin policy, waits or barriers were changed. Logging has some overhead; durations use the measured call interval, not log arrival. I can provide the patch.Checks:
test_compute_pin.pyand all eight cache-cleanup cases pass with GCC 16.2.1 and Clang 23.1.3. On main-base source, the revised tests stop at the missing new scan function rather than demonstrating a compiled behavioral failure. The Windows SEH test cannot execute on Linux; its generated fixture passed Windows-target syntax checking after resolving the compiler-identification probe.The local Windows-target preflight also found a portability omission in the new compute-pin fixture: it calls
getenvwithout_CRT_SECURE_NO_WARNINGSbefore its includes. The existing, unchanged cache-cleanup fixture has the same opt-out omission fortmpfile/CRT calls. These are local preflight findings, not a claim about current upstream CI. No full-suite rerun or Windows execution was performed.Not tested: the coming shared-memory restriction, the four advertised compile-time gains, correctness after all pipelines finish, other scenes or GPUs, real windows, sound or long play.