Skip to content

Shaders: mesh lane permutations within runs of 8 and 16 lanes - #2255

Closed
Mericas77 wants to merge 1 commit into
Marvisak:mainfrom
Mericas77:feat/mesh-lane-runs
Closed

Mericas77 wants to merge 1 commit into
Marvisak:mainfrom
Mericas77:feat/mesh-lane-runs

Conversation

@Mericas77

Copy link
Copy Markdown

Mesh programs using DPP8, DPP16 row patterns or ds_swizzle_b32 bit-mask swizzles beyond quads currently stop with a cross-lane operation in a mesh shader (seen in #293, #769, #778).

Change

  • lane_block gives the aligned run a permutation reads within: quad (4), DPP8 and row_half_mirror (8), row shifts / row_ror / row_mirror / row_share / row_xmask (16), bit-mask swizzles by the bits they touch.
  • Mesh programs with such permutations number their threads by host lane (waveReadLaneFirst of the flat id rounded down to WaveGetLaneCount, plus the lane index), the same bijection thread_id uses for compute's console lanes. A run of console lanes is then a run of host lanes, and each lane reads its source with waveReadLaneAt inside its run.
  • Runs of up to 16 lanes are accepted (MESH_BLOCK); wider ones are still refused, since the translation does not know the host's wave size and the shader cache does not key on it. Mesh programs without such permutations are unchanged.

Tests

  • mesh_permutes_in_runs_of_16_lanes_translate: six permutations (DPP8 reversed, row_mirror, row_half_mirror, row_xmask:9, row_ror:3, swizzle SWAP 8) translate and pass dxil.dll; SWAP 16 is still refused.
  • mesh_permutes_read_the_console_lanes: a 64-thread mesh draw where each lane culls its triangle when it read the expected lane; nothing must be lit, and a control comparing with the lane's own index must light all 256 texels. Skipped on devices with waves under 16 lanes.

RTX 4070 (driver 621.01, Windows 11), on 940d32f:

  • hardware: mesh permutes read the console lanes (waves of 32-32 lanes); WARP skipped (waves of 4 lanes).
  • cargo test -p victory-shader --locked: 246 passed, 3 failed, vs 244 passed, 3 failed on 940d32f. The same 3 known NVIDIA failures on both (two stride_tests, gathers_at_a_level); +2 are the new tests.

AI-assisted.

DPP8, DPP16 row patterns and ds_swizzle_b32 bit-mask swizzles that stay
within aligned runs of up to 16 lanes no longer stop mesh programs with
"a cross-lane operation in a mesh shader". Mesh threads that use them
are numbered by their host lane (as compute's console lanes are), so a
run of console lanes is a run of host lanes on any host wave of 16 lanes
or more, and each lane reads its source through waveReadLaneAt.

AI-assisted.
@Dathinel

Copy link
Copy Markdown
Contributor

Tested this head (72b8fa5) together with #2245 (2e26c46), from 940d32f. They conflict in the mesh emitter and test builders. Keeping both emitter fields and initializers, plus the two builders as separate helpers, let both sets of tests run.

For the interaction test I extended permute_mesh: first export an always-culled triangle, then export the lane-selected triangle with all three edge flags set. On wave32 hardware the expected permutation lit 0/256 pixels and the own-lane control lit 256/256. WARP drew the standalone edge-flag test but skipped the permutation test (4-lane waves; 16 required).

Full combined victory-shader --lib run: 246 passed, 3 ignored, 3 failed. I reran those three failures (two heap-buffer stride cases and the gather-at-level case) on 940d32f; all three also failed there. AI-assisted, synthetic fixtures only.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with dxil.dll validator):

  • cargo test -p victory-shader --lib mesh — 7 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean lowering of mesh lane permutations within 8- and 16-lane runs, verified end-to-end on hardware and WARP. Looks great.

AI-assisted (Gemini 4 Neon).

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally: merged into main 940d32f, cargo test -p victory-shader --locked on macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — mesh lane permutations within runs of 8/16, +1 test.

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 72b8fa5 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).

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work. The change lets mesh programs use DPP8/DPP16 row patterns and bit-mask ds_swizzle_b32 within runs of up to 16 lanes (lane_block, Lower::mesh_block, Lower::mesh_read) by renumbering mesh threads by host lane in Lower::mesh_thread. The DPP control ranges in lane_block match the RDNA 2 encodings, the hardware test checks the lanes read, CI check passes and it merges cleanly. The problem is value: a tester's offline run over the title's shader corpus found the same 23,918 validated programs as main and no program changing its failure reason, so none of the mesh programs that stop at a cross-lane operation in a mesh shader today is unlocked; the patterns they use are evidently outside these runs. What would change the verdict: show which refused mesh programs this translates (count of that failure reason before/after), or extend it to the patterns they actually use. The relabelling also assumes each host wave holds an aligned run of flat thread ids, which is worth a sentence of evidence.


Generated by Claude Code

@Mericas77

Copy link
Copy Markdown
Author

Thanks for the triage, that's a fair call. I don't have a shader corpus to produce the before/after refusal counts, and from what I could see the game's mesh programs are wave64 and use cross-lane patterns outside these ≤16-lane runs, so this change wouldn't unlock any of them as-is. Extending it to the patterns actually used isn't something I can validate without the corpus, so I'm closing this rather than leaving it open. Happy to pick it back up if someone with the corpus finds a case it helps.

@Mericas77 Mericas77 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants