Shaders: mask mesh primitive vertex indices to 9 bits (port of upstream VIctory #1718) #919
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!919
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-919"
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?
@Moon0755 on GitHub · 2026-11-25 12:54 UTC · original
Moon0755:fix/mesh-prim-edge-flags→main· +188 −7 · 3 files · 1 commits · openPorts upstream Marvisak/VIctory#1718 (
tjthebigbearcat-hub).What changed
crates/victory-shader/src/emit/lower.rs(Lower::emit_indices): Mask each corner vertex index inexp primto 9 bits (0x1FF) instead of 10 bits (0x3FF).crates/victory-shader/src/io.rs: Update theexp primbit-layout documentation.crates/victory-shader/src/emit/mod.rs: Add unit and D3D12 mesh draw tests (primitive_export_indices_drop_the_edge_flagsandedge_flagged_triangles_draw_as_unflagged_ones).Why (RDNA2 / Xbox Series X NGG hardware layout)
In RDNA2 NGG mesh primitive exports (
exp prim), each 10-bit corner field packs a 9-bit vertex index in bits[8:0]and a hardware edge flag in bit9(bits9,19, and29of the exported dword), while bit31marks the primitive as culled. Edge flags are only consumed by the console's edge-flag rasterization and are not part of the vertex index.Impact
With a 10-bit (
0x3FF) mask, any triangle with a hardware edge flag set unpacked asindex + 512. Becauseemit_indicesin this fork also culls primitives whose vertex indices are>= written(min(max_vertices, threads)), any edge-flagged triangle was guaranteed to be silently culled instead of rendered. Masking to 9 bits drops the edge flags cleanly while preserving bit-31 culling and bounds checking.Verification
Verified on
windows-latestvia GitHub Actions run #45617588678 (scoped to-p victory-shader -p xtask, as workspace-wide clippy onmaincurrently fails on unrelated pre-existing items invictory-gpu):cargo clippy -p victory-shader -p xtask --all-targets --locked -- -D warnings: passedcargo clippy -p victory-shader -p xtask --all-targets --all-features --locked -- -D warnings: passedcargo test -p victory-shader -p xtask --locked -- --nocapture:victory-shader: 217 passed, 0 failed (3 ignored), includingdxil.dllvalidation andwarp: edge-flagged triangles drewxtask: 4 passed, 0 failed (repository_passes_policyok)— Neon
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.