[PR #2174] rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) #2176

Open
opened 2026-11-26 21:20:18 +01:00 by 4ld0 · 0 comments
Owner

📋 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)

  • 15350f6 rdna2spirv: 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_id is below
src_pops_exiting_wave_id + ~collision_id (unsigned). The translator orders the section with fragment-shader
interlock 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_u32 with field
0x000a0010), when the program reads that SGPR's entry value (shader_meta's user_sgpr_reads). It sets that SGPR
at entry to 0x00010000 (no overlap, wave id 1, collision id 0), and the loop then leaves after one round. A program
without that extract is translated as before.

  • tools/rdna2spirv.py: pops_collision_sgpr and the entry store.
  • tests/semantic/test_pops_collision_seed.py: whole subgroups of 64 and 32 lanes, with and without the seed (EXEC
    all on, a lane on in each half, all off, the low half off), plus the SGPR search.
  • GPU fixture runtime/test/shaders/ps_pops_wait_loop.asm, run by check.py and run_gpu_tests.py, with its llvm-mc
    listing for the branch encodings.
  • tests/semantic/spirv_wave_interp.py: the interlock instructions run as no-ops, since one run has no other
    primitive.
  • runtime/test/vk_harness.cpp: on a device without pixel interlock, a fragment shader that needs it is reported as
    unsupported (77), as is already done for barycentrics.
  • docs/design.md and docs/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).
  • The semantic suite (scripts/run_semantic_tests.py tests/semantic -j 4): 493 files, 6327 tests, 0 files failed.
  • tests/test_translate.py plus the related semantic files: 795 passed and 2 failed. Both failures are
    cs_dpp_cmp.asm, which llvm-mc 23.1.6 does not assemble for gfx1013 ("dpp variant of this instruction is not
    supported"). 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.
  • The repository-consistency set: the same baseline failure as on main
    (test_every_tool_the_jobs_read_triggers_the_workflow), nothing new.
  • Shaders: 100 pixel shaders of a local corpus (its 10 POPS shaders and 90 others picked at random) translate and pass
    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.
  • GPU: ps_pops_wait_loop through check.py's pixel test gives 4096 of 4096 pixels as expected. With the seed taken
    out 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

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of 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.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2174 **Author:** [@QemmHD](https://github.com/QemmHD) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `claude/pops-collision-seed` --- ### 📝 Commits (1) - [`15350f6`](https://github.com/ubiquitarianism/leonida/commit/15350f6da6281cc6af4b9698b533d925431417f8) rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) ### 📊 Changes **10 files changed** (+383 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 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_id` is below `src_pops_exiting_wave_id + ~collision_id` (unsigned). The translator orders the section with fragment-shader interlock 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_u32` with field `0x000a0010`), when the program reads that SGPR's entry value (`shader_meta`'s `user_sgpr_reads`). It sets that SGPR at entry to `0x00010000` (no overlap, wave id 1, collision id 0), and the loop then leaves after one round. A program without that extract is translated as before. - `tools/rdna2spirv.py`: `pops_collision_sgpr` and the entry store. - `tests/semantic/test_pops_collision_seed.py`: whole subgroups of 64 and 32 lanes, with and without the seed (EXEC all on, a lane on in each half, all off, the low half off), plus the SGPR search. - GPU fixture `runtime/test/shaders/ps_pops_wait_loop.asm`, run by check.py and run_gpu_tests.py, with its llvm-mc listing for the branch encodings. - `tests/semantic/spirv_wave_interp.py`: the interlock instructions run as no-ops, since one run has no other primitive. - `runtime/test/vk_harness.cpp`: on a device without pixel interlock, a fragment shader that needs it is reported as unsupported (77), as is already done for barycentrics. - `docs/design.md` and `docs/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). - The semantic suite (`scripts/run_semantic_tests.py tests/semantic -j 4`): 493 files, 6327 tests, 0 files failed. - `tests/test_translate.py` plus the related semantic files: 795 passed and 2 failed. Both failures are `cs_dpp_cmp.asm`, which llvm-mc 23.1.6 does not assemble for gfx1013 ("dpp variant of this instruction is not supported"). 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. - The repository-consistency set: the same baseline failure as on main (`test_every_tool_the_jobs_read_triggers_the_workflow`), nothing new. - Shaders: 100 pixel shaders of a local corpus (its 10 POPS shaders and 90 others picked at random) translate and pass 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. - GPU: `ps_pops_wait_loop` through check.py's pixel test gives 4096 of 4096 pixels as expected. With the seed taken out 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#2176
No description provided.