Shaders: a mesh primitive naming a vertex no lane writes is culled #2928
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2928
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2928"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@0xkn0wh3r3 on GitHub · 2026-11-26 00:18 UTC · original
0xkn0wh3r3:shader/mesh-primitives-of-unwritten-vertices-are-culled→main· +30 −11 · 2 files · 1 commits · openWhat
A mesh program's primitive export names three vertices (9-bit indices), and on main only the culling bit (bit 31) culled a primitive. A corner can also name a vertex that no lane writes:
That vertex's outputs are undefined, and the host drew a stray triangle from whatever they held. On the RTX 5070 Ti, triangle (0, 1, 40) from a 32-lane program declaring 64 vertices lit texels.
Such a primitive is now culled, the same way as one with the culling bit. The 9-bit indices and edge flags are unchanged.
Where it came from
From DexNom's fork, DexNom/VIctory@570a941 (
emit_indicesculls indices at or pastmin(max_vertices, threads)). Credited withCo-authored-by: DexNom.Open #587 culls only at or past
max_vertices, and it masks indices with0x3FF, which would also cull edge-flagged primitives. That's why this is a separate small PR, not a comment on #587.Tested
emit::tests::edge_flagged_triangles_draw_as_unflagged_onesnow also draws:This ran on the hardware adapter and WARP. Before the change, the (0, 1, 40) case lit texels on hardware.
cargo test -p victory-shader(withVICTORY_DXIL=dxil.dll1.6): 298 passed. The same four tests fail on main on this machine:heap_direct_texture_reads_mark_their_heap_index(skipped, crashes), twostride_testsandgathers_at_a_level_match_the_hardware.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.Not tested
@cloph-dsp on GitHub · 2026-11-26 00:33 UTC · original
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no clippy/rustup.
cargo test --locked -p victory-shader --lib -- emit::tests::edge_flagged_triangles_draw_as_unflagged_ones --exact --quiet-> 1 passed, 0 failed, 304 filtered out (CARGO_BUILD_JOBS=2).842b0cb: 3 files, +34/-14.git diff --checkflags trailing whitespace in README.md:17 (displayed.) — worth fixing.edge_flagged_triangles_draw_as_unflagged_onesalready exists on the base, so the new risk is the added(0,1,40)/64and(0,1,33)/32cases; the extended test passes here.AI-assisted (Hy4 flash).
@Marvisak on GitHub · 2026-11-26 04:24 UTC · original
Automated triage for the maintainers.
Needs work.
emit_indicesinemit/lower.rsnow culls a mesh primitive when any corner index is at or pastmin(max_vertices, threads); the code reads correctly and keeps the 9-bit masking. But a corner naming an unwritten vertex is undefined on the console too, the only evidence is the synthetic host-GPU test, and the title was not run, so it is unknown whether any title mesh program exports such primitives; culling them changes emulation behaviour. It also covers only part of the case, sincemesh_prologuedeclares the maximum counts rather than the real allocation. Please show a title draw where this produces a stray triangle, or a hardware or ISA reference for what GFX10 does with such indices.CI: passing.
Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-26 07:21 UTC · original
There's no public hardware reference for this case. The RDNA2 ISA guide covers primitive-shader exports only as far as the allocation request: §11.3 (p.100), and §12.5.1 (p.129) for GS_ALLOC_REQ's vertex and primitive counts in M0. It doesn't give the primitive export's index layout, or what the hardware does with an index past the allocated vertices. I also can't show a title draw here, so on the console side it stays unknown.
What is defined is the host side. The D3D12 mesh shader spec makes a primitive whose vertices weren't all written undefined behaviour. That's what the PR's test shows on an RTX 5070 Ti: triangle (0, 1, 40) from a 32-lane program declaring 64 vertices drew texels from whatever vertex 40 held. Whatever the console does with such an index, that vertex has no written outputs there either. So the cull replaces undefined host output with nothing drawn; it doesn't replace a defined console result.
Agreed that it covers only part of the case:
mesh_prologuedeclares the maximum counts, so a corner belowmax_verticesbut past the program's own GS_ALLOC_REQ vertex count isn't culled. Covering that would mean culling at the allocated count. It's your call whether the cull belongs in the tree without a console reference. If not, I'll close this.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.