victory-shader: mask mesh primitive vertex indices to 9 bits (drop edge flags) #1717
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1718"
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?
Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-24T21:14:58Z.
Summary
Fixes mesh primitive export vertex index unpacking in
victory-shader(crates/victory-shader/src/emit/lower.rsandio.rs):0x1FF) instead of 10 bits (0x3FF) so hardware edge-flag bits (bits 9, 19, and 29) are not mixed into vertex indices.crates/victory-shader/src/io.rs.Verification (Windows 11 + SDK
dxil.dll+ WARP)crates/victory-shader/src/emit/mod.rs(zero game bytes; verified withxtaskasset-policy check):primitive_export_indices_drop_the_edge_flags: validates plain, edge-flagged (0x20280600), and culled triangles againstdxil.dll.edge_flagged_triangles_draw_as_unflagged_ones: executes on WARP (D3D12), verifying edge-flagged triangles rasterize all 256 texels identically to unflagged triangles (whereas the previous0x3FFmask rendered 0/256 texels).cargo test --workspace --locked: all crates pass, 0 failures.cargo clippy --workspace --all-targets --locked -- -D warnings: 0 warnings.Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T21:26:29Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib primitive_export_indices_drop_the_edge_flags— passedcargo test -p victory-shader --lib edge_flagged—edge_flagged_triangles_draw_as_unflagged_onespassed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean 9-bit masking of mesh primitive vertex indices to drop edge flags, verified end-to-end on hardware and WARP. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:00Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.Mesh primitive vertex indices are masked to 9 bits with the edge-flag bits (9/19/29) and cull bit (31) dropped; TRIANGLE/EDGE_FLAGS/CULL constants document the layout, with a one-wave triangle mesh test program. +1 macOS test.
Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-24T21:37:43Z.
The edge-flagged triangle matched the unflagged reference pixel for pixel on both the RTX 5080 (driver 621.24) and built-in Windows WARP. I tested PR head
c0228d9on Windows 11 build 26300.10075 and read back the 16 × 16 RGBA target after each draw.0x002004000x202806000xa0280600With all three flags set, every pixel matched the reference RGBA value
[1.0, 0.5, 0.25, 1.0]bit for bit. I also set bit 9, bit 19, and bit 29 individually. Each single-bit draw produced 0 differing pixels out of 256 on each adapter. With culling enabled, all four channels were zero across the target on both adapters.Both original mesh tests passed on the clean PR head. The Windows SDK DXIL validator also accepted the unflagged, flagged, and flagged-and-culled shader variants.
Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T22:24:51Z.
Review: APPROVED
Tested
c0228d93on Windows 11, RTX 5070, MSVC:cargo test -p victory-shader -- --test-threads=1passes on the head (122 passed, 1 ignored).clippy -D warnings(default and all features) are clean.The fix is right. In the GFX10 NGG primitive export, each vertex index is 9 bits, with its edge flag in the bit above (bits 9, 19, 29), and bit 31 marks a null primitive. The old
0x3FFmask folded the edge flag in as +512.On a full game package,
translate --validate --listgives the same result for every program (counts only compared). This changes the index values, not what validates.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T22:32:48Z.
Reviewed and verified at runtime on a host that caps its heaps
(Windows): cargo check clean, and both new tests pass — the validator
one, and the hardware/WARP draw test (edge-flagged corners drew as
unflagged, the culled export lit nothing). The 9-bit index + edge flag
layout is consistently updated in io.rs; no other 10-bit mesh mask
remains.
Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T23:06:34Z.
Setup: one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell,
10de:2d59, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP,8086:a788, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged ontomain70564ae.cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1with the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1, and a local, uncommitted change that also turns the debug layer on in victory-shader's testHost): 477 passed, 5 failed, 7 ignored. The 5 failures are the onesmain70564aehas by itself on NVIDIA (the view-heap cap and the structured-view stride, already reported in #1744); this PR adds none. No new debug-layer messages compared withmain.cargo clippy --workspace --all-targets --locked -- -D warnings, with and without--all-features: cleanedge_flagged_triangles_draw_as_unflagged_onesdraws on both devices:hardware: edge-flagged triangles drewon the RTX andwarp: edge-flagged triangles drew.primitive_export_indices_drop_the_edge_flagspasses.No game data used. AI-assisted (Claude Code).