Skip to content

reprend #2174: rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) - #2731

Merged
MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
OreoFR:carry/pr-2174
Nov 30, 2026
Merged

MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
OreoFR:carry/pr-2174

Conversation

@OreoFR

@OreoFR OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Carries #2174 by @QemmHD, because it conflicts with main after #2566 and the reminder to merge main (#2174 (comment)) got no answer within the delay of the carry rule. If the author comes back, this carry is dropped.

Item: SHADER-POPS-COLLISION-SEED-CARRY (claimed in #2570 (comment); original item SHADER-POPS-COLLISION-SEED).

What this branch is

  • The author's branch at 15350f6da, unchanged (no rebase, author commits kept).
  • A merge of main (from the carry preparation of 29/11) that resolves the conflict, then a merge of current main f9f3ec4c6, which had a new conflict (below). Both merge commits carry Co-authored-by the author.
  • Nothing else: the change itself is the original PR's; see rdna2spirv: seed the POPS collision word so the wait loop ends (SHADER-POPS-COLLISION-SEED) #2174 for what and why, and the verifications posted there.

What conflicted and how it was resolved

  • runtime/test/vk_harness.cpp: main's two-stage has_cap scan, plus the PR's needs_interlock = has_cap(fs_code, 5378).
  • New with f9f3ec4c6: tools/rdna2spirv.py, _translate (straight-line and CFG paths): main now passes extra=meta_extra to _shader_meta.collect and reads the literal samplers right after it; the PR's g.note_pops_word(insns) follows that block, still before fit_shared_memory / needs_barrier_rounds as in the PR.

Tests

  • On this branch (main f9f3ec4c6 merged), Windows 11, Python 3.12, no GPU used: tests/semantic/test_pops_collision_seed.py: 12 OK.
  • Earlier merge: green 12 OK; GPU (RTX 4070 Laptop 8 GB) run_gpu_tests --filter ps_pops_wait_loop: PASS 4096/4096; red (main's rdna2spirv.py): 1 failure + 14 errors, GPU FAIL; full semantic suite 530 files / 6537 tests, same 2 failures as main.
  • python -I scripts/check_no_game_data.py on every file this PR changes: clean.
  • CI on this PR covers the rest (C++ build and ctest, the full translator suite).

Depends on: none.

Needs an independent verifier before merge (red/green on another machine), as for any carry.

AI-assisted (Claude Code, oreofr-agent).

🤖 Generated with Claude Code

QemmHD and others added 3 commits November 25, 2026 19:45
…R-POPS-COLLISION-SEED)

A pixel shader with an ordered section (POPS) reads the hardware's collision word, which sits in the SGPR after the
user SGPRs and the primitive mask: collision wave id in bits 0-9, this wave's id in bits 16-25, overlap 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, and the word was
whatever the push constants held at that dword, usually 0. With wave id == collision id the test is
0xffffffff < 0xffffffff, never true, so a wave that reached the 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, so it is a wave (a host subgroup) with EXEC
all off there; on 32-wide subgroups that is either half of a wave64 program whose lanes are all off.

The SGPR is now 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), and it is set at entry to 0x00010000 (no overlap, wave id 1,
collision id 0): the loop leaves after one round. A program without that extract keeps the old behaviour.

- tools/rdna2spirv.py: pops_collision_sgpr and the entry store.
- tests/semantic/test_pops_collision_seed.py: subgroups of 64 and 32 lanes, with and without the seed, and the SGPR
  search; the GPU fixture runtime/test/shaders/ps_pops_wait_loop.asm (check.py, run_gpu_tests.py) and its llvm-mc
  listing.
- tests/semantic/spirv_wave_interp.py: the interlock instructions run as no-ops (a run has no other primitive).
- runtime/test/vk_harness.cpp: a fragment shader that needs pixel interlock on a device without it is unsupported
  (77), as for barycentrics.
- docs/design.md, docs/d3d12_vulkan.md: the POPS rows.

GPU: on an RTX 4070 SUPER the fixture gives 4096 of 4096 pixels as expected; with the seed taken out every pixel's
round count is 0x00010000.

Idea from Marvisak/VIctory 7ac1f54, written anew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SR1Fv7eQNgZjM6miWPKjHf
vk_harness: main's has_cap scan of both stages, plus needs_interlock = has_cap(fs_code, 5378) from the PR.

Co-authored-by: QemmHD <290605352+QemmHD@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Current main after ProjectLeonida#2566. New conflict on top of the earlier carry merge:
tools/rdna2spirv.py, _translate (straight-line and CFG paths): main passes
extra=meta_extra to _shader_meta.collect and reads the literal samplers
after it; the PR's g.note_pops_word(insns) runs right after that block,
before fit_shared_memory / needs_barrier_rounds as before.

Co-authored-by: QemmHD <290605352+QemmHD@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16 (pytest, no GPU), main f9f3ec4c6.

  • MEASURED, red (main + only this PR's tests): tests/semantic/test_pops_collision_seed.py: 1 failed.
  • MEASURED, green (main + merge --no-ff of f474c74b0): 12 passed, 8 subtests passed.
  • READ IN CODE: tests/semantic/spirv_wave_interp.py is a helper with no tests of its own ("no tests ran" on both sides).
  • Not covered: the C++ build, ctest and the rest of the suite (CI).

Not independent: this PR and this check share the same owner (OreoFR). Treat it as a second-machine run, not an independent review.

AI-assisted: Claude Code

@KelboLive

Copy link
Copy Markdown

Independent check on Windows/NVIDIA (not the author), at f474c74b0.

  • tests/semantic/test_pops_collision_seed.py: 12 passed (python -I -m unittest discover -s tests/semantic -p test_pops_collision_seed.py).
  • Full translator suite on this branch: 550 files, 6,687 tests, 0 files failed (395 s, 32 jobs).
  • GPU: built the branch's vk_harness change and ran run_gpu_tests.py --build build --filter pops:
    ps_pops_wait_loop 4096/4096 pixels exact — 1/1 passed. The device has fragmentShaderPixelInterlock, so it ran rather than skipping.

Machine: NVIDIA RTX 4070 Ti SUPER, driver 621.01 (Windows 32.0.16.2101), Windows 11 Pro 10.0.26200.9711, MSVC 14.52.37025, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8.

No regressions seen. As with the other carries, a rebase on current main before merge would keep history linear.

AI-assisted: yes (opencode).

…vm-mc does

The carry's new fixture ps_pops_wait_loop.asm reads it (s_add_i32), and
test_parity_with_llvm_mc_on_shader_fixtures failed where llvm-mc is installed:
the decoder gave raw src_239. rdna2spirv and shader_ir already expect the special name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

ed699ed76 fixes the red linux-python-and-viewer job (found by MoonEyes): tests/test_rdna2_decode.py::test_parity_with_llvm_mc_on_shader_fixtures failed on this PR's new fixture runtime/test/shaders/ps_pops_wait_loop.asm (s_add_i32), where llvm-mc prints src_pops_exiting_wave_id and tools/rdna2_decode.py gave raw src_239. The decoder now names source operand 239 like llvm-mc; tools/rdna2spirv.py and tools/shader_ir.py already expected that name.

  • MEASURED (macOS 27.2.1, Apple M5, Python 3.12.16, llvm-mc from Homebrew LLVM): every test file that uses rdna2_decode, cpu_ref or cf_ref (19 files): before 1 failed, 356 passed, 1 skipped, after 357 passed, 1 skipped, 1834 subtests passed. test_rdna2_decode.py + test_pops_collision_seed.py + test_translate.py: 768 passed.
  • Without llvm-mc the parity test is skipped, which is why the earlier Windows and Mac runs were green.
  • Same owner as the carry: needs someone else's check.

AI-assisted: Claude Code

@MoonEyes

Copy link
Copy Markdown
Collaborator

Verified by MoonEyes (another owner than OreoFR) on head ed699ed76: Windows 11, Python 3.14, no LLVM, no GPU run.

  • tests/semantic/test_pops_collision_seed.py 12 OK on this head; red on the earlier head f474c74b0 (without rdna2spirv.py of the change: 9 failures, 4 errors). rdna2_decode.py changed since (source 239 named): the Linux CI job that compares it with llvm-mc is green on this head.
  • Corpus slice, tools/rdna2spirv.py --wave64-emulate, shards 0, 12, 24 and 36 of 48 (2,209 shaders), main 20fe0c754 against main + this pull request: 2,209 translated and 2,209 pass spirv-val in both; 1 of 2,145 SPIR-V files differs (+32 bytes).

AI-assisted (Claude Code).

@MoonEyes

Copy link
Copy Markdown
Collaborator

Merging. Head ed699ed76 merges cleanly with main ffa0f8ed4 and does not force a rebase of #2566. Counts equal on the slice, 1 file differs; red/green on Windows 11 by another owner. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 35e75b7 into ProjectLeonida:main Nov 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants