Shaders: emit mesh primitive indices once per lane #2245
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!2245
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2245/head"
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?
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 08:39 UTC · original
andrewpozdnakov7-jpg:fix/emit-mesh-primitive-indices-once→main· +83 −47 · 3 files · 1 commits · closed without mergingChange
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.
@MamaLeVrai on GitHub · 2026-11-25 09:13 UTC · original
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.
@Mericas77 on GitHub · 2026-11-25 10:13 UTC · original
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.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 10:31 UTC · original
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.
@sinan-cmyk on GitHub · 2026-11-25 10:38 UTC · original
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).
@Marvisak on GitHub · 2026-11-25 13:30 UTC · original
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
@Marvisak on GitHub · 2026-11-25 22:07 UTC · original
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