rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) #2174
Open
github-bot
wants to merge 1 commit from
github-bot/gh-2174 into main
AGit
pull from: github-bot/gh-2174
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2174
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2174"
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?
@QemmHD on GitHub · 2026-11-26 02:02 UTC · original
ubiquitarianism:claude/pops-collision-seed→main· +383 −4 · 10 files · 1 commits · openClaimed in the coordination issue as: SHADER-POPS-COLLISION-SEED
What and why
A pixel shader with an ordered section (POPS) reads the hardware's collision word from the SGPR after its user SGPRs
and the primitive mask. The word holds the collision wave id in bits 0-9, this wave's id in bits 16-25 and the
overlap flag in bit 31. The program waits until
wave_id + ~collision_idis belowsrc_pops_exiting_wave_id + ~collision_id(unsigned). The translator orders the section with fragment-shaderinterlock and reads the exiting id as 0, so it relied on that word holding no collision. The word was whatever the
push constants held at that dword, usually 0. With wave id == collision id the test becomes
0xffffffff < 0xffffffff, which is never true, so a wave that reached the wait loop ran it until the loop guard(65,536 rounds).
The overlap test before the loop skips it whenever a lane is on in EXEC. The case that spins is therefore a host
subgroup that reaches the branch with EXEC all off. On 32-wide subgroups that is either half of a wave64 program whose
lanes in that half are all off.
The translator now finds the SGPR as the source of the program's wave-id extract (
s_bfe_u32with field0x000a0010), when the program reads that SGPR's entry value (shader_meta'suser_sgpr_reads). It sets that SGPRat entry to
0x00010000(no overlap, wave id 1, collision id 0), and the loop then leaves after one round. A programwithout that extract is translated as before.
tools/rdna2spirv.py:pops_collision_sgprand the entry store.tests/semantic/test_pops_collision_seed.py: whole subgroups of 64 and 32 lanes, with and without the seed (EXECall on, a lane on in each half, all off, the low half off), plus the SGPR search.
runtime/test/shaders/ps_pops_wait_loop.asm, run by check.py and run_gpu_tests.py, with its llvm-mclisting for the branch encodings.
tests/semantic/spirv_wave_interp.py: the interlock instructions run as no-ops, since one run has no otherprimitive.
runtime/test/vk_harness.cpp: on a device without pixel interlock, a fragment shader that needs it is reported asunsupported (77), as is already done for barycentrics.
docs/design.mdanddocs/d3d12_vulkan.md: the POPS rows.Idea from Marvisak/VIctory 7ac1f54, written anew.
Tested
tests/semantic/test_pops_collision_seed.py: 12 passed (8 subtests).scripts/run_semantic_tests.py tests/semantic -j 4): 493 files, 6327 tests, 0 files failed.tests/test_translate.pyplus the related semantic files: 795 passed and 2 failed. Both failures arecs_dpp_cmp.asm, which llvm-mc 23.1.6 does not assemble for gfx1013 ("dpp variant of this instruction is notsupported"). That fixture fails at the llvm-mc step, before the translator runs, so it fails the same way without this change.
tests/semantic/regen_fixtures.py --check: clean.(
test_every_tool_the_jobs_read_triggers_the_workflow), nothing new.spirv-val before and after: 100/100 both times. The 90 others are byte-identical. The 10 POPS shaders differ only
in the entry store of the seed.
ps_pops_wait_loopthrough check.py's pixel test gives 4096 of 4096 pixels as expected. With the seed takenout of the translator, every pixel's round count is
0x00010000(the loop guard).GPUs tested: NVIDIA GeForce RTX 4070 SUPER, Windows 11 (Vulkan)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
@real-rusher on GitHub · 2026-11-26 10:20 UTC · original
Verified on main
a73a57e1(Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly. python -m unittest discover -s tests/semantic -p test_pops_collision_seed.py: 12 tests OK with this PR; the same file against main's translator: 1 failure and 16 errors, so it fails on main and passes with the change. compileall clean.Not run: the whole semantic suite and the translated / spirv-val counts over a corpus (no game data here).
AI-assisted: yes (Claude Code)
@Tauwni on GitHub · 2026-11-26 13:48 UTC · original
Tested
15350f6daon an Apple M3 (macOS 26.5.1). I ran the fullscripts/run_gpu_tests.pyin auto mode againstmaina73a57e13, with test programs built from this branch (it changesvk_harness.cpp).mainLEONIDA_W64_EMULATE=1The new
ps_pops_wait_looppasses on MoltenVK, native and emulated (4096/4096 pixels exact), so the seeded collision word ends the wait loop there. KosmicKrisp skips it, because the device has no fragment-shader interlock. No new failure. The ones left are the same on both sides:cs_fma_fused(#1724),ps_ssharp(#1774) andcs_imgatomic_ext(#1518) on MoltenVK; KosmicKrisp's(NAN)-constant fixtures (#2229) andcs_imgatomic_extthere.AI-assisted (Claude Code). No game data.
@wavehs on GitHub · 2026-11-26 19:31 UTC · original · reviewed
macOS arm64 / GPU check of #2174 (SHADER-POPS-COLLISION-SEED). A translator rule, a GPU fixture and a harness capability gate; all three run here.
Tested head
15350f6damerged ontomainbdbc7e923as mergeaf475333f(clean, no conflicts).Environment: Apple M3 Pro, arm64, macOS 27.2.1, Apple clang 21.0.0, CMake 4.5.0, CPython 3.15.2,
llvm-mc23.1.5, SPIRV-Tools v2026.4, MoltenVK 1.4.0, KosmicKrisp = Mesa 26.3.0.The fixture runs, and it needed the harness change to be a fair test
ps_pops_wait_loopon the merge with the rebuiltvk_harness, MoltenVK:PASS 4096/4096 pixels exact-x = 1round,y = 0, and the 1.0 outputs, exactly the.asmheader's derivation from the seeded0x00010000.KosmicKrisp:
SKIP (unsupported: ... uses fragment-shader interlock and the device has no fragmentShaderPixelInterlock). That is the new gate atruntime/test/vk_harness.cpp:329-341doing its job. Before I rebuilt the harness (the checked-invk_harnessin my build dir predated this PR), the same fixture on the same driver failed atvkCreateGraphicsPipelineswithVK_ERROR_INVALID_SHADER_NVafter SPIRV-Cross emittedUnknown intrinsic end_invocation_interlockin the MSL. Those are the two sides of the gate: without it, a device that does not expose the feature fails the suite instead of skipping, and the failure message blames the shader.Full suite on the merge, MoltenVK:
279 shaders: 278 translated, 278 pass spirv-val,196 / 3 / 70of 269. The three failures are main's on this driver (cs_fma_fused,cs_imgatomic_ext,ps_ssharp); the one added pass over the baseline (195 / 3 / 70of 268) is the new fixture.ps_ij_computedis still the expected refusal under the f16 fallback in this tree (#2239), and it is in the 70 skips.Semantic:
tests/semantic/test_pops_collision_seed.py12 tests OK; whole suite501 files, 6379 tests, 0 files failed(main 500 / 6367, so one file and twelve cases).NC 1 (translator reverted to main, fixture and tests kept): the new semantic file reports
FAILED (failures=9, errors=4)and the GPU run becomesFAIL ps_pops_wait_loop 4096/4096 mismatches; first at (0,0): got ['0x10000', ...], want ['0x1', ...]- the loop runs to its guard when the collision word arrives as 0.NC 2 (keep everything, set
POPS_COLLISION_SEED = 0, i.e. the old push-constant behaviour): 8 semantic failures and the same0x10000GPU mismatch. Both the seed's value and its placement are pinned.Assessment of the rule
src_pops_exiting_wave_idread as 0 and the seed's collision id 0, the loop'ss5 = wave_id + ~collision_idis 1 + 0xffffffff = 0, which is below0 + 0xffffffff, so a wave that enters the loop leaves after one round. A word with wave id == collision id (0) gives 0xffffffff < 0xffffffff, false, and the loop runs to the guard - which is exactly what NC 1/NC 2 measure, so the choice of 1 rather than 0 is load-bearing and not an accident.tools/rdna2spirv.py:16844-16850), so it wins over push constants, and it only runs when the shader also readssrc_pops_exiting_wave_id(uses_pops) and ans_bfe_u32with field0x000A0010reads an entry SGPR (pops_collision_sgpr,:379-394). Both call sites run aftershader_meta.collect(:18833,:18904), souser_sgpr_readsis populated when this is decided.Nits, not defects
s_bfe_u32 sX, sY, 0x000A0010on a register whose entry value is read. A compiler that gets the wave id withs_and/s_lshr, or that reads the collision word through a copy, is not seeded and keeps the old behaviour (loop to the guard). Over the corpus that may be empty; I cannot count it without a game copy, so the row should say which shape is recognised and that anything else still runs the loop, so a later reader does not assume the seed is universal.0x00010000over whatever the push constants held at that SGPR. The collision word is hardware-supplied on the console, so that is right, but if a title's user-SGPR count is below the translator's 16 the slot is also inside the copied user-data range: a shader that uses that dword as ordinary user data would now see0x00010000. The field match plususes_popsmakes a false positive unlikely; a comment saying so would be cheaper than rediscovering it.Not run: the full corpus (needs a game copy), native RDNA2 hardware, and the D3D12 path (
ROVsSupportedcomes from the same feature bit; that is Windows-only and unaffected by this PR).python -I scripts/check_no_game_data.pyon all ten changed files: clean.No game files. AI-assisted.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.