d3d12: carry #2580 - mesh pipelines draw through compute without mesh shaders (D3D12-MESH-COMPUTE-FALLBACK) #3128

Open
github-bot wants to merge 13 commits from github-bot/gh-3128 into main AGit
Owner

@⁠MoonEyes on GitHub · 2026-12-02 12:47 UTC · original
MoonEyes:carry/2580 → main · +2129 −142 · 31 files · 13 commits · open

Claimed in the coordination issue as: D3D12-MESH-COMPUTE-FALLBACK (the claim of the original author, #2570)

Depends on: #2557 (merged)

What and why

Carry of #2580 (qhukz13), in conflict with main in d3d12/crates/leonida-gpu/src/pipeline/host.rs, shader_cache.rs and d3d12/crates/leonida-shader/src/emit/{lower,mod,shader}.rs. This branch is main (40ac04183) merged with the head of #2580 (74ac98c64), so the author's commits are kept. My only change is the merge.

The change itself is #2580's: on a GPU without D3D12 mesh shaders (Pascal and older) every mesh pipeline was refused and the world drew nothing. A mesh program is now translated as a cs_6_6 compute shader writing to a buffer, drawn as a triangle list through a pass-through vertex shader (LEONIDA_MESH_COMPUTE=1 forces it on any card). The review fixes of the original (sink slot, topology restore, offsets beside their elements, no native mesh signature on that path) are already in its head.

How each conflict was resolved (both sides kept):

  • emit/mod.rs, emit/shader.rs: main's mesh_counts, mesh_payload, SLOT_TLAS_* and ray_queries stay beside the PR's mesh_vs, MeshOut, SLOT_MESH_* and mesh_out. constant_color stays pub(super) (main's mesh_counts tests use it) and builds on the PR's test_programs::color_ps.
  • emit/lower.rs: host_settings() has six words, main's inline ray tracing switch then the PR's mesh switch; both setters and the TEST_MESH_COMPUTE hook stay.
  • shader_cache.rs: a record writes the mesh layout (0 or 1 plus the layout), then main's optional ray query record; the decoder reads them in that order. paired_override keeps main's host_settings()[..4] test.
  • pipeline/host.rs: HostPipeline has both amplify and mesh_compute; the root slots the host owns include SLOT_MESH_IN and the TLAS range; main's effective_depth_bounds_desc stays and the PR's impl HostPipeline follows it.
  • Test literals (HostShader, Parts, Draw) take the fields of both sides (ray_queries, mesh_out, mesh_compute, vertex_count, instances); two imports that main's constant_color alone used are gone.

Tested

Windows 11, NVIDIA GeForce RTX 4060 (driver 32.0.16.1088), on current main (40ac04183) plus this branch (016c7765b), debug build:

  • cargo check -p leonida-shader -p leonida-gpu --tests: no error (one unused mut warning in host.rs, also on main with the diagnostics feature off).
  • cargo test -p leonida-shader --lib mesh: 18 passed (the device tests ran on the hardware adapter and on WARP: "the mesh program drew as compute (mesh shaders there: true)").
  • cargo test -p leonida-gpu --lib shader_cache: 6 passed; --lib mesh_fallback: 1 passed; --lib pipeline::host: 11 passed.
  • Whole suites: cargo test -p leonida-shader --lib: 432 passed, 0 failed, 6 ignored; cargo test -p leonida-gpu --lib: 692 passed, 0 failed, 59 ignored.
  • Red: with host_mesh_compute() forced to false in emit/lower.rs (mesh programs stay mesh) 3 of the 18 shader mesh tests fail (a_mesh_program_translates_as_compute_without_mesh_shaders, a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws, the_mesh_sink_slot_draws_nothing) and mesh_fallback::tests::mesh_runs_in_one_list_draw_their_own_groups_and_the_strip_after_them_its_strip fails; restored, git status clean. On main itself the new tests do not build (MeshOut, mesh_vs, TEST_MESH_COMPUTE are absent).
  • python -I scripts/check_no_game_data.py on the 30 changed files: clean.
  • Not run: the C++ runtime build, CI, a card without mesh shaders (the author measured a GTX 1050 Ti).
  • This touches the render path: an in-game run of at least 300 s on the head is still needed before merging.

GPUs tested: NVIDIA GeForce RTX 4060 (mesh shaders present, so the comparison with the native mesh pipeline ran) and WARP, Windows 11.

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md. (n/a: no new translation rule, a host mode that lowers mesh programs as compute; the original did not touch the table)

Supersedes #2580 once merged; the original stays open until a maintainer decides.

🤖 Generated with Claude Code

**@⁠MoonEyes** on GitHub · 2026-12-02 12:47 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128) `MoonEyes:carry/2580` → `main` · +2129 −142 · 31 files · 13 commits · open Claimed in the coordination issue as: D3D12-MESH-COMPUTE-FALLBACK (the claim of the original author, https://git.gtahub.st/github/ubiquitarianism--leonida/issues/2570) Depends on: #2557 (merged) ### What and why Carry of #2580 (qhukz13), in conflict with `main` in `d3d12/crates/leonida-gpu/src/pipeline/host.rs`, `shader_cache.rs` and `d3d12/crates/leonida-shader/src/emit/{lower,mod,shader}.rs`. This branch is `main` (`40ac04183`) merged with the head of #2580 (`74ac98c64`), so the author's commits are kept. My only change is the merge. The change itself is #2580's: on a GPU without D3D12 mesh shaders (Pascal and older) every mesh pipeline was refused and the world drew nothing. A mesh program is now translated as a `cs_6_6` compute shader writing to a buffer, drawn as a triangle list through a pass-through vertex shader (`LEONIDA_MESH_COMPUTE=1` forces it on any card). The review fixes of the original (sink slot, topology restore, offsets beside their elements, no native mesh signature on that path) are already in its head. How each conflict was resolved (both sides kept): - `emit/mod.rs`, `emit/shader.rs`: main's `mesh_counts`, `mesh_payload`, `SLOT_TLAS_*` and `ray_queries` stay beside the PR's `mesh_vs`, `MeshOut`, `SLOT_MESH_*` and `mesh_out`. `constant_color` stays `pub(super)` (main's `mesh_counts` tests use it) and builds on the PR's `test_programs::color_ps`. - `emit/lower.rs`: `host_settings()` has six words, main's inline ray tracing switch then the PR's mesh switch; both setters and the `TEST_MESH_COMPUTE` hook stay. - `shader_cache.rs`: a record writes the mesh layout (0 or 1 plus the layout), then main's optional ray query record; the decoder reads them in that order. `paired_override` keeps main's `host_settings()[..4]` test. - `pipeline/host.rs`: `HostPipeline` has both `amplify` and `mesh_compute`; the root slots the host owns include `SLOT_MESH_IN` and the TLAS range; main's `effective_depth_bounds_desc` stays and the PR's `impl HostPipeline` follows it. - Test literals (`HostShader`, `Parts`, `Draw`) take the fields of both sides (`ray_queries`, `mesh_out`, `mesh_compute`, `vertex_count`, `instances`); two imports that main's `constant_color` alone used are gone. ### Tested Windows 11, NVIDIA GeForce RTX 4060 (driver 32.0.16.1088), on current `main` (`40ac04183`) plus this branch (`016c7765b`), debug build: - `cargo check -p leonida-shader -p leonida-gpu --tests`: no error (one `unused mut` warning in `host.rs`, also on main with the `diagnostics` feature off). - `cargo test -p leonida-shader --lib mesh`: 18 passed (the device tests ran on the hardware adapter and on WARP: "the mesh program drew as compute (mesh shaders there: true)"). - `cargo test -p leonida-gpu --lib shader_cache`: 6 passed; `--lib mesh_fallback`: 1 passed; `--lib pipeline::host`: 11 passed. - Whole suites: `cargo test -p leonida-shader --lib`: 432 passed, 0 failed, 6 ignored; `cargo test -p leonida-gpu --lib`: 692 passed, 0 failed, 59 ignored. - Red: with `host_mesh_compute()` forced to `false` in `emit/lower.rs` (mesh programs stay mesh) 3 of the 18 shader mesh tests fail (`a_mesh_program_translates_as_compute_without_mesh_shaders`, `a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws`, `the_mesh_sink_slot_draws_nothing`) and `mesh_fallback::tests::mesh_runs_in_one_list_draw_their_own_groups_and_the_strip_after_them_its_strip` fails; restored, git status clean. On main itself the new tests do not build (`MeshOut`, `mesh_vs`, `TEST_MESH_COMPUTE` are absent). - `python -I scripts/check_no_game_data.py` on the 30 changed files: clean. - Not run: the C++ runtime build, CI, a card without mesh shaders (the author measured a GTX 1050 Ti). - This touches the render path: an in-game run of at least 300 s on the head is still needed before merging. GPUs tested: NVIDIA GeForce RTX 4060 (mesh shaders present, so the comparison with the native mesh pipeline ran) and WARP, Windows 11. AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md). - [ ] A new translator rule is in the contract table of `docs/design.md`. (n/a: no new translation rule, a host mode that lowers mesh programs as compute; the original did not touch the table) Supersedes #2580 once merged; the original stays open until a maintainer decides. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
set_host_mesh_shaders(false) lowers a mesh program as cs_6_6. setMeshOutputCounts goes. emitIndices,
storeVertexOutput and storePrimitiveOutput become raw stores into the root UAV SLOT_MESH_OUT (251), in the
group's MeshOut slot: max_vertices vertices, then max_primitives primitives (three indices, then the per-primitive
outputs).
- The buffer is MESH_OUT_BYTES (64 MiB). A 256-byte header holds a draw's arguments: lane 0 of each group raises
  its instance count to the group id + 1, so an indirect dispatch's draw needs no CPU read.
- Groups past MeshOut::groups_cap write to one sink slot after the last.
- mesh_vs() builds the pass-through vertex shader that draws it. SV_VertexID gives primitive and corner,
  SV_InstanceID the group. It reads the root SRV SLOT_MESH_IN (250) and outputs the program's vertex outputs
  register for register, plus the per-primitive outputs where the pixel shader reads them, constant. A group past
  the cap draws a triangle of no area.
- HostShader carries the layout and the signatures, and the shader cache encodes them. host_settings() has a word
  for it, so a translation for one kind of host never serves the other.

Tests: the triangle mesh fixture translates as compute (layout, root UAV, empty output signature; dxil.dll takes
it for plain, edge-flagged and culled primitives) and stays a mesh shader with mesh shaders. Its vertex shader
validates. On a device, the program run as compute and drawn lights the texels the mesh pipeline lights, compared
texel for texel where the device has mesh shaders. The test harness gets a root UAV for dispatches, root SRVs in
draws and a vertex count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At device creation the translator is told whether the host has mesh shaders at shader model 6.6
(LEONIDA_MESH_COMPUTE=1 takes the fallback on any card). Without them, a mesh pipeline is made as two:
- the mesh program as a compute pipeline;
- the pass-through vertex shader with the title's pixel shader and state, drawing triangle lists with no vertex input.

The draw path:
- A mesh dispatch binds the compute pipeline with the title's graphics root arguments (roots_ref reads them while
  title_side_graphics is set).
- It dispatches and draws 3 * max_primitives vertices, one instance a group.
- An indirect one writes the header's draw arguments (WriteBufferImmediate), runs the title's record with a
  dispatch signature, and draws from the header with ExecuteIndirect.
- The buffer goes common -> UAV -> shader resource and indirect argument -> common.

shortcut: an indirect call of several records is left out (each would fill the same slots).

MEASURED on a GTX 1050 Ti (Pascal: mesh shader tier 0), Windows 10 with #2557: the title gets past its start screen
through the opening cutscenes into the first playable scene. Without this, every mesh pipeline was refused and the
world drew nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From timbot103's audit of dc5818bb8 (#2580):
- An indirect mesh dispatch run as compute makes no host mesh command
  signature first: a host without mesh shaders may refuse one, and the
  fallback needs none (draw.rs).
- Slot `groups_cap` is the sink every group from the cap on writes to at
  once: mesh_vs draws nothing for an instance from the cap on (it took
  only those past it), and the direct path draws at most `cap` instances.
- The fallback's triangle list no longer stays the list's topology: the
  title's comes back after it (`restore_topology`).
- MeshOut's OSG1/PSG1 parts keep their elements in the order of the byte
  offsets made for them: sorted by register, an element stood beside
  another's offset where the outputs were not in register order.
- A per-primitive render-target or viewport index is refused by mesh_vs
  rather than left out (the translator does not export them yet).
- The host device is made before a pipeline chooses between the mesh path
  and the fallback, so a pipeline made first cannot keep the mesh path.
- The mesh program's own stores (to title buffers) count after a fallback
  draw, as the draw's do (`drew_mesh_as_compute`).

Tests: mesh_out_parts_keep_their_elements_beside_their_offsets (fails
without the fix), the_mesh_sink_slot_draws_nothing (GPU; the test
harness's Draw takes an instance count).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both callers are in leonida-shader; a public constructor taking a
crate-private type set off private_interfaces.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The commands the mesh fallback records between and after the pipelines the
draw path binds (barriers, the dispatch or counted indirect dispatch, the
header of the indirect draw, the triangle list drawn from the buffer, the
title's topology again) move from draw.rs into mesh_fallback::MeshRun, which
draw.rs calls. A test records the same commands on a device of its own,
as a title does in one list: a counted indirect run (count 1), a direct run
of three groups, a run whose triangle is culled, a counted indirect run with
a count of 0, then the title's triangle strip; every texel comes out as the
runs and the strip draw it. Without the topology restored the strip draws
one triangle (64 texels differ); without the header's instance count reset
the count-0 run draws the first run's groups again (100 differ).

leonida-shader's host checks (emit::host) take the test programs this needs:
triangle_mesh_program (the triangle mesh program its own tests used),
color_ps and position_vs; dxbc::build is there for them too. draw.rs
names its topology mapping (host_topology).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: draw.rs (the signature is an Option for the mesh fallback, and
main reads mesh_test() once per dispatch: the fallback takes that mode too),
emit/mod.rs (both sets of exports; main's pixel mask test with the mesh test
programs from emit::host). Main's new test initializers take the fields this
branch adds (Parts::mesh_compute, Draw::vertex_count/instances,
HostShader::mesh_out).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The mesh, colour and position programs 924b29417 put in emit::host are
needed by portable tests too (primitive_export_indices_drop_the_edge_flags),
and emit::host is Windows-only: the Linux test build did not resolve them.
They need no device, so they live in emit::test_programs, built for tests
and the host feature on every platform.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's Shader gained mask and masked_twins (the sample mask's pixel shader
twins); the mesh program seen as compute and its pass-through vertex shader
are the title's own forms: no mask, no twins yet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts kept both sides: main's inline ray tracing, amplification stage, mesh_counts and
nvidia settings stay beside the PR's mesh compute fallback. host_settings() has a sixth word
for the fallback; the shader cache record writes the mesh layout, then main's optional ray
query record; HostShader, Parts and Draw literals in tests take the fields of both sides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 12:52:51 +00:00
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-02 15:01 UTC · original

Ran natively on Windows 11, head 016c7765b merged into current main (69cd4106c, 98 commits past the carry's base; git merge --no-ff clean, no conflict). Debug build, Rust from rust-toolchain.toml, --locked. Synthetic fixtures only, no game data.

One gap the carry introduces: LEONIDA_MESH_COUNTS=1 together with the compute fallback

mesh_counts.rs (main's LEONIDA_MESH_COUNTS, off by default) is not on #2580's head; it meets the fallback for the first time in this merge. With both on, a mesh program translated as compute still gets the mesh-only DXIL ops:

  • in lower.rs the plan is made whenever mesh_counts::on(), whatever x.mesh_compute says;
  • mesh_prologue then returns early (if self.mesh_counts.is_some()) before the compute branch, so the header's instance-count atomic is not emitted (read from the code, not run: an indirect run would then draw 0 instances);
  • own_mesh_counts emits setMeshOutputCounts and emitIndices unconditionally.

Throwaway test (the mesh(prims, own) fixture of mesh_counts::tests with TEST_MESH_COMPUTE = Some(true)), checked with dxil.dll:

Counts switch Requested primitives dxil.dll on the cs_6_6 WARP CreateComputePipelineState
off 0 / 1 / 3 valid made
on 0 / 1 / 3 invalid: "Opcode SetMeshOutputCounts not valid in shader model cs_6_6", same for EmitIndices made anyway
on, with && !x.mesh_compute added to the mesh_counts::on() check in lower.rs 0 / 1 / 3 valid made

WARP created the pipeline from the invalid module; I did not trace whether the runtime validates a translation before it gets there, and I did not feed it to the card. It needs an opt-in switch plus a card without mesh shaders (or LEONIDA_MESH_COMPUTE=1), so it is not blocking for default runs, but in that combination every mesh program that gets a counts plan comes out wrong. The one-line guard above is the smallest fix I found; it means the fallback ignores the program's own counts and keeps the declared maxima, as it does today with the switch off. Carrying the counts into the compute layout would be a separate change.

Also checked with the throwaway: LEONIDA_MESH_AMPLIFY's payload (MESH_PAYLOAD_HERE) with the compute variant validates, and the runtime cannot reach the amplification branch on this path (the fallback's graphics pipeline is built from vertex and pixel stages, so amplify is None).

Edge case: declared maxima above the lane count

Throwaway copy of a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws with the 32-lane triangle program declaring 256 vertices and 256 primitives:

Device Compute + pass-through VS vs native mesh pipeline
card (native mesh shaders) texel for texel equal
WARP texel for texel equal

Debug layer on the PR's device tests

LEONIDA_D3D12_DEBUG=1, with the info queue read at the end of each device iteration (throwaway lines, removed afterwards; the queue was present, so the layer was on):

Test Card WARP
a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws 0 errors, 0 warnings 0 errors, 0 warnings
mesh_fallback::tests::mesh_runs_in_one_list_… (passes) 25 errors, 1 warning 25 errors, 1 warning

The 25 errors in the recorder test come from the test's own root signatures, not from MeshRun as the runtime uses it:

  • 18 × "SetDescriptorHeaps must be called … before setting a root signature with …HEAP_DIRECTLY_INDEXED" (the test never binds heaps);
  • 4 × SetGraphicsRootShaderResourceView: the mesh buffer in NON_PIXEL_SHADER_RESOURCE (or | INDIRECT_ARGUMENT) "is invalid for use as a root shader resource", missing PIXEL_SHADER_RESOURCE;
  • 3 × Dispatch / ExecuteIndirect: the buffer "is bound as DATA_STATIC_WHILE_SET_AT_EXECUTE … and had a change to a writable state" (the previous run's root SRV still points at it).

The last two kinds exist because the harness (emit::host) declares root descriptors with D3D12_ROOT_DESCRIPTOR_FLAG_NONE, which for an SRV means static-while-set-at-execute. The runtime's root signatures (pipeline/host.rs) declare them DATA_VOLATILE, so those checks should not fire there; I did not run the draw path under the layer to confirm. Suggestion: declare the test's root descriptors DATA_VOLATILE and bind a heap, so this test can serve as a clean debug-layer check of the recorder.

Suites on the merge (clean tree)

Run Result
leonida-gpu --features diagnostics --lib 777 passed, 1 failed, 59 ignored: timeline::report::tests::real_waits_are_recorded_with_who_ended_them ("no entry found for key"), which passed 3/3 alone (timing under a loaded machine, not mesh code)
same, LEONIDA_MESH_COMPUTE=1 LEONIDA_D3D12_DEBUG=1, card 778 passed, 0 failed, 59 ignored
same, LEONIDA_MESH_COMPUTE=1 LEONIDA_D3D12_DEBUG=1 LEONIDA_D3D12_WARP=1 777 passed, 1 failed (the same timeline test, passes alone)
leonida-shader --lib 432 passed, 0 failed, 6 ignored (--test-threads=2). A first run at the default thread count ended in an access violation (0xc0000005) after 142 tests, while other GPU jobs shared the machine; the PR's mesh tests had not run yet in it. It did not recur in one rerun at --test-threads=2; not rerun at the default count, not tried on main
cargo clippy --all-targets -p leonida-shader -p leonida-gpu 0 errors; 16 warnings, none on a line this PR changes

Note on the forced runs: the counts match the unforced run, and I found no test in the leonida-gpu lib suite that reaches HostPipeline::mesh_compute or draw.rs's mesh_as_compute / mesh_indirect_as_compute (their only callers are the runtime's pipeline and draw paths), so the switch probably changes little there. The device coverage of the runtime side is the MeshRun recorder test; the bind and root-argument steps in draw.rs around it are covered only in game.

Not checked: a card without mesh shaders, the game, a mesh program whose outputs pass 32 KiB (where the mesh path lowers the maxima and the fallback keeps them), stale primitives in a reused mesh buffer beyond the recorder test's culled run (the shader-crate comparison uploads a fresh buffer), the multi-record indirect case (left out by design), dispatches past 65,535 groups or past groups_cap() beyond the existing sink test, and mesh programs reading group ids other than x.

GPUs tested: one NVIDIA desktop card + WARP.

AI-assisted: yes (Claude Code).

**@⁠Kal0s-design** on GitHub · 2026-12-02 15:01 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#issuecomment-7349559514) Ran natively on Windows 11, head `016c7765b` merged into current `main` (`69cd4106c`, 98 commits past the carry's base; `git merge --no-ff` clean, no conflict). Debug build, Rust from `rust-toolchain.toml`, `--locked`. Synthetic fixtures only, no game data. ### One gap the carry introduces: `LEONIDA_MESH_COUNTS=1` together with the compute fallback `mesh_counts.rs` (main's `LEONIDA_MESH_COUNTS`, off by default) is not on #2580's head; it meets the fallback for the first time in this merge. With both on, a mesh program translated as compute still gets the mesh-only DXIL ops: - in `lower.rs` the plan is made whenever `mesh_counts::on()`, whatever `x.mesh_compute` says; - `mesh_prologue` then returns early (`if self.mesh_counts.is_some()`) before the compute branch, so the header's instance-count atomic is not emitted (read from the code, not run: an indirect run would then draw 0 instances); - `own_mesh_counts` emits `setMeshOutputCounts` and `emitIndices` unconditionally. Throwaway test (the `mesh(prims, own)` fixture of `mesh_counts::tests` with `TEST_MESH_COMPUTE = Some(true)`), checked with dxil.dll: | Counts switch | Requested primitives | dxil.dll on the `cs_6_6` | WARP `CreateComputePipelineState` | |---|---|---|---| | off | 0 / 1 / 3 | valid | made | | on | 0 / 1 / 3 | **invalid**: "Opcode SetMeshOutputCounts not valid in shader model cs_6_6", same for EmitIndices | made anyway | | on, with `&& !x.mesh_compute` added to the `mesh_counts::on()` check in `lower.rs` | 0 / 1 / 3 | valid | made | WARP created the pipeline from the invalid module; I did not trace whether the runtime validates a translation before it gets there, and I did not feed it to the card. It needs an opt-in switch plus a card without mesh shaders (or `LEONIDA_MESH_COMPUTE=1`), so it is not blocking for default runs, but in that combination every mesh program that gets a counts plan comes out wrong. The one-line guard above is the smallest fix I found; it means the fallback ignores the program's own counts and keeps the declared maxima, as it does today with the switch off. Carrying the counts into the compute layout would be a separate change. Also checked with the throwaway: `LEONIDA_MESH_AMPLIFY`'s payload (`MESH_PAYLOAD_HERE`) with the compute variant validates, and the runtime cannot reach the amplification branch on this path (the fallback's graphics pipeline is built from vertex and pixel stages, so `amplify` is `None`). ### Edge case: declared maxima above the lane count Throwaway copy of `a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws` with the 32-lane triangle program declaring 256 vertices and 256 primitives: | Device | Compute + pass-through VS vs native mesh pipeline | |---|---| | card (native mesh shaders) | texel for texel equal | | WARP | texel for texel equal | ### Debug layer on the PR's device tests `LEONIDA_D3D12_DEBUG=1`, with the info queue read at the end of each device iteration (throwaway lines, removed afterwards; the queue was present, so the layer was on): | Test | Card | WARP | |---|---|---| | `a_mesh_program_run_as_compute_draws_what_the_mesh_pipeline_draws` | 0 errors, 0 warnings | 0 errors, 0 warnings | | `mesh_fallback::tests::mesh_runs_in_one_list_…` (passes) | 25 errors, 1 warning | 25 errors, 1 warning | The 25 errors in the recorder test come from the test's own root signatures, not from `MeshRun` as the runtime uses it: - 18 × "SetDescriptorHeaps must be called … before setting a root signature with `…HEAP_DIRECTLY_INDEXED`" (the test never binds heaps); - 4 × `SetGraphicsRootShaderResourceView`: the mesh buffer in `NON_PIXEL_SHADER_RESOURCE` (or `| INDIRECT_ARGUMENT`) "is invalid for use as a root shader resource", missing `PIXEL_SHADER_RESOURCE`; - 3 × `Dispatch` / `ExecuteIndirect`: the buffer "is bound as DATA_STATIC_WHILE_SET_AT_EXECUTE … and had a change to a writable state" (the previous run's root SRV still points at it). The last two kinds exist because the harness (`emit::host`) declares root descriptors with `D3D12_ROOT_DESCRIPTOR_FLAG_NONE`, which for an SRV means static-while-set-at-execute. The runtime's root signatures (`pipeline/host.rs`) declare them `DATA_VOLATILE`, so those checks should not fire there; I did not run the draw path under the layer to confirm. Suggestion: declare the test's root descriptors `DATA_VOLATILE` and bind a heap, so this test can serve as a clean debug-layer check of the recorder. ### Suites on the merge (clean tree) | Run | Result | |---|---| | `leonida-gpu --features diagnostics --lib` | 777 passed, 1 failed, 59 ignored: `timeline::report::tests::real_waits_are_recorded_with_who_ended_them` ("no entry found for key"), which passed 3/3 alone (timing under a loaded machine, not mesh code) | | same, `LEONIDA_MESH_COMPUTE=1 LEONIDA_D3D12_DEBUG=1`, card | 778 passed, 0 failed, 59 ignored | | same, `LEONIDA_MESH_COMPUTE=1 LEONIDA_D3D12_DEBUG=1 LEONIDA_D3D12_WARP=1` | 777 passed, 1 failed (the same timeline test, passes alone) | | `leonida-shader --lib` | 432 passed, 0 failed, 6 ignored (`--test-threads=2`). A first run at the default thread count ended in an access violation (0xc0000005) after 142 tests, while other GPU jobs shared the machine; the PR's mesh tests had not run yet in it. It did not recur in one rerun at `--test-threads=2`; not rerun at the default count, not tried on `main` | | `cargo clippy --all-targets -p leonida-shader -p leonida-gpu` | 0 errors; 16 warnings, none on a line this PR changes | Note on the forced runs: the counts match the unforced run, and I found no test in the `leonida-gpu` lib suite that reaches `HostPipeline::mesh_compute` or `draw.rs`'s `mesh_as_compute` / `mesh_indirect_as_compute` (their only callers are the runtime's pipeline and draw paths), so the switch probably changes little there. The device coverage of the runtime side is the `MeshRun` recorder test; the bind and root-argument steps in `draw.rs` around it are covered only in game. Not checked: a card without mesh shaders, the game, a mesh program whose outputs pass 32 KiB (where the mesh path lowers the maxima and the fallback keeps them), stale primitives in a reused mesh buffer beyond the recorder test's culled run (the shader-crate comparison uploads a fresh buffer), the multi-record indirect case (left out by design), dispatches past 65,535 groups or past `groups_cap()` beyond the existing sink test, and mesh programs reading group ids other than x. GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
D3D12-MESH-COMPUTE-FALLBACK review fix (#3128):

- emit/lower.rs: the mesh counts plan (LEONIDA_MESH_COUNTS=1) was made
  whatever x.mesh_compute said, so a mesh program translated as cs_6_6
  got setMeshOutputCounts and emitIndices (invalid there per dxil.dll)
  and mesh_prologue returned before the compute branch, skipping the
  header's instance-count write. No plan is made as compute; the compute
  layout keeps the declared maxima, as with the switch off.
- emit/mesh_counts.rs: as_compute_the_program_keeps_the_maxima checks the
  compute module is byte-identical with the switch on and off for 0/1/3
  requested primitives (and validates it where dxil.dll is present). The
  mesh() fixture is no longer Windows-only so the check runs everywhere.
- d3d12/docs/switches.md: regenerated (tools/d3d12_switches.py); the PR's
  LEONIDA_MESH_COMPUTE was missing, failing tests/test_d3d12_switches.py
  in the check and linux-python-and-viewer jobs. host.rs's comment now
  says what the switch does on its own, as the page quotes it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DDMsHuc6uzQ89RckiuWwc9
main had edited d3d12/docs/switches.md too; the generated page is made
again with tools/d3d12_switches.py on the merge (683 names).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DDMsHuc6uzQ89RckiuWwc9
Author
Owner

@⁠fiestorra on GitHub · 2026-12-03 00:27 UTC · original

VERIFY-3128 — parcial, y el tamaño es la noticia: 9 commits, 31 ficheros, +2129

Own commits 9 (b3fd0c857 head) — mesh programs, the fallback's shaders, emit::test_programs, …
Size 31 files changed, 2129 insertions, 142 deletions

Ran at the head

cargo test -p leonida-gpu --lib mesh     2 passed; 0 failed

That is what passed, and it is not enough to call this verified. A nine-commit branch that touches 31 files cannot be reviewed as one pull request, and the honest statement is: the mesh filter is green, and I have not read 2 129 added lines.

What I did read, from the commit messages, is the shape:

  • b3fd0c857 — mesh programs run as compute keep the maxima under LEONIDA_MESH_COUNTS: a count cap, which is the kind of thing that either holds or silently drops the last workgroup.
  • 74ac98c64 — the mesh fallback's shaders take main's sample-mask fields: a merge of main's change into a branch that had its own copy — the classic way for a stack to lose a fix.
  • eab9c1e0f — emit::test_programs, built on every platform: a portability fix, which is what tonight's #3164 was missing.

And the process point, which is the same one I made in #2570 in the first hours: a branch that carries nine commits should be nine pull requests, or one pull request with Depends on: #n for each of the others. As it stands, a reviewer who says "no" to one commit says no to all nine, and the merge queue sees one 31-file item where it should see a stack.

#3247 landed on main while I was writing this (d5b30be1c), and main is still green (cargo test -p leonida-lua → 47 passed) — so this branch's rebase is against a moving but healthy base.

What I could not test

  • The other 29 files: their tests, their behaviour. This is a partial verification and I am labelling it as one.

Written with an AI assistant.

**@⁠fiestorra** on GitHub · 2026-12-03 00:27 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#issuecomment-7363207664) ## VERIFY-3128 — parcial, y el tamaño es la noticia: **9 commits, 31 ficheros, +2129** | | | |---|---| | Own commits | 9 (`b3fd0c857` head) — `mesh` programs, the fallback's shaders, `emit::test_programs`, … | | Size | **31 files changed, 2129 insertions, 142 deletions** | **Ran at the head** ``` cargo test -p leonida-gpu --lib mesh 2 passed; 0 failed ``` **That is what passed, and it is not enough to call this verified.** **A nine-commit branch that touches 31 files cannot be reviewed as one pull request**, **and the honest statement is: the mesh filter is green, and I have not read 2 129 added lines.** **What I did read, from the commit messages, is the shape**: - `b3fd0c857` — **mesh programs run as compute keep the maxima under `LEONIDA_MESH_COUNTS`**: **a count cap, which is the kind of thing that either holds or silently drops the last workgroup.** - `74ac98c64` — **the mesh fallback's shaders take main's sample-mask fields**: **a merge of `main`'s change into a branch that had its own copy — the classic way for a stack to lose a fix.** - `eab9c1e0f` — **`emit::test_programs`, built on every platform**: **a portability fix, which is what tonight's `#3164` was missing.** **And the process point, which is the same one I made in #2570 in the first hours**: **a branch that carries nine commits should be nine pull requests, or one pull request with `Depends on: #n` for each of the others.** **As it stands, a reviewer who says "no" to one commit says no to all nine**, **and the merge queue sees one 31-file item where it should see a stack.** **#3247 landed on `main` while I was writing this** (`d5b30be1c`), and `main` is still green (`cargo test -p leonida-lua` → 47 passed) — **so this branch's rebase is against a moving but healthy base.** ## What I could not test - **The other 29 files**: their tests, their behaviour. **This is a partial verification and I am labelling it as one.** Written with an AI assistant.
Author
Owner

@⁠enlight3d on GitHub · 2026-12-03 01:06 UTC · original

RUN (in game, gate-style): head 32039d441 merged alone with git merge --no-ff onto main f3865cae8 (no conflict). Built with diagnostics,mimalloc, target x86_64-pc-windows-msvc. RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300). This card has mesh shaders, so the fallback only runs when forced with LEONIDA_MESH_COMPUTE=1; both were run with the same exe and the same save, each with a warm-up run first in a data folder of its own (the change touches the translator).

Launcher defaults except -PrecompileUsed (on this main the launcher's default precompiles every recorded pipeline, 88,671 here, which takes hours on a first start), Series S settings, -NoDlss -NoFrameGen, standing at the save, memory safety stop on, each run ended 330 s (default) or 300 s (fallback) after reaching the world:

default (switch absent) LEONIDA_MESH_COMPUTE=1
Mesh programs run as compute no (mesh=true forced=false) yes (mesh=true forced=true)
Reached the world 72 s 73 s
Time in the world 332 s 302 s
Device losses 0 0
Crashes 0 0
Frame median 32.9 ms (30.4 fps rendered) 90.8 ms (10.8 fps)
Card busy 91 % 100 %
Private memory, max 28.0 GB 29.3 GB

Fallback forced on a card with mesh shaders: 90.8 ms vs 32.9 ms a frame (same exe, same save). The warm-ups gave the same picture (94.0 vs 38.7 ms), and with the fallback the frame stays at 90-95 ms in every minute in the world, so this is the cost of the path itself (the card is at 100 %), not compilation still going on. It is the fallback's price on a card that does not need it; on the cards it is meant for (no mesh shaders) the comparison is with a world that drew nothing.

The fallback draws. 834 mesh pipelines were made as a compute program and a triangle list in the measured run (822 in its warm-up), and none was refused: no "no host pipeline" line in either run. Window snapshots at 150, 250 and 350 s after the start (all in the world) show the same scene in both, all its geometry and characters present, with no empty screen and no broken or stretched triangles. The differences between the two are animation timing (moving characters are elsewhere at the same second) and a shadow on the left wall that shows in the three fallback snapshots and in none of the three default ones; another run of this main without the switch shows that same shadow at a later moment, so it looks like a scene shadow that comes and goes, but the timing was not matched to settle it. Frames saved by frame number (up to 4096 with the fallback) fall at different moments at 10 and 30 fps and were not compared.

Warnings: the default run printed only kinds that a run of the same main with nine other pull requests printed too, in about the same numbers. The fallback run printed one kind more, 4 times: "a placed texture view lies in the memory of a texture the host copied into: it is filled from title memory, which the copy never reached". It is absent from the default run, both warm-ups and the other batch. Both runs have the same 29 "creation method that is not implemented" lines as main.

Verdict: PASS. With the switch absent nothing changes on this card: mesh programs are not run as compute, and there is no new warning or failure. Forced on, the fallback draws the world correctly, with no device loss, crash or refused pipeline, at the cost given above. Not covered here: a card without mesh shaders (Pascal and older, the case it is for), -RayTracing, DLSS and frame generation, Wine/Proton.

AI-assisted: Claude Code (Claude Opus 5.5)

**@⁠enlight3d** on GitHub · 2026-12-03 01:06 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#issuecomment-7363961664) RUN (in game, gate-style): head 32039d441 merged alone with `git merge --no-ff` onto `main` f3865cae8 (no conflict). Built with `diagnostics,mimalloc`, target `x86_64-pc-windows-msvc`. RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro (build 26300). This card has mesh shaders, so the fallback only runs when forced with `LEONIDA_MESH_COMPUTE=1`; both were run with the same exe and the same save, each with a warm-up run first in a data folder of its own (the change touches the translator). Launcher defaults except `-PrecompileUsed` (on this `main` the launcher's default precompiles every recorded pipeline, 88,671 here, which takes hours on a first start), Series S settings, `-NoDlss -NoFrameGen`, standing at the save, memory safety stop on, each run ended 330 s (default) or 300 s (fallback) after reaching the world: | | default (switch absent) | `LEONIDA_MESH_COMPUTE=1` | |---|---|---| | Mesh programs run as compute | no (`mesh=true forced=false`) | yes (`mesh=true forced=true`) | | Reached the world | 72 s | 73 s | | Time in the world | 332 s | 302 s | | Device losses | 0 | 0 | | Crashes | 0 | 0 | | Frame median | 32.9 ms (30.4 fps rendered) | 90.8 ms (10.8 fps) | | Card busy | 91 % | 100 % | | Private memory, max | 28.0 GB | 29.3 GB | **Fallback forced on a card with mesh shaders: 90.8 ms vs 32.9 ms a frame (same exe, same save).** The warm-ups gave the same picture (94.0 vs 38.7 ms), and with the fallback the frame stays at 90-95 ms in every minute in the world, so this is the cost of the path itself (the card is at 100 %), not compilation still going on. It is the fallback's price on a card that does not need it; on the cards it is meant for (no mesh shaders) the comparison is with a world that drew nothing. **The fallback draws.** 834 mesh pipelines were made as a compute program and a triangle list in the measured run (822 in its warm-up), and none was refused: no "no host pipeline" line in either run. Window snapshots at 150, 250 and 350 s after the start (all in the world) show the same scene in both, all its geometry and characters present, with no empty screen and no broken or stretched triangles. The differences between the two are animation timing (moving characters are elsewhere at the same second) and a shadow on the left wall that shows in the three fallback snapshots and in none of the three default ones; another run of this `main` without the switch shows that same shadow at a later moment, so it looks like a scene shadow that comes and goes, but the timing was not matched to settle it. Frames saved by frame number (up to 4096 with the fallback) fall at different moments at 10 and 30 fps and were not compared. Warnings: the default run printed only kinds that a run of the same `main` with nine other pull requests printed too, in about the same numbers. The fallback run printed one kind more, 4 times: "a placed texture view lies in the memory of a texture the host copied into: it is filled from title memory, which the copy never reached". It is absent from the default run, both warm-ups and the other batch. Both runs have the same 29 "creation method that is not implemented" lines as `main`. Verdict: **PASS**. With the switch absent nothing changes on this card: mesh programs are not run as compute, and there is no new warning or failure. Forced on, the fallback draws the world correctly, with no device loss, crash or refused pipeline, at the cost given above. Not covered here: a card without mesh shaders (Pascal and older, the case it is for), `-RayTracing`, DLSS and frame generation, Wine/Proton. AI-assisted: Claude Code (Claude Opus 5.5)
Author
Owner

@⁠merzleckeier on GitHub · 2026-12-03 01:23 UTC · original · reviewed

I checked 32039d441 merged onto main at 1a163523. The unmodified as_compute_the_program_keeps_the_maxima test passes in the Windows MSVC build under Wine 11.22.

I also ran a disposable probe that requires the DXIL validator from DXC 1.8.2505.1 to load. For 0, 1 and 3 requested primitives, the current compute DXIL was byte-identical with mesh counts on and off, and the validator accepted both forms. Making only the old counts-plan condition selectable in the probe reproduced SetMeshOutputCounts and EmitIndices rejection in cs_6_6 for all three counts. The PR's own regression test also failed with that condition restored.

Merge-order detail for #3270: both changes merge textually, but their resulting catalog has 684 runtime rows and a 683-name header. The new --check catches that combination. Regenerating on the combined tree updates the header to 684, refreshes the LEONIDA_FG_WITH_RT generated marker, and passes --check and all 21 switch tests. These were synthetic checks. AI-assisted with OpenAI Codex.

**@⁠merzleckeier** on GitHub · 2026-12-03 01:23 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#pullrequestreview-6162081092) · **reviewed** I checked `32039d441` merged onto `main` at `1a163523`. The unmodified `as_compute_the_program_keeps_the_maxima` test passes in the Windows MSVC build under Wine 11.22. I also ran a disposable probe that requires the DXIL validator from DXC 1.8.2505.1 to load. For 0, 1 and 3 requested primitives, the current compute DXIL was byte-identical with mesh counts on and off, and the validator accepted both forms. Making only the old counts-plan condition selectable in the probe reproduced `SetMeshOutputCounts` and `EmitIndices` rejection in `cs_6_6` for all three counts. The PR's own regression test also failed with that condition restored. Merge-order detail for #3270: both changes merge textually, but their resulting catalog has 684 runtime rows and a 683-name header. The new `--check` catches that combination. Regenerating on the combined tree updates the header to 684, refreshes the `LEONIDA_FG_WITH_RT` generated marker, and passes `--check` and all 21 switch tests. These were synthetic checks. AI-assisted with OpenAI Codex.
d3d12/docs/switches.md regenerated with tools/d3d12_switches.py after the merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01DDMsHuc6uzQ89RckiuWwc9
Author
Owner

@⁠OreoFR on GitHub · 2026-12-03 10:14 UTC · original

RUN #3128 — in-game, 300 s walking in the world, RTX 4070 Laptop 8 GB

Verified by OreoFR

  • Base: main d9b618f10. Head tested: 879604d4d, merged --no-ff into that main.
  • GPU: RTX 4070 Laptop 8 GB, driver 621.40, Windows 11, diag build (build-nvidia.ps1).
  • Settings: -SeriesS -NoDlss -NoFrameGen, LEONIDA_WINDOWS_BAR_MB=0, LEONIDA_TEXTURE_BUDGET_MB=1024.
  • Same walker for every run: menus, lift, then W with J/L turns.
  • Order: A B A B in one session. LEONIDA_MESH_COMPUTE was unset, so the 4070 keeps its native mesh shaders. No mesh-fallback line appears in any log.

Every row is the last 240 s in the world.

run build fps median ms >100 ms >1 s device lost / removed crash
A1 (cold) PR 24.5 37.9 16 3 0 / 0 no
B1 main 28.4 33.8 5 0 0 / 0 no
A2 (warm) PR 25.8 36.5 14 2 0 / 0 no
B2 main 28.2 33.9 4 0 0 / 0 no

Stability: PASS.

  • No device loss, reset, panic or error line in any run.
  • The picture is correct; I compared screenshots at +150 s and +290 s and did not post them.
  • Both builds close cleanly.

Performance: slower with the PR, MEASURED n=2, PROVISIONAL.

  • On the warm pair, the PR runs about 9 % slower: 25.8 fps against 28.2-28.4, and the median rises by about 2.6 ms.
  • It also has 3-4 times as many frames over 100 ms, plus 1 s stalls that main does not have (the longest was 5.2 s in A2).
  • The mean draws per frame are close: 3 440 for A2 against 3 230-3 280 for main.
  • On the cold first start, the PR retranslated every shader: 1 649 s to reach the world, against 363 s for main from the same caches. So the translation changes on every card, not only on cards without mesh shaders.
  • That points at the translator changes in leonida-shader/src/emit/*, which reach every card. This is a hypothesis and not bisected.

Safe to merge into main? Not yet.

  1. git merge-tree against current main: clean.
  2. CI on 879604d4d: all 6 jobs green.
  3. Off by default: no. With LEONIDA_MESH_COMPUTE unset, the 4070 still gets a different shader translation (it retranslates on first start), and it is about 9 % slower than main.
  4. Repo checks: covered by CI (d3d12 Windows job, no-game-data). I did not rerun them locally.
  5. Scope: the diff reaches the shader emitter that every card uses, not only the fallback path.

A suggestion: keep the emitter output byte-identical when the fallback is off, then re-run the A/B. A per-commit bisect of the emit/ changes would also show which one costs the frames. I can run the A/B again on a new head.

AI-assisted (oreofr-agent, Claude Code), run on OreoFR's machine.

**@⁠OreoFR** on GitHub · 2026-12-03 10:14 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#issuecomment-7374936677) ## RUN #3128 — in-game, 300 s walking in the world, RTX 4070 Laptop 8 GB **Verified by OreoFR** - **Base:** `main` d9b618f10. **Head tested:** 879604d4d, merged `--no-ff` into that main. - **GPU:** RTX 4070 Laptop 8 GB, driver 621.40, Windows 11, diag build (`build-nvidia.ps1`). - **Settings:** `-SeriesS -NoDlss -NoFrameGen`, `LEONIDA_WINDOWS_BAR_MB=0`, `LEONIDA_TEXTURE_BUDGET_MB=1024`. - **Same walker for every run:** menus, lift, then W with J/L turns. - **Order:** A B A B in one session. `LEONIDA_MESH_COMPUTE` was unset, so the 4070 keeps its native mesh shaders. No mesh-fallback line appears in any log. Every row is the last 240 s in the world. | run | build | fps | median ms | >100 ms | >1 s | device lost / removed | crash | |---|---|---|---|---|---|---|---| | A1 (cold) | PR | 24.5 | 37.9 | 16 | 3 | 0 / 0 | no | | B1 | main | 28.4 | 33.8 | 5 | 0 | 0 / 0 | no | | A2 (warm) | PR | 25.8 | 36.5 | 14 | 2 | 0 / 0 | no | | B2 | main | 28.2 | 33.9 | 4 | 0 | 0 / 0 | no | **Stability: PASS.** - No device loss, reset, panic or error line in any run. - The picture is correct; I compared screenshots at +150 s and +290 s and did not post them. - Both builds close cleanly. **Performance: slower with the PR, MEASURED n=2, PROVISIONAL.** - On the warm pair, the PR runs about 9 % slower: 25.8 fps against 28.2-28.4, and the median rises by about 2.6 ms. - It also has 3-4 times as many frames over 100 ms, plus 1 s stalls that main does not have (the longest was 5.2 s in A2). - The mean draws per frame are close: 3 440 for A2 against 3 230-3 280 for main. - On the cold first start, the PR retranslated every shader: 1 649 s to reach the world, against 363 s for main from the same caches. So the translation changes on every card, not only on cards without mesh shaders. - That points at the translator changes in `leonida-shader/src/emit/*`, which reach every card. This is a hypothesis and not bisected. **Safe to merge into main? Not yet.** 1. `git merge-tree` against current main: clean. 2. CI on 879604d4d: all 6 jobs green. 3. Off by default: **no**. With `LEONIDA_MESH_COMPUTE` unset, the 4070 still gets a different shader translation (it retranslates on first start), and it is about 9 % slower than main. 4. Repo checks: covered by CI (d3d12 Windows job, no-game-data). I did not rerun them locally. 5. Scope: the diff reaches the shader emitter that every card uses, not only the fallback path. A suggestion: keep the emitter output byte-identical when the fallback is off, then re-run the A/B. A per-commit bisect of the `emit/` changes would also show which one costs the frames. I can run the A/B again on a new head. AI-assisted (oreofr-agent, Claude Code), run on OreoFR's machine.
Author
Owner

@⁠upipibi on GitHub · 2026-12-03 17:12 UTC · original

A run on a real card without mesh shaders: AMD Radeon RX 580 (Polaris; mesh shader tier 0, highest shader model 6.7, 64-lane waves), driver 31.0.21927.4000, Windows 11, in the same PC as an RTX 3070 (621.40). Head 879604d4d as it is (it conflicts with current main), debug, --locked, synthetic tests only.

leonida-gpu honours LEONIDA_ADAPTER. leonida-shader's test Host always takes the high-performance adapter, so for these runs I patched it locally (not part of this PR) to take the card LEONIDA_ADAPTER names.

RX 580 RTX 3070
cargo test -p leonida-shader --lib mesh 19 passed, 0 failed ("hardware: the mesh program drew as compute (mesh shaders there: false)") —
cargo test -p leonida-gpu --lib mesh_fallback 0 passed, 1 failed, 5 of 5 runs 1 passed, 0 failed, 5 of 5 runs

The failure is mesh_runs_in_one_list_draw_their_own_groups_and_the_strip_after_them_its_strip: "128 of 256 texels differ, first (0, 0): got [1, 1, 0, 1], wanted [0, 1, 0, 1]". Step 4, the counted indirect run with count 0, draws yellow over the whole left half. On this driver, a counted ExecuteIndirect dispatch with a count of 0 still runs its record:

  • With the record at offset 12 set to (0, 0, 0) groups, the test passes, 3 of 3 runs.
  • A separate count buffer holding 0 at offset 0 still fails, 3 of 3, so it is not the count's offset.
  • WriteBufferImmediate in MARKER_OUT mode for the header still fails, 3 of 3.
  • The debug layer (LEONIDA_D3D12_DEBUG=1) reports nothing.

On such a card, then, a title's counted mesh dispatch whose count is 0 draws the record's groups anyway.

A workaround that passes on both cards: wrap the counted ExecuteIndirect in MeshRun::indirect in SetPredication(count buffer, offset, D3D12_PREDICATION_OP_EQUAL_ZERO) and clear it after. That gave 3 of 3 passes on the RX 580 and 3 of 3 on the 3070, with the debug layer silent. It works only because MeshRun::indirect asks for at most one command. Predication reads 64 bits at an 8-byte-aligned offset, so a real version would first copy the title's count dword into a zeroed 8-byte slot of ours and predicate on that. I measured this with the test's count buffer only (padded zeros).

For completeness, the whole suites on the RX 580 also fail tests that fail on main there too:

  • leonida-gpu: views_are_made_beside_the_heap_and_copied_in, the same as on #2995.
  • leonida-shader: 7 device tests (pack, permlane, ds_min/max_f32, LDS subtracts, a whole-wave f64 sum, a partial dispatch), the same 7 on main. All 7 are pipeline refusals ("The parameter is incorrect") of programs the translator declares with WaveSize(32) (emit/lower.rs:2595, :2773 on main 717b90233), which a card with only 64-lane waves cannot make (this one reports lanes 64 to 64). That is outside this PR. But it means the fallback alone won't make pre-RDNA AMD cards (Polaris, Vega) run the title. Pascal-era NVIDIA cards, whose waves are 32 lanes, don't have this problem.

Tested with the help of Claude Code (Claude Opus 5.5).

**@⁠upipibi** on GitHub · 2026-12-03 17:12 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3128#issuecomment-7386150253) A run on a real card without mesh shaders: **AMD Radeon RX 580** (Polaris; mesh shader tier 0, highest shader model 6.7, 64-lane waves), driver 31.0.21927.4000, Windows 11, in the same PC as an RTX 3070 (621.40). Head `879604d4d` as it is (it conflicts with current `main`), debug, `--locked`, synthetic tests only. `leonida-gpu` honours `LEONIDA_ADAPTER`. `leonida-shader`'s test `Host` always takes the high-performance adapter, so for these runs I patched it locally (not part of this PR) to take the card `LEONIDA_ADAPTER` names. | | RX 580 | RTX 3070 | |---|---|---| | `cargo test -p leonida-shader --lib mesh` | 19 passed, 0 failed ("hardware: the mesh program drew as compute (mesh shaders there: false)") | — | | `cargo test -p leonida-gpu --lib mesh_fallback` | **0 passed, 1 failed**, 5 of 5 runs | 1 passed, 0 failed, 5 of 5 runs | The failure is `mesh_runs_in_one_list_draw_their_own_groups_and_the_strip_after_them_its_strip`: "128 of 256 texels differ, first (0, 0): got [1, 1, 0, 1], wanted [0, 1, 0, 1]". Step 4, the counted indirect run with count 0, draws yellow over the whole left half. **On this driver, a counted `ExecuteIndirect` dispatch with a count of 0 still runs its record:** - With the record at offset 12 set to (0, 0, 0) groups, the test passes, 3 of 3 runs. - A separate count buffer holding 0 at offset 0 still fails, 3 of 3, so it is not the count's offset. - `WriteBufferImmediate` in `MARKER_OUT` mode for the header still fails, 3 of 3. - The debug layer (`LEONIDA_D3D12_DEBUG=1`) reports nothing. On such a card, then, a title's counted mesh dispatch whose count is 0 draws the record's groups anyway. A workaround that passes on both cards: wrap the counted `ExecuteIndirect` in `MeshRun::indirect` in `SetPredication(count buffer, offset, D3D12_PREDICATION_OP_EQUAL_ZERO)` and clear it after. That gave 3 of 3 passes on the RX 580 and 3 of 3 on the 3070, with the debug layer silent. It works only because `MeshRun::indirect` asks for at most one command. Predication reads 64 bits at an 8-byte-aligned offset, so a real version would first copy the title's count dword into a zeroed 8-byte slot of ours and predicate on that. I measured this with the test's count buffer only (padded zeros). For completeness, the whole suites on the RX 580 also fail tests that fail on `main` there too: - `leonida-gpu`: `views_are_made_beside_the_heap_and_copied_in`, the same as on #2995. - `leonida-shader`: 7 device tests (pack, permlane, `ds_min/max_f32`, LDS subtracts, a whole-wave f64 sum, a partial dispatch), the same 7 on `main`. All 7 are pipeline refusals ("The parameter is incorrect") of programs the translator declares with `WaveSize(32)` (`emit/lower.rs:2595`, `:2773` on `main` `717b90233`), which a card with only 64-lane waves cannot make (this one reports lanes 64 to 64). That is outside this PR. But it means the fallback alone won't make pre-RDNA AMD cards (Polaris, Vega) run the title. Pascal-era NVIDIA cards, whose waves are 32 lanes, don't have this problem. *Tested with the help of Claude Code (Claude Opus 5.5).*
This pull request has changes conflicting with the target branch.
  • d3d12/crates/leonida-shader/src/emit/lower.rs
  • d3d12/docs/switches.md
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3128/head:github-bot/gh-3128'
git switch 'github-bot/gh-3128'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3128'
git switch 'github-bot/gh-3128'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3128'
git switch 'github-bot/gh-3128'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3128'
git switch 'main'
git merge --squash 'github-bot/gh-3128'
git switch 'main'
git merge --ff-only 'github-bot/gh-3128'
git switch 'main'
git merge 'github-bot/gh-3128'
git push origin 'main'
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/ubiquitarianism--leonida!3128
No description provided.