Repository navigation
Conversation
…SHADER-350) A pixel shader that reads src_pops_exiting_wave_id is ordered by fragment- shader interlock around the whole shader: OpBeginInvocationInterlockEXT at the end of the entry block, OpEndInvocationInterlockEXT before the return. The Begin was appended only on the path that lays out branch blocks, so a straight-line POPS shader got the End without a Begin, which is invalid for the interlock. The straight-line path now appends it in the same place. tests/test_pops_interlock.py: straight-line and branched POPS shaders get exactly Begin then End, after the entry label, and pass spirv-val; a shader without POPS gets neither. The straight-line case gave ['End'] before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
YaBulochka
left a comment
There was a problem hiding this comment.
Read the diff and ran the new tests on a clean worktree of 6a3778d6: python3 -m pytest -q tests/test_pops_interlock.py -> 3 passed. The fix is the right shape: the straight-line path now appends OpBeginInvocationInterlockEXT to the same prologue list (fn) that the if gen.blocks path already used, so both shapes put Begin at the end of the entry block and End before the return, and a shader without POPS still gets neither.
One small thing about the test, not the fix: the comment on the entry-block assertion says "before the first instruction that reads or writes anything the shader stores", but the assertion only compares the positions of Begin and End. On the straight-line fixture the store is the OpStore/export after the Begin anyway, so the property you describe holds; if you want the comment to be literal, assert that every OpStore / OpImageWrite / export call sits after the Begin index.
No GPU run from me: this is a translation-shape change and the new tests are CPU-side; a POPS shader on hardware would need a fixture that the suite does not have yet.
|
Tested 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 This adds a 5-line 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 AI-assisted review. |
|
Closing as a duplicate of #2017: @fearkov claimed this finding at 15:20 (#1902 (comment)), before it had an ID and before my claim, and #2017 is the same one-line change. @borislisandro ran this PR's |
Claimed on #1902: #1902 (comment)
What and why
A pixel shader that reads
src_pops_exiting_wave_id(POPS, primitive-ordered pixel shading) is translated with fragment-shader interlock around the whole shader:PixelInterlockOrderedEXT;OpBeginInvocationInterlockEXTonce, at the end of the entry block;OpEndInvocationInterlockEXTonce, before the return.The Begin was appended only inside
if gen.blocks:, the path that lays out branch blocks, while the End is added for every POPS shader. So a POPS shader without a branch got an End with no Begin, which is invalid for the interlock. 10 of the game's pixel shaders need ROVs (docs/d3d12_vulkan.md question 10).The change
In
assemble, the straight-line path now appendsOpBeginInvocationInterlockEXTat the same point: the end of the entry prologue, before the body. Oneelif pops:branch; the branched path is unchanged.Tests (
tests/test_pops_interlock.py, new)[Begin, End], Begin after the entry label and before End, withFragmentShaderPixelInterlockEXTandPixelInterlockOrderedEXT, and passspirv-val. Before the fix, the straight-line case gave['End'].tests/test_translate.py+tests/test_shader_checks.py: 560 passed, 2 skipped.Not GPU-run: AMD's Windows driver (RX 9070) doesn't expose
VK_EXT_fragment_shader_interlock. A fixture run needs a GPU withfragmentShaderPixelInterlock(NVIDIA, Intel).Disclosure: written with an AI assistant (Claude Code). I reviewed it and ran the tests above.
🤖 Generated with Claude Code