Shaders: emit mesh primitive indices once per lane #2243
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2245"
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 andrewpozdnakov7-jpg on 2026-11-25T08:39:05Z.
Change
The mesh lowerer stages the lane's latest packed primitive export and writes the final indices at exit. A lane with no export still emits a degenerate primitive. Edge flags and the guest cull bit retain their existing meanings.
On WARP, the translated test triangle disappeared when its default indices and real indices were both emitted. A native HLSL shader on the same pipeline drew all 256 pixels. Removing the preliminary default write in isolation also restored the translated triangle. The mesh specification assigns the last write when an output element is written more than once. DirectX Mesh Shader specification
Verification
Same extended test on
940d32f69b22265690a0b5a15d6ded572ba33baf, with WARP forced. Before, the first ordinary triangle lit 0/256 pixels. After, all six cases passed. Visible triangles lit 256/256, while culling and absent exports lit zero. Both orders of repeated exports produced the result from the last export.The full shader suite went from 244 passed / 3 failed / 3 ignored to 245 passed / 2 failed / 3 ignored. Both runs also hit the existing forced-WARP gather-reference and variable lane-shuffle failures discussed in #2225. Strict shader Clippy and the staged asset policy passed.
If you reuse the patch or regression, please preserve its Git author. If you fold it into your own commit, please add:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:42:25Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib mesh— 5 passed, 0 failed on both RTX 5090 hardware andVICTORY_D3D12_WARP=1cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean deferred emission of mesh primitive indices once per lane via
save_mesh_primitive/finish_mesh_primitive. Looks good.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:48:17Z.
Review: APPROVED
Mesh primitive indices emitted once per lane. Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 144 passed, 0 failed, 2 ignored. Approving.Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-25T09:13:26Z.
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head
2e26c46aintomain940d32fin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warnings: clean; the same with--all-features: clean.cargo test --workspace --locked: 701 passed, 0 failed, 10 ignored, two runs (mainalone on the same machine: 701 passed, 0 failed, 10 ignored). The title was not run, so this says nothing about in-game effect. No game data.AI-assisted (Claude Code); no game data.
Imported from Marvisak/VIctory. Originally posted by Mericas77 on 2026-11-25T10:13:29Z.
NVIDIA hardware test report: RTX 4070, driver 621.01, Windows 11, Rust 1.98.1 MSVC. I ran head
2e26c46againstmain940d32f; the head branches from940d32fand only changesbitcode.rs,lower.rsandmod.rsunderemit/.edge_flagged_triangles_draw_as_unflagged_onespasses all 6 cases, printinghardware: edge-flagged triangles drewandwarp: edge-flagged triangles drew. The newallocalocal passes the validator, and the pipeline is created on NVIDIA.mod.rstests on top ofmain's production code. They also pass all 6 cases on this card, both on the hardware pass and on the WARP pass. So I couldn't reproduce the "first ordinary triangle lit 0/256 pixels" failure here. My guess is that the WARP build or adapter differs from yours, or the repeated-export cases need the forced-WARP setup you describe. Either way, the regression test doesn't tellmainand this PR apart on this machine.cargo test -p victory-shader --lib --lockedgives 244 passed, 3 failed. The 3 failures matchmainon this card:stride_tests×2 andgathers_at_a_level_match_the_hardware.So there's no regression on NVIDIA. Writing the indices once at exit is consistent with the mesh spec's last-write rule either way.
AI-assisted. Synthetic tests only, no game data.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T10:31:48Z.
Thanks for running the same fixture on the RTX 4070. I replayed the paired executables here with
VICTORY_WARP=1, app-local WARP1.0.22.0.20261027.1and Agility core1.620.2.0.20261106.5. That flag also forces WARP for the arm that printshardware.940d32fproduction code again reported 0 of 256 texels lit on the first triangle and exited 101.2e26c46, the same fixture ran all six cases successfully and exited 0. A minimal native DXC mesh shader also lit all 256 texels on the app-local runtime.10.0.19041.5794). Both explicitly skipped for lack of mesh shader support, so that control couldn't isolate a WARP version difference.The fixture distinguishes the two trees on this app-local WARP setup. Your matched A/B establishes that it can also pass on both trees on another setup. Thanks for checking compatibility with the real NVIDIA driver.
If the code or fixture is folded into another commit, please preserve the Git author or include:
Co-authored-by: andrewpozdnakov7-jpg [email protected]
AI-assisted. Synthetic tests only.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T10:38:40Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
2e26c46aontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:30:51Z.
Automated triage for the maintainers.
Merge candidate (worth a look). Instead of a default culled
emitIndicesinmesh_prologuefollowed by a second one perexp prim,emit/lower.rsnow stores the lane's last packed primitive in an entry-blockalloca(newModule::local_i32inbitcode.rs, which passes the validator per the NVIDIA report) and emits once at lane exit, in both theTerm::Retpath and the abort block (the only two returns). This removes the double write the DirectX mesh shader spec leaves to the last one, and the cull bit and edge-flag decoding are unchanged. CIcheckpasses. The failure it fixes was reproduced only on an app-local WARP build (the RTX 4070 A/B passes onmaintoo), so the main gain is spec conformance.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:07:38Z.
Automated triage for the maintainers, second look (a review against current
main, with builds and tests where they could change the verdict).Closing because
mainalready behaves as the mesh shader specification requires (the last value written to an output element is the one used), and the failure was seen only with one app-local WARP build. Withmain'slower.rsandbitcode.rs, the extendededge_flagged_triangles_draw_as_unflagged_onespasses all six cases on an RX 6700 XT and on the system WARP. The change rewrites the primitive path of every mesh program and adds a private alloca to each. The extra test cases (no export, repeated exports) pass onmainand would be welcome by themselves.If this is mistaken, reply here with what was missed and it will be looked at again. Thank you for the contribution.
Pull request closed