mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #2174] rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) #2176
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2176
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2174
Author: @QemmHD
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:claude/pops-collision-seed📝 Commits (1)
15350f6rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED)📊 Changes
10 files changed (+383 additions, -4 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+1 -1)📝
docs/design.md(+1 -1)📝
runtime/test/shaders/check.py(+2 -0)➕
runtime/test/shaders/ps_pops_wait_loop.asm(+61 -0)📝
runtime/test/vk_harness.cpp(+16 -1)📝
scripts/run_gpu_tests.py(+1 -0)➕
tests/semantic/fixtures/disasm/ps_pops_wait_loop.s(+47 -0)📝
tests/semantic/spirv_wave_interp.py(+7 -0)➕
tests/semantic/test_pops_collision_seed.py(+200 -0)📝
tools/rdna2spirv.py(+47 -1)📄 Description
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.