Skip to content

Translator: a POPS shader without a branch begins its interlock too - #2017

Closed
fearkov wants to merge 3 commits into
ItsNotRexed:mainfrom
fearkov:fix/pops-straight-line-interlock
Closed

fearkov wants to merge 3 commits into
ItsNotRexed:mainfrom
fearkov:fix/pops-straight-line-interlock

Conversation

@fearkov

@fearkov fearkov commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #1902 as: #1902 (comment) (@abilliontokens's finding, #1902 (comment))

What and why

A POPS pixel shader (one that reads src_pops_exiting_wave_id) runs in a fragment-shader interlock: assemble
begins it at the end of the entry block and ends it at shader exit. The begin was only emitted under
if gen.blocks:, while OpEndInvocationInterlockEXT goes into the tail of every POPS module. So a straight-line
POPS shader ended an interlock it never began, which SPV_EXT_fragment_shader_interlock doesn't allow (each exactly
once, begin first). spirv-val accepts it anyway. The begin is now emitted in the straight-line path too, at the
same place, so every POPS module has one of each.

As @abilliontokens counted, the corpus isn't affected: all 10 POPS shaders have the wait loop, so they have blocks.

Commits:

  1. assemble in tools/rdna2spirv.py
  2. test_pops_interlock_begins_and_ends_once in tests/test_translate.py, with and without a branch: one begin, one
    end, begin first, PixelInterlockOrderedEXT, valid SPIR-V
  3. the POPS row of docs/design.md

Tested

Linux, llvm-mc 23.1.5, SPIRV-Tools from the Vulkan SDK 1.4.363, rebased on 4eb6155.

Check this branch
python -m pytest tests/test_translate.py 500 passed, 2 skipped
python -m unittest discover -s tests/semantic OK
python -m pytest tests --ignore=tests/semantic 4237 passed, 98 skipped, 5 failed: test_cf_ref.py (2) and test_world_names.py (3), the same on main (#1852, #1848)

With main's tools/rdna2spirv.py the new test fails in the straight-line case (assert 0 == 1 on the begin count)
and passes with a branch. No GPU run: no GPU fixture uses POPS, so the GPU suites translate the same modules.

The runs above are from my own machine.

Checklist

  • 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.

OpBeginInvocationInterlockEXT was only emitted when the program had blocks, while every POPS module ends the interlock, so a straight-line one ended a section it never began. Found by abilliontokens.
@borislisandro

borislisandro commented Nov 22, 2026 •

Copy link
Copy Markdown

Tested 946061dd (CPU only): pass. pytest tests/test_translate.py -k pops: 2 passed.

Cross-check of the three PRs for SHADER-350 (#2012, #2017, #2020), all CPU, Linux x86_64, Python 3.x: each change makes a straight-line POPS shader begin its interlock at the end of the entry block, and the three translator changes are equivalent for it. I ran #2020's test_pops_interlock.py (3 cases: Begin/End order and spirv-val) against the translator of #2012 and of #2017 and both pass. #2017's parametrised test_pops_interlock_begins_and_ends_once (straight-line and branching, one Begin and one End, Begin first, spirv-val) passes on its own branch. Only one of the three needs to merge.

This is the narrowest change (4 lines, only for pops and not gen.blocks) and has the strongest test of the three, plus a design.md update to the POPS row. If one is merged, I'd pick this one or #2020.

Differential check: I translated three hand-written shaders (a straight-line POPS shader, a POPS shader with a branch, a non-POPS shader with a branch) on main and on the branches of #2012, #2017 and #2020 and compared the full SPIR-V text. The branching POPS and the non-POPS output is byte-identical to main on all three; the straight-line POPS output differs from main and is byte-identical across the three PRs. So they are interchangeable for these shapes.

AI-assisted review.

@AvantBras

Copy link
Copy Markdown
Contributor

Independent GPU smoke check of 946061dd16c44c4ec8c5d0140aa5640818c83718 on RTX 3060 12 GB, NVIDIA 580.178.04, Pop!_OS 22.04. Translated the straight-line and branched synthetic POPS cases from #2020 using this PR’s translator. Both emitted exactly one Begin and one End, passed spirv-val, and rendered 4,096/4,096 expected RGBA pixels each through the Linux vk_harness built at #2048’s head with the UBO tail off. The harness reported VK_EXT_fragment_shader_interlock enabled.

Negative control: the same straight-line input at 4eb6155d emitted only End; the branched control already had both. I did not dispatch the broken base module. This checks module creation and drawing, not ordering under contended resource writes. No game files. AI-assisted verification.

@ItsNotRexed

Copy link
Copy Markdown
Owner

Closing as a duplicate: the POPS interlock fix landed on main via #2012. Thanks!

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