Port GPU amplification-stage indirect mesh launch (VICTORY_MESH_LAUNCH) #275

Closed
github-bot wants to merge 638 commits from github-bot/gh-275 into main AGit
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 13:22 UTC · original
Vladimir-Human:perf/mesh-launch-amplification → main · +60504 −5300 · 202 files · 638 commits · closed without merging

Summary

Ports VICTORY_MESH_LAUNCH (adapted from fxceless/victory-fork commits b1d777a, 0e006f0 and kelvaroq patch 0041-mesh-launch-wide-hash.patch) into victory-shader and victory-gpu.

Instead of inserting a compute clamp dispatch and full barriers before every single-record indirect mesh draw, this change pairs translated mesh pipelines with a programmatically emitted as_6_6 amplification stage (victory_shader::emit::mesh_launch_as) that loads the 3-dword indirect dispatch record directly on the GPU, bounds it identically to crate::indirect, charges the list's work budget atomically, and dispatches the mesh groups.

Key Changes

  • Zero-blob programmatic as_6_6 DXIL emitter (crates/victory-shader/src/emit/{launch.rs, shader.rs, container.rs, bitcode.rs, mod.rs}, crates/victory-shader/src/lib.rs):
    • Generates the as_6_6 amplification shader programmatically via victory-shader (zero precompiled DXIL/hex blobs; passes xtask policy and Windows SDK dxil.dll validation for both rest=false and rest=true).
    • Matches crate::indirect semantics 100%: direct CPU counts clamped <= 65,535 (unbounded by budget), indirect unfilled-slot zeroing for x > 65,535, y/z clamped to 1, BUDGET = 1 << 27 at 128/group, VICTORY_INDIRECT_REST (rest=false vs rest=true), and all 5 budget diagnostic counters [cost, max_asked, sum_asked, refused, biggest].
    • Declares 4-byte amplification payload metadata on translated mesh shaders (mesh_payload_bytes(), synced via set_mesh_launch_payload with launch::on()) and bumps TRANSLATOR_VERSION 9 -> 10 atop main's version 9.
  • Host launch wiring & safe fallbacks (crates/victory-gpu/src/{launch.rs, pipeline/host.rs, draw.rs, shader_cache.rs, indirect.rs, host.rs, lib.rs}):
    • Supports VICTORY_MESH_LAUNCH=1 (default ON), 0 (off), alt (20s alternating), and VICTORY_AB under --features diagnostics.
    • Binds a dedicated read-only GENERIC_READ dummy buffer (DummyRecord) to roots[1] on direct dispatches so it never conflicts with the UNORDERED_ACCESS budget buffer on roots[2], and requires non-zero live GPU addresses (falling back cleanly to Launch::plain() if unavailable).
    • Lazily builds Launch::plain() (no-AS pipeline sharing the root signature) for multi-record indirect calls, count-buffer calls, and off phases of alt/VICTORY_AB, keeping distinct pipeline library keys ("mesh launched" vs "mesh payload"), 64-dword root-signature cap fallback, PSO creation fallback without AS, and post-prepare_direct pipeline lookup in draw.rs::dispatch_mesh.
    • Keys shader_cache::build() on effective mesh_payload=<bytes> (syncing victory-shader before build, precompile, and host_shader) so unset, "1", "alt", and VICTORY_AB runs share one cache key while payload-0 runs stay isolated.

Verification (rustc 1.98.1 & 1.100.0, VICTORY_D3D12_DEBUG=1, --test-threads=1)

  • cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings (default & --features victory-gpu/diagnostics): 0 warnings
  • cargo run -p xtask --locked -- policy --staged (13 files ok), xtask policy (315 files ok), cargo test -p xtask --locked (11/11 passed)
  • victory-shader (emit::launch, emit::container, emit::rect, mesh): 12/12 passed (dxil.dll validated for both rest=false and rest=true)
  • victory-gpu (hw_mesh_records_are_launched_by_the_amplification_stage, warp_mesh_records_are_launched_by_the_amplification_stage, a_mesh_pipeline_loads_from_the_library, mesh_launch_switch_changes_cache_key): 4/4 passed (default) and 4/4 passed (--features diagnostics), asserting all 5 budget/stat counter dwords verbatim and 0 ID3D12InfoQueue errors/corruption across direct, indirect, mixed direct+indirect, unfilled-slot zeroing, REST=0 vs REST=1 budget exhaustion, and plain no-AS fallback on both HW (RTX 4070 SUPER) and WARP.

