Repository navigation
spirv_gs_to_compute: reject OpEmitVertex in a loop header before OpLoopMerge (SHADER-617) - #3319
Conversation
b9a76cd to
bff06ea
Compare
|
Tested bff06ea on Windows, CPython 3.14.7, CPU only (no GPU, no game files): pass for the part that needs no SPIRV-Tools or llvm-mc.
Not checked here: assembly and |
|
Ran this on
With the tool from One shape the split doesn't handle: an The input passes spirv-val. After rdna2spirv's loop headers hold only AI-assisted (Claude Code). |
|
Thanks @JRamos1993 for catching that structured-CFG edge case! Rebased onto main (aa2988c) and updated in b4b0f6a: rewrite() now tracks blocks split by OpEmitVertex and raises Unsupported when OpLoopMerge appears later in the same split block, with a regression test (test_emit_vertex_in_loop_header_before_loop_merge_rejected) in tests/test_spirv_gs_to_compute_bounds.py (7/7 OK). AI-assisted, CPU only, no game files. |
bff06ea to
b4b0f6a
Compare
# Conflicts: # docs/design.md
|
Verified on Linux — the OpEmitVertex bounds guard from this PR is already on main as of bff06ea (landed via merge 8dd81f9, with tests/test_spirv_gs_to_compute_bounds.py and the design.md row; both verified present). The current branch head is a post-merge rewrite that no longer merges cleanly with main (conflicts in the tool, the bounds test and design.md — re-confirmed), and its one genuine addition beyond the merged commit — rejecting OpEmitVertex in a loop header before OpLoopMerge — would apply better as a small follow-up on current main, where the tool has no OpLoopMerge handling. Suggest closing as superseded. Heads-up: #4149 touches the same tool. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
b4b0f6a to
19c3e12
Compare
…opMerge (SHADER-617) The OpSelectionMerge split moves OpLoopMerge into the merge block while the back-edge still targets the original header label, which breaks structured control flow. Reject it as Unsupported; adds a test and extends the design.md row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Tested |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tools/spirv_gs_to_compute.py now tracks blocks whose OpEmitVertex was split and rejects, with Unsupported, a loop header where OpLoopMerge would have to move into the split merge block while back-edges still target the original header. This avoids emitting a module that violates SPIR-V structured-control-flow rules. A regression test covers the loop-header-before-OpLoopMerge case, and design docs record the new refusal (SHADER-617).
Why merge
The compute fallback previously produced invalid SPIR-V for that control-flow shape, which downstream tools could reject or miscompile. Refusing explicitly keeps the translator honest and gives the test suite a clear, covered boundary instead of silent corruption.
Verdict: Approve
|
Summary
Why merge The compute fallback previously produced invalid SPIR-V for that control-flow shape, which downstream tools could reject or miscompile. Refusing explicitly keeps the translator honest and gives the test suite a clear, covered boundary instead of silent corruption. Verdict: Approve |
The
OpEmitVertexn < OutputVerticesguard itself landed on main earlier via bff06ea / 8dd81f9. This PR is now rebased to only the remaining piece: anOpEmitVertexin a loop header before itsOpLoopMergemakes theOpSelectionMergesplit moveOpLoopMergeinto the merge block while the back-edge still targets the original header, which breaks SPIR-V structured control flow, sorewrite()raisesUnsupportedinstead.Adds
test_emit_vertex_in_loop_header_before_loop_merge_rejectedand extends the SHADER-617 row indocs/design.md.Tested on CPU only (no GPU):
python -m compileall -q make_game.py tools tests,python -I tests/test_spirv_gs_to_compute_bounds.py(7 OK),check_no_game_data.AI-assisted.
🤖 Generated with Claude Code