rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) #2174
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!2174
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/pops-collision-seed"
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?
Pull request successfully merged and closed
Claimed 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
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)
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.
#2174 | head
15350f6da6281cc6af4b9698b533d925431417f8|python3 -m unittest discover -s tests/semantic -p test_pops_collision_seed.py -v,python -I scripts/run_gpu_tests.py --filter ps_pops_wait_loop --require-pass --build <harness-dir> --assembler python --work <scratch>| red: 12 tests, 9 assertion failures, 5 errors, GPU 4,096/4,096 pixels mismatched | green: 12 passed, GPU 4,096/4,096 pixels matched | Red → green, GPU confirmedThe baseline generated a module that validated but produced 4,096 mismatched pixels. The merged tree matched all 4,096 pixels. Failure and error counts include subtest events. The merged fixture also passed a separate SPIRV-Tools 2026.1 check with
spirv-val --target-env vulkan1.2.Pinned main
4938673668d807bf365b61284bf22b1ff8d02cc4, merged into the PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4 for CPU tests. Windows 11 Pro, Python 3.12.10, RTX 5070 Ti (NVIDIA 610.74) for the filtered Vulkan run. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.#2174 | head
15350f6da6281cc6af4b9698b533d925431417f8(merged cleanly ontomaind48a957bb9988afce424552a3c0c8d01ef12320f) | Windows 11 (10.0.26200), CPython3.12.10, MSVC19.44.35228(/W4 /permissive- /utf-8),spirv-val(1.4.363.1), NVIDIA GeForce RTX 3090 (Vulkan1.4.341, driver610.88,subgroup 32..32,VK_EXT_fragment_shader_interlock,LEONIDA_VK_VALIDATION=1)main(d48a957bb9988afce424552a3c0c8d01ef12320f): Assemblingps_pops_wait_loop.asmwithllvm-mc(-triple=amdgcn--amdpal -mcpu=gfx1013), translating withmain'stools/rdna2spirv.py, and running on RTX 3090 viavk_harness(VK_EXT_fragment_shader_interlockenabled) returns(0x00010000, 0x00000000, 0x3f800000, 0x3f800000)across all4096/4096pixels (65,536loop-guard rounds withEXEC = 0instead of1).PR + main:vk_harnessrebuilds cleanly (0MSVC warnings).python -m unittest discover -s tests/semantic -p "test_pops_collision_seed.py" -v:12/12tests pass (OK).python -I scripts/run_gpu_tests.py --filter ps_pops_wait_loop --require-pass(LEONIDA_VK_VALIDATION=1on RTX 3090):PASS ps_pops_wait_loop(4096/4096pixels exact(0x00000001, 0x00000000, 0x3f800000, 0x3f800000),spirv-valclean,0Khronos validation errors).scripts/check_no_game_data.py,test_docs_encoding.py, andtest_text_write_line_endings.py: pass (0CRLF).tests/semantic/test_pops_collision_seed.pyimportssupportwithout insertingos.path.dirname(os.path.abspath(__file__))intosys.pathfirst, so directpython -I tests/semantic/test_pops_collision_seed.pyraisesModuleNotFoundError: No module named 'support'(whereasunittest discover -s tests/semanticpasses).AI-assisted.
@QemmHD this PR now conflicts with
main(runtime/test/vk_harness.cpp). Could you mergemaininto your branch (no force-push needed)? It was verified before the conflict: https://github.com/ProjectLeonida/mandy/pull/2174#issuecomment-7239295605. If there's no update within 24 h, OreoFR may carry it in a new PR that keeps you as co-author (per the maintainers' plan). — OreoFR's agent (AI-assisted)Carried as #2731 because of the conflict with main after #2566; @QemmHD, if you come back, say so and the carry is dropped.