Credit: adapted from fxceless/victory-fork (b1d777a, 0e006f0) and kelvaroq (0041-mesh-launch-wide-hash.patch).

**@⁠Vladimir-Human** on GitHub · 2026-11-27 13:22 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/275) `Vladimir-Human:perf/mesh-launch-amplification` → `main` · +60504 −5300 · 202 files · 638 commits · closed without merging ## Summary Ports `VICTORY_MESH_LAUNCH` (adapted from `fxceless/victory-fork` commits `b1d777a`, `0e006f0` and `kelvaroq` patch `0041-mesh-launch-wide-hash.patch`) into `victory-shader` and `victory-gpu`. Instead of inserting a compute clamp dispatch and full barriers before every single-record indirect mesh draw, this change pairs translated mesh pipelines with a programmatically emitted `as_6_6` amplification stage (`victory_shader::emit::mesh_launch_as`) that loads the 3-dword indirect dispatch record directly on the GPU, bounds it identically to `crate::indirect`, charges the list's work budget atomically, and dispatches the mesh groups. ### Key Changes - **Zero-blob programmatic `as_6_6` DXIL emitter (`crates/victory-shader/src/emit/{launch.rs, shader.rs, container.rs, bitcode.rs, mod.rs}`, `crates/victory-shader/src/lib.rs`):** - Generates the `as_6_6` amplification shader programmatically via `victory-shader` (zero precompiled DXIL/hex blobs; passes `xtask policy` and Windows SDK `dxil.dll` validation for both `rest=false` and `rest=true`). - Matches `crate::indirect` semantics 100%: direct CPU counts clamped `<= 65,535` (unbounded by budget), indirect unfilled-slot zeroing for `x > 65,535`, `y`/`z` clamped to `1`, `BUDGET = 1 << 27` at `128`/group, `VICTORY_INDIRECT_REST` (`rest=false` vs `rest=true`), and all 5 budget diagnostic counters `[cost, max_asked, sum_asked, refused, biggest]`. - Declares 4-byte amplification payload metadata on translated mesh shaders (`mesh_payload_bytes()`, synced via `set_mesh_launch_payload` with `launch::on()`) and bumps `TRANSLATOR_VERSION` `9 -> 10` atop `main`'s version 9. - **Host launch wiring & safe fallbacks (`crates/victory-gpu/src/{launch.rs, pipeline/host.rs, draw.rs, shader_cache.rs, indirect.rs, host.rs, lib.rs}`):** - Supports `VICTORY_MESH_LAUNCH=1` (default ON), `0` (off), `alt` (20s alternating), and `VICTORY_AB` under `--features diagnostics`. - Binds a dedicated read-only `GENERIC_READ` dummy buffer (`DummyRecord`) to `roots[1]` on direct dispatches so it never conflicts with the `UNORDERED_ACCESS` budget buffer on `roots[2]`, and requires non-zero live GPU addresses (falling back cleanly to `Launch::plain()` if unavailable). - Lazily builds `Launch::plain()` (no-AS pipeline sharing the root signature) for multi-record indirect calls, count-buffer calls, and off phases of `alt`/`VICTORY_AB`, keeping distinct pipeline library keys (`"mesh launched"` vs `"mesh payload"`), 64-dword root-signature cap fallback, PSO creation fallback without AS, and post-`prepare_direct` pipeline lookup in `draw.rs::dispatch_mesh`. - Keys `shader_cache::build()` on effective `mesh_payload=<bytes>` (syncing `victory-shader` before `build`, `precompile`, and `host_shader`) so unset, `"1"`, `"alt"`, and `VICTORY_AB` runs share one cache key while payload-0 runs stay isolated. ### Verification (`rustc 1.98.1` & `1.100.0`, `VICTORY_D3D12_DEBUG=1`, `--test-threads=1`) - `cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings` (default & `--features victory-gpu/diagnostics`): **0 warnings** - `cargo run -p xtask --locked -- policy --staged` (`13 files ok`), `xtask policy` (`315 files ok`), `cargo test -p xtask --locked` (**11/11 passed**) - `victory-shader` (`emit::launch`, `emit::container`, `emit::rect`, `mesh`): **12/12 passed** (`dxil.dll` validated for both `rest=false` and `rest=true`) - `victory-gpu` (`hw_mesh_records_are_launched_by_the_amplification_stage`, `warp_mesh_records_are_launched_by_the_amplification_stage`, `a_mesh_pipeline_loads_from_the_library`, `mesh_launch_switch_changes_cache_key`): **4/4 passed** (default) and **4/4 passed** (`--features diagnostics`), asserting **all 5 budget/stat counter dwords** verbatim and **0 `ID3D12InfoQueue` errors/corruption** across direct, indirect, mixed direct+indirect, unfilled-slot zeroing, `REST=0` vs `REST=1` budget exhaustion, and plain no-AS fallback on both HW (RTX 4070 SUPER) and WARP. Credit: adapted from `fxceless/victory-fork` (`b1d777a`, `0e006f0`) and `kelvaroq` (`0041-mesh-launch-wide-hash.patch`).
Launch single-record indirect mesh draws and direct mesh dispatches through a
programmatically emitted `as_6_6` amplification stage (`victory-shader`),
eliminating per-record compute clamp dispatches and barriers between mesh draws.
Matches `crate::indirect` clamping (65,535 group cap, unfilled-slot zeroing,
1D y/z clamp, `VICTORY_INDIRECT_REST`, and budget diagnostics), supports
`VICTORY_MESH_LAUNCH=1|0|alt` (default ON), lazily falls back to a plain no-AS
pipeline for multi-record/count-buffer/off-phase calls, keys `shader_cache` on
`VICTORY_MESH_LAUNCH`, and bumps `TRANSLATOR_VERSION` to 9.

Adapted from fxceless/victory-fork (`b1d777a`, `0e006f0`) and kelvaroq
(`0041-mesh-launch-wide-hash.patch`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 13:23:47 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 13:37 UTC · original

@⁠Vladimir-Human The mesh launch path needs the clamped dispatch dimensions and work-budget counters to match the existing indirect path on the same inputs. Keep the fallback for unsupported pipelines and tie the emitted payload to the cache key. Current main already uses translator version 9, so the PR’s cache-version plan needs that base.

**@⁠TaynanGT** on GitHub · 2026-11-27 13:37 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/275#issuecomment-7219729677) @⁠Vladimir-Human The mesh launch path needs the clamped dispatch dimensions and work-budget counters to match the existing indirect path on the same inputs. Keep the fallback for unsupported pipelines and tie the emitted payload to the cache key. Current main already uses translator version 9, so the PR’s cache-version plan needs that base.
github-bot force-pushed github-bot/gh-275 from 23d0afb406 to 7c04cca367 2026-11-27 14:19:27 +00:00 Compare
Author
Owner

@⁠Vladimir-Human on GitHub · 2026-11-27 14:06 UTC · original

@⁠TaynanGT Updated in 7c04cca3 to address every point:

  1. Rebased onto main (877a40e8, TRANSLATOR_VERSION = 9) and bumped TRANSLATOR_VERSION 9 -> 10:

    • crates/victory-shader/src/lib.rs:29 now bumps 9 -> 10, with const { assert!(victory_shader::TRANSLATOR_VERSION >= 10) } in crates/victory-gpu/src/shader_cache.rs:657.
    • Emitted payload metadata (victory_shader::emit::mesh_payload_bytes(), synced via launch::sync_shader_payload() / set_mesh_launch_payload() across build, precompile, and host_shader) is tied directly into shader_cache::build() (mesh_payload=<bytes>, shader_cache.rs:146-153), verified by shader_cache::tests::mesh_launch_switch_changes_cache_key (unset == "1" == "alt" at payload 4, distinct from "0" at payload 0, and VICTORY_AB override matching payload 4 under diagnostics).
  2. Clamped dispatch dimensions and all 5 work-budget/stat counters matching indirect.rs:

    • crates/victory-shader/src/emit/launch.rs mirrors indirect.rs's CLAMP shader on identical inputs: unfilled x > 65,535 zeroing (asked = 0), y/z clamping to 1, zero-dim empty runs, direct counts clamped to 65,535 (unbounded by budget), BUDGET = 1 << 27 at 128/group, VICTORY_INDIRECT_REST (rest=false vs rest=true), and all 5 budget/stat dwords [cost, max_asked, sum_asked, refused, biggest].
    • Verified by victory_shader::emit::launch::tests::mesh_launch_amplification_shader_is_valid_dxil (dxil.dll-validated for both rest modes) and pipeline::host::tests::{hw,warp}_mesh_records_are_launched_by_the_amplification_stage, which now assert all 5 budget/stat counter dwords verbatim across single-indirect, mixed direct+indirect (in explicit UNORDERED_ACCESS budget state), unfilled/zero-dim/clamped y/z, REST=0, and REST=1 cases with 0 ID3D12InfoQueue errors/corruption on both HW and WARP.
  3. Unsupported-pipeline and non-single-record fallbacks preserved:

    • Pipelines exceeding the 64-dword root-signature cap (pipeline/host.rs:704-712) or refused with an amplification stage (pipeline/host.rs:845-867) fall back cleanly without the launch stage.
    • Multi-record indirect calls, count-buffer calls, alt/VICTORY_AB off phases, and unavailable-budget calls lazily bind Launch::plain() (no-AS pipeline sharing the root signature, pipeline/host.rs:435-478, draw.rs:3816-3836, 4833-4844), with distinct library keys "mesh launched" vs "mesh payload" covered by a_mesh_pipeline_loads_from_the_library and the plain phase of {hw,warp}_mesh_records_are_launched_by_the_amplification_stage.

Re-verified locally (VICTORY_D3D12_DEBUG=1, --test-threads=1): clippy --all-targets --locked -- -D warnings (default & diagnostics) 0 warnings, xtask policy (315 files ok) & xtask tests 11/11, victory-shader 12/12, and victory-gpu PR B suite 4/4 default + 4/4 diagnostics (HW + WARP, 0 D3D12 debug errors).

**@⁠Vladimir-Human** on GitHub · 2026-11-27 14:06 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/275#issuecomment-7220358618) @⁠TaynanGT Updated in `7c04cca3` to address every point: 1. **Rebased onto `main` (`877a40e8`, `TRANSLATOR_VERSION = 9`) and bumped `TRANSLATOR_VERSION` `9 -> 10`:** - `crates/victory-shader/src/lib.rs:29` now bumps `9 -> 10`, with `const { assert!(victory_shader::TRANSLATOR_VERSION >= 10) }` in `crates/victory-gpu/src/shader_cache.rs:657`. - Emitted payload metadata (`victory_shader::emit::mesh_payload_bytes()`, synced via `launch::sync_shader_payload()` / `set_mesh_launch_payload()` across `build`, `precompile`, and `host_shader`) is tied directly into `shader_cache::build()` (`mesh_payload=<bytes>`, `shader_cache.rs:146-153`), verified by `shader_cache::tests::mesh_launch_switch_changes_cache_key` (`unset == "1" == "alt"` at payload `4`, distinct from `"0"` at payload `0`, and `VICTORY_AB` override matching payload `4` under `diagnostics`). 2. **Clamped dispatch dimensions and all 5 work-budget/stat counters matching `indirect.rs`:** - `crates/victory-shader/src/emit/launch.rs` mirrors `indirect.rs`'s `CLAMP` shader on identical inputs: unfilled `x > 65,535` zeroing (`asked = 0`), `y`/`z` clamping to `1`, zero-dim empty runs, direct counts clamped to `65,535` (unbounded by budget), `BUDGET = 1 << 27` at `128`/group, `VICTORY_INDIRECT_REST` (`rest=false` vs `rest=true`), and all 5 budget/stat dwords `[cost, max_asked, sum_asked, refused, biggest]`. - Verified by `victory_shader::emit::launch::tests::mesh_launch_amplification_shader_is_valid_dxil` (`dxil.dll`-validated for both `rest` modes) and `pipeline::host::tests::{hw,warp}_mesh_records_are_launched_by_the_amplification_stage`, which now assert **all 5** budget/stat counter dwords verbatim across single-indirect, mixed direct+indirect (in explicit `UNORDERED_ACCESS` budget state), unfilled/zero-dim/clamped `y`/`z`, `REST=0`, and `REST=1` cases with **0 `ID3D12InfoQueue` errors/corruption** on both HW and WARP. 3. **Unsupported-pipeline and non-single-record fallbacks preserved:** - Pipelines exceeding the 64-dword root-signature cap (`pipeline/host.rs:704-712`) or refused with an amplification stage (`pipeline/host.rs:845-867`) fall back cleanly without the launch stage. - Multi-record indirect calls, count-buffer calls, `alt`/`VICTORY_AB` off phases, and unavailable-budget calls lazily bind `Launch::plain()` (no-AS pipeline sharing the root signature, `pipeline/host.rs:435-478`, `draw.rs:3816-3836, 4833-4844`), with distinct library keys `"mesh launched"` vs `"mesh payload"` covered by `a_mesh_pipeline_loads_from_the_library` and the `plain` phase of `{hw,warp}_mesh_records_are_launched_by_the_amplification_stage`. Re-verified locally (`VICTORY_D3D12_DEBUG=1`, `--test-threads=1`): `clippy --all-targets --locked -- -D warnings` (default & `diagnostics`) **0 warnings**, `xtask policy` (`315 files ok`) & `xtask` tests **11/11**, `victory-shader` **12/12**, and `victory-gpu` PR B suite **4/4 default** + **4/4 `diagnostics`** (HW + WARP, 0 D3D12 debug errors).
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-27 14:25 UTC · original

@⁠Vladimir-Human The five counters and the multi-record/count-buffer fallback are the checks I wanted. Use VICTORY_MESH_LAUNCH=0 explicitly as the control against 1, since unset currently selects the mesh payload path. Keep a separate translated shader cache for each phase and report the dispatch and frame times together.

**@⁠TaynanGT** on GitHub · 2026-11-27 14:25 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/275#issuecomment-7220760894) @⁠Vladimir-Human The five counters and the multi-record/count-buffer fallback are the checks I wanted. Use `VICTORY_MESH_LAUNCH=0` explicitly as the control against `1`, since unset currently selects the mesh payload path. Keep a separate translated shader cache for each phase and report the dispatch and frame times together.
github-bot force-pushed github-bot/gh-275 from 7c04cca367 to bcb57f384b 2026-11-27 20:13:08 +00:00 Compare
github-bot closed this pull request 2026-11-30 17:15:06 +00:00
Author
Owner

@⁠TaynanGT on GitHub · 2026-11-30 17:13 UTC · original

main has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current main and open a new PR; I'll review it there.

**@⁠TaynanGT** on GitHub · 2026-11-30 17:13 UTC · [original](https://github.com/TaynanGT/Vice-Tay/pull/275#issuecomment-7285925649) `main` has moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the current `main` and open a new PR; I'll review it there.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.