Repository navigation
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
Fixes SHADER-617 (finding by @Vonsek; claimed in #3232 comment).
Problem
In
tools/spirv_gs_to_compute.py:270-294,rewrite()emittedOpEmitVertexstores to%gsc_recand%gsc_metaand incremented%gsc_nwithout checkingn < max_verts(OutputVertices). A geometry shader emitting more thanOutputVerticesvertices overflowed primitivep's slots and corrupted primitivep + 1's vertex records andmetacount slot (and leftOpEndPrimitive/OpReturnusing the unclamped%gsc_n).Changes
tools/spirv_gs_to_compute.py(rewrite):OpEmitVertex's record/meta SSBO stores and%gsc_nincrement behindOpULessThan %bool %n %gsc_k<mv>(OpSelectionMerge+OpBranchConditional). Extra vertices pastOutputVerticesare cleanly dropped, preserving the invariant0 <= %gsc_n <= OutputVerticessoOpEndPrimitiveandOpReturnalso stay strictly within primitivep'smetaslice (includingOutputVertices == 0and repeatedOpEndPrimitivecalls after dropped emits).block_tail) and rewriteOpPhipredecessor labels in a post-pass overmainso both forwardif/elsemerges and backward loop-header back-edges stay valid SPIR-V wheneverOpEmitVertex(or the entry primitive-count check) splits a block.tests/test_spirv_gs_to_compute_bounds.py: Stdlib-onlyunittestsuite (runs under bothpython -Iandpytest) executing the lowered compute SPIR-V across multi-primitive buffers with sentinel guards:OutputVertices 3, 5 emits) leaves primitivep + 1'srecandmetauntouched and clampsp's count to3.OpEndPrimitiveafter dropped emits stays within primitivep's slice.OutputVertices 0drops all emits and writes count0.2 < 4) preserves exact count and per-strip flags.OpPhiacross split%entryand%thenblocks + backward loop-headerOpPhiacross a split%latchblock (5 loop iterations clamped toOutputVertices 3).tools/spirv_asm.py(and runsspirv-as+spirv-valwhen available on PATH).docs/design.md: Updated theGeometry shadersrow with theOutputVerticesemit-bound guard and test reference.Verification (CPU, Windows 11, Python 3.14; no game files, no GPU needed)
python -I tests/test_spirv_gs_to_compute_bounds.py -v: 6/6 OK (includingtools/spirv_asm.pyassembly)PHI_GSOpPhiparity check (%x = OpPhi %uint %u1 %t %u0 %gsc_body): OKpython -I tests/test_docs_links.py: 5/5 OKpython -I tests/test_docs_repo_paths.py: 2/2 OKpython -m compileall -q make_game.py tools tests: OKAI-assisted.