Shaders: emit mesh primitive indices once per lane #2245

Closed
github-bot wants to merge 1 commit from gh-pr/2245/head into gh-pr/2245/base
Owner

@⁠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 merging

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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 08:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245) `andrewpozdnakov7-jpg:fix/emit-mesh-primitive-indices-once` → `main` · +83 −47 · 3 files · 1 commits · closed without merging ## 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](https://microsoft.github.io/DirectX-Specs/d3d/MeshShader.html#shared-output-arrays) ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:59:47 +00:00
github-bot closed this pull request 2026-11-26 04:59:47 +00:00
Author
Owner

@⁠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 2e26c46a into main 940d32f in 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 (main alone 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.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 09:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7158040656) 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 `2e26c46a` into `main` `940d32f` in 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 (`main` alone 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.
Author
Owner

@⁠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 2e26c46 against main 940d32f; the head branches from 940d32f and only changes bitcode.rs, lower.rs and mod.rs under emit/.

  • This PR: edge_flagged_triangles_draw_as_unflagged_ones passes all 6 cases, printing hardware: edge-flagged triangles drew and warp: edge-flagged triangles drew. The new alloca local passes the validator, and the pipeline is created on NVIDIA.
  • A/B: I ran the PR's mod.rs tests on top of main'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 tell main and this PR apart on this machine.
  • cargo test -p victory-shader --lib --locked gives 244 passed, 3 failed. The 3 failures match main on this card: stride_tests ×2 and gathers_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.

**@⁠Mericas77** on GitHub · 2026-11-25 10:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7159401792) NVIDIA hardware test report: RTX 4070, driver 621.01, Windows 11, Rust 1.98.1 MSVC. I ran head `2e26c46` against `main` `940d32f`; the head branches from `940d32f` and only changes `bitcode.rs`, `lower.rs` and `mod.rs` under `emit/`. - **This PR:** `edge_flagged_triangles_draw_as_unflagged_ones` passes all 6 cases, printing `hardware: edge-flagged triangles drew` and `warp: edge-flagged triangles drew`. The new `alloca` local passes the validator, and the pipeline is created on NVIDIA. - **A/B:** I ran the PR's `mod.rs` tests on top of `main`'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 tell `main` and this PR apart on this machine. - `cargo test -p victory-shader --lib --locked` gives 244 passed, 3 failed. The 3 failures match `main` on this card: `stride_tests` ×2 and `gathers_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.
Author
Owner

@⁠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 WARP 1.0.22.0.20261027.1 and Agility core 1.620.2.0.20261106.5. That flag also forces WARP for the arm that prints hardware.

  • The PR fixture with 940d32f production code again reported 0 of 256 texels lit on the first triangle and exited 101.
  • On 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.
  • As a control, I ran both executables with the same Agility core and just the system WARP (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.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-25 10:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7159821036) Thanks for running the same fixture on the RTX 4070. I replayed the paired executables here with `VICTORY_WARP=1`, app-local WARP `1.0.22.0.20261027.1` and Agility core `1.620.2.0.20261106.5`. That flag also forces WARP for the arm that prints `hardware`. - The PR fixture with `940d32f` production code again reported **0 of 256 texels lit** on the first triangle and exited 101. - On `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. - As a control, I ran both executables with the same Agility core and just the system WARP (`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.
Author
Owner

@⁠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 2e26c46a onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 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).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 10:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7159977444) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 2e26c46a onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 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).
Author
Owner

@⁠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 emitIndices in mesh_prologue followed by a second one per exp prim, emit/lower.rs now stores the lane's last packed primitive in an entry-block alloca (new Module::local_i32 in bitcode.rs, which passes the validator per the NVIDIA report) and emits once at lane exit, in both the Term::Ret path 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. CI check passes. The failure it fixes was reproduced only on an app-local WARP build (the RTX 4070 A/B passes on main too), so the main gain is spec conformance.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7163885502) <!-- victory-triage v1 head=2e26c46a63806ead6ba830a415bb992ef45c985f verdict=merge-candidate at=2026-11-25T13:43:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** Instead of a default culled `emitIndices` in `mesh_prologue` followed by a second one per `exp prim`, `emit/lower.rs` now stores the lane's last packed primitive in an entry-block `alloca` (new `Module::local_i32` in `bitcode.rs`, which passes the validator per the NVIDIA report) and emits once at lane exit, in both the `Term::Ret` path 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. CI `check` passes. The failure it fixes was reproduced only on an app-local WARP build (the RTX 4070 A/B passes on `main` too), so the main gain is spec conformance. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠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 main already 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. With main's lower.rs and bitcode.rs, the extended edge_flagged_triangles_draw_as_unflagged_ones passes 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 on main and 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.

**@⁠Marvisak** on GitHub · 2026-11-25 22:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2245#issuecomment-7175969683) Automated triage for the maintainers, second look (a review against current `main`, with builds and tests where they could change the verdict). Closing because `main` already 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. With `main`'s `lower.rs` and `bitcode.rs`, the extended `edge_flagged_triangles_draw_as_unflagged_ones` passes 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 on `main` and 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

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2245
No description provided.