victory-shader: support line-topology mesh shaders #1711

Open
tjthebigbearcat-hub wants to merge 1 commit from upstream-pr/1712 into main
tjthebigbearcat-hub commented 2026-11-24 21:05:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-24T21:05:22Z.


Summary

Adds support for line-output mesh shaders (topology = 1) alongside triangles (topology = 2) in victory-shader:

  • Updates emit/lower.rs with emit_primitive to unpack two vertex indices (bits 0 and 10) for lines—leaving the third DXIL emitIndices index undef—while preserving primitive culling (bit 31 and unexported primitives).
  • Keeps unsupported topologies (0, 3, etc.) cleanly refused with clearer diagnostic messages.
  • Updates emit/mod.rs module docs to reflect line and triangle mesh shader support.

Verification (Windows 11 + SDK dxil.dll 10.0.26100 + WARP)

  • Added hand-encoded synthetic GFX10 mesh shader tests in emit/mod.rs (zero game bytes; verified with xtask asset-policy check):
    • mesh_programs_draw_lines_or_triangles: validates line and triangle programs (normal and culled) against dxil.dll 10.0.26100 and verifies PSV0 topology output, while confirming topologies 0 and 3 are refused.
    • mesh_lines_light_one_texel_row: executes a line mesh pipeline on WARP (D3D12), verifying 15 lit texels along row 8 and 0 lit texels when culled (verified failure when bit-unpacking offset was mutated).
  • cargo test --workspace --locked: all crates pass, 0 failures.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: 0 warnings.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6591397626 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712). Originally posted by [tjthebigbearcat-hub](https://github.com/tjthebigbearcat-hub) on 2026-11-24T21:05:22Z. --- ### Summary Adds support for line-output mesh shaders (`topology = 1`) alongside triangles (`topology = 2`) in `victory-shader`: - Updates `emit/lower.rs` with `emit_primitive` to unpack two vertex indices (bits 0 and 10) for lines—leaving the third DXIL `emitIndices` index `undef`—while preserving primitive culling (bit 31 and unexported primitives). - Keeps unsupported topologies (`0`, `3`, etc.) cleanly refused with clearer diagnostic messages. - Updates `emit/mod.rs` module docs to reflect line and triangle mesh shader support. ### Verification (Windows 11 + SDK `dxil.dll` 10.0.26100 + WARP) - Added hand-encoded synthetic GFX10 mesh shader tests in `emit/mod.rs` (zero game bytes; verified with `xtask` asset-policy check): - `mesh_programs_draw_lines_or_triangles`: validates line and triangle programs (normal and culled) against `dxil.dll 10.0.26100` and verifies `PSV0` topology output, while confirming topologies `0` and `3` are refused. - `mesh_lines_light_one_texel_row`: executes a line mesh pipeline on WARP (`D3D12`), verifying 15 lit texels along row 8 and 0 lit texels when culled (verified failure when bit-unpacking offset was mutated). - `cargo test --workspace --locked`: all crates pass, 0 failures. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: **0 warnings**.
DenRakEiw commented 2026-11-24 21:28:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T21:26:31Z.

Review: APPROVED


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

  • cargo test -p victory-shader --lib mesh_ — 6 passed, 0 failed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1 (including mesh_programs_draw_lines_or_triangles and mesh_lines_light_one_texel_row)
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean line-topology mesh shader lowering with end-to-end rendering verification on hardware and WARP. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6047684105 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#pullrequestreview-6047684105). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T21:26:31Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, with `dxil.dll` validator): - `cargo test -p victory-shader --lib mesh_` — 6 passed, 0 failed on both RTX 5090 hardware and `VICTORY_D3D12_WARP=1` (including `mesh_programs_draw_lines_or_triangles` and `mesh_lines_light_one_texel_row`) - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean line-topology mesh shader lowering with end-to-end rendering verification on hardware and WARP. Looks good. AI-assisted (Gemini 4 Neon).
catminou4 commented 2026-11-24 22:02:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:40:02Z.

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.

Line-topology mesh shaders: emitIndices takes two indices for lines (third undef, validator accepts for line topology), primitives past the program's count are culled via zero-area/zero-length sentinels, and a clear error is returned for mesh shaders drawing neither lines nor triangles. +1 macOS test.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047847722 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#pullrequestreview-6047847722). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:40:02Z. **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. Line-topology mesh shaders: emitIndices takes two indices for lines (third undef, validator accepts for line topology), primitives past the program's count are culled via zero-area/zero-length sentinels, and a clear error is returned for mesh shaders drawing neither lines nor triangles. +1 macOS test.
steven-seagull27 commented 2026-11-24 22:02:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-24T21:42:12Z.


Tested PR head 57c2560 on an RTX 5080 (driver 621.24) and built-in Windows WARP. Both lit exactly the same 15 pixels on row 8, columns 0–14 inclusive, on the 16 × 16 target. With the cull bit set, both lit 0 of 256 pixels.

The full RGBA readbacks matched bit for bit between adapters on both draws. Both original mesh tests also passed on the clean PR head.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145277840 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#issuecomment-7145277840). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-24T21:42:12Z. --- Tested PR head `57c2560` on an RTX 5080 (driver 621.24) and built-in Windows WARP. Both lit exactly the same **15 pixels on row 8, columns 0–14 inclusive**, on the 16 × 16 target. With the cull bit set, both lit **0 of 256 pixels**. The full RGBA readbacks matched bit for bit between adapters on both draws. Both original mesh tests also passed on the clean PR head.
mercuryVM commented 2026-11-24 23:05:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T22:24:55Z.

Review: APPROVED


Tested 57c25604 on Windows 11, RTX 5070, MSVC: cargo test -p victory-shader -- --test-threads=1 passes on the head (122 passed, 1 ignored).

The change looks right:

  • corners() drives both the index unpacking and the emitIndices arity, with the third index undef for lines.
  • The topology goes into the entry metadata (topology: ms.topology), so the validator sees a line mesh.

It conflicts with #1718 in lower.rs and mod.rs (the same unpacking loop and the test module), so I couldn't merge it into our fork after #1718. Once #1718 lands, please rebase onto it, and keep the 9-bit 0x1FF mask in the new unpacking.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6048366988 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#pullrequestreview-6048366988). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T22:24:55Z. **Review:** APPROVED --- Tested 57c25604 on Windows 11, RTX 5070, MSVC: `cargo test -p victory-shader -- --test-threads=1` passes on the head (122 passed, 1 ignored). The change looks right: - `corners()` drives both the index unpacking and the `emitIndices` arity, with the third index `undef` for lines. - The topology goes into the entry metadata (`topology: ms.topology`), so the validator sees a line mesh. It conflicts with #1718 in `lower.rs` and `mod.rs` (the same unpacking loop and the test module), so I couldn't merge it into our fork after #1718. Once #1718 lands, please rebase onto it, and keep the 9-bit `0x1FF` mask in the new unpacking. AI-assisted (Claude Code).
kais7654 commented 2026-11-24 23:05:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T22:35:55Z.


Reviewed and verified at runtime (Windows): the six mesh tests pass,
including the draw one — the line lit exactly texel row 8 on both the
hardware device and WARP, the culled export lit nothing, and the
translated modules' PSV0 carries the right topology byte. Topologies
other than lines and triangles stay refused with the new message.

One coordination note: this and #1718 touch the same mask line in
emit_indices (10-bit here, 9-bit plus edge flags there) — whoever
merges second needs a trivial rebase of that one line.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146421891 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#issuecomment-7146421891). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-24T22:35:55Z. --- Reviewed and verified at runtime (Windows): the six mesh tests pass, including the draw one — the line lit exactly texel row 8 on both the hardware device and WARP, the culled export lit nothing, and the translated modules' PSV0 carries the right topology byte. Topologies other than lines and triangles stay refused with the new message. One coordination note: this and #1718 touch the same mask line in emit_indices (10-bit here, 9-bit plus edge flags there) — whoever merges second needs a trivial rebase of that one line.
DeerSilver commented 2026-11-25 00:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T23:06:35Z.


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 onto main 70564ae.

  • cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1 with 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 test Host): 477 passed, 5 failed, 7 ignored. The 5 failures are the ones main 70564ae has 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 with main.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean
  • mesh_lines_light_one_texel_row gives the same result on both devices: hardware: the line lit 15 texels of row 8 on the RTX, and the same on WARP. mesh_programs_draw_lines_or_triangles passes.

No game data used. AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147023728 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#issuecomment-7147023728). Originally posted by [DeerSilver](https://github.com/DeerSilver) on 2026-11-24T23:06:35Z. --- **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 onto `main` `70564ae`. - `cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1` with 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 test `Host`): 477 passed, 5 failed, 7 ignored. The 5 failures are the ones `main` `70564ae` has 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 with `main`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean - `mesh_lines_light_one_texel_row` gives the same result on both devices: `hardware: the line lit 15 texels of row 8` on the RTX, and the same on WARP. `mesh_programs_draw_lines_or_triangles` passes. No game data used. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 02:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T01:34:55Z.


Automated triage for the maintainers.

Merge candidate. This lets mesh programs that draw lines translate. mesh_prologue and the primitive export in crates/victory-shader/src/emit/lower.rs go through a new emit_primitive, which passes as many 9-bit indices as corners(topology) gives and leaves the third undefined for a line. Topologies other than 1 and 2 stay refused. The topology numbering (1 lines, 2 triangles) is the one MeshIo::topology in native.rs already documents, and it matches DXIL's, which passes it through to PSV0. Upstream's 0x1FF index mask is kept. The new draw test, mesh_lines_light_one_texel_row, was reported in this thread to light only row 8 and to cull completely on an RTX 5080, an RTX 5060 Laptop, an Intel UHD and WARP.

Thanks for the rebase, which kept main's edge-flag tests. It merges cleanly now, so this is the first content review.

CI: passing (check).


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149712601 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#issuecomment-7149712601). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:34:55Z. --- <!-- victory-triage v1 head=ff8c44552b9d21bfa7ba8d8f65bd99c9cc00f06c verdict=merge-candidate at=2026-11-25T06:27:30Z --> Automated triage for the maintainers. **Merge candidate.** This lets mesh programs that draw lines translate. `mesh_prologue` and the primitive export in `crates/victory-shader/src/emit/lower.rs` go through a new `emit_primitive`, which passes as many 9-bit indices as `corners(topology)` gives and leaves the third undefined for a line. Topologies other than 1 and 2 stay refused. The topology numbering (1 lines, 2 triangles) is the one `MeshIo::topology` in `native.rs` already documents, and it matches DXIL's, which passes it through to PSV0. Upstream's `0x1FF` index mask is kept. The new draw test, `mesh_lines_light_one_texel_row`, was reported in this thread to light only row 8 and to cull completely on an RTX 5080, an RTX 5060 Laptop, an Intel UHD and WARP. Thanks for the rebase, which kept `main`'s edge-flag tests. It merges cleanly now, so this is the first content review. CI: passing (`check`). --- _Generated by [Claude Code](https://claude.ai/code)_
tjthebigbearcat-hub commented 2026-11-25 04:06:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by tjthebigbearcat-hub on 2026-11-25T03:21:00Z.


Rebased cleanly onto current main (940d32f → ff8c445):

  • Integrated upstream's 9-bit 0x1FF vertex index edge-flag mask into the line/triangle primitive export loop and kept both upstream's edge-flag tests and our line-mesh tests.
  • Re-verified cargo test -p victory-shader --locked mesh (7 passed, 0 failed) and cargo clippy (0 warnings).
<!-- greyfinch-sync:Marvisak/VIctory:comment:7151830939 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#issuecomment-7151830939). Originally posted by [tjthebigbearcat-hub](https://github.com/tjthebigbearcat-hub) on 2026-11-25T03:21:00Z. --- Rebased cleanly onto current `main` (`940d32f` → `ff8c445`): - Integrated upstream's 9-bit `0x1FF` vertex index edge-flag mask into the line/triangle primitive export loop and kept both upstream's edge-flag tests and our line-mesh tests. - Re-verified `cargo test -p victory-shader --locked mesh` (7 passed, 0 failed) and `cargo clippy` (0 warnings).
fuzeofficlal commented 2026-11-26 02:05:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:51:45Z.

Review: COMMENTED


Reviewed and verified against main (63bcca43) on Windows 11 with native Mesh Shaders on RTX 5090 + WARP (VICTORY_D3D12_DEBUG=1) and dxil.dll (10.0.26100.0) — looks clean and ready to merge:

  • corners(topology) (1 -> Some(2), 2 -> Some(3), rejecting others) and the shared emit_primitive(prim, indices) helper cleanly cover both mesh_prologue and emit_indices, preserving bit-31 primitive culling (SLT 0 -> 0), dropping edge flags, and passing undef for the 3rd corner to dx.op.emitIndices (opcode 169) on line topology — accepted by dxil.dll.
  • emit/container.rs (info[27]) and victory-gpu stream PSO / dispatch_mesh already consume the PSV0 topology directly with no GPU-crate changes needed.
  • Note on 512 KiB file-size policy: on 63bcca43, this brings crates/victory-shader/src/emit/lower.rs to 521,619 B (+1,056 B, 2,669 B under the 524,288 B cap) — passes cargo xtask policy now, just worth keeping an eye on merge order with other lower.rs PRs.

Local verification:

  • emit::tests::mesh_programs_draw_lines_or_triangles & mesh_lines_light_one_texel_row: passed on both RTX 5090 and WARP (the line lit 15 texels of row 8, culled 0x8000_0400 segment unlit)
  • victory-shader mesh + emit::lower::tests: 40/40 passed (RTX 5090 + DEBUG=1), 7/7 passed (WARP + DEBUG=1)
  • cargo clippy (default & --all-features) + cargo xtask policy (191 files ok): 0 warnings
<!-- greyfinch-sync:Marvisak/VIctory:review:6067493321 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1712#pullrequestreview-6067493321). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T01:51:45Z. **Review:** COMMENTED --- Reviewed and verified against `main` (`63bcca43`) on Windows 11 with native Mesh Shaders on RTX 5090 + WARP (`VICTORY_D3D12_DEBUG=1`) and `dxil.dll` (`10.0.26100.0`) — looks clean and ready to merge: - `corners(topology)` (`1 -> Some(2)`, `2 -> Some(3)`, rejecting others) and the shared `emit_primitive(prim, indices)` helper cleanly cover both `mesh_prologue` and `emit_indices`, preserving bit-31 primitive culling (`SLT 0 -> 0`), dropping edge flags, and passing `undef` for the 3rd corner to `dx.op.emitIndices` (opcode `169`) on line topology — accepted by `dxil.dll`. - `emit/container.rs` (`info[27]`) and `victory-gpu` stream PSO / `dispatch_mesh` already consume the PSV0 topology directly with no GPU-crate changes needed. - **Note on 512 KiB file-size policy**: on `63bcca43`, this brings `crates/victory-shader/src/emit/lower.rs` to **521,619 B** (`+1,056 B`, **2,669 B** under the `524,288 B` cap) — passes `cargo xtask policy` now, just worth keeping an eye on merge order with other `lower.rs` PRs. **Local verification**: - `emit::tests::mesh_programs_draw_lines_or_triangles` & `mesh_lines_light_one_texel_row`: passed on both **RTX 5090** and **WARP** (`the line lit 15 texels of row 8`, culled `0x8000_0400` segment unlit) - `victory-shader` mesh + `emit::lower::tests`: **40/40 passed** (RTX 5090 + `DEBUG=1`), **7/7 passed** (WARP + `DEBUG=1`) - `cargo clippy` (default & `--all-features`) + `cargo xtask policy` (`191 files ok`): 0 warnings
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1712:upstream-pr/1712'
git switch 'upstream-pr/1712'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1712'
git switch 'upstream-pr/1712'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1712'
git switch 'upstream-pr/1712'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1712'
git switch 'main'
git merge --squash 'upstream-pr/1712'
git switch 'main'
git merge --ff-only 'upstream-pr/1712'
git switch 'main'
git merge 'upstream-pr/1712'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1711
No description provided.