Skip to content

D3D12.X: draw eligible console mesh programs as native mesh shaders behind XCL_NATIVE_MESH - #3327

Draft
KDenKC wants to merge 3 commits into
xcl-dev:mainfrom
KDenKC:native-mesh-c4
Draft

KDenKC wants to merge 3 commits into
xcl-dev:mainfrom
KDenKC:native-mesh-c4

Conversation

@KDenKC

@KDenKC KDenKC commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Part of C4 in #3011. In our RTX 5090 measurements, two-pass mesh work took about 40–48% of GPU frame time. This adds an experimental native mesh path that avoids the separate NGG compute pass, record buffer and inter-pass barrier for eligible draws. Enable it with XCL_NATIVE_MESH=1. The default is off.

Rebased onto main 6bfb5c51; the head is now 1e65e6a2 (was 427330b5). One conflict, in real.rs (translated_mesh_stream_once): main now takes the render-target formats from stream_rt_formats earlier in that function and dropped the inline block that read them; this PR's only line there, let state_start = out.0.len();, is kept and the old block is not brought back. The other two commits rebased without changes.

A native wave64 translator from Kalmarv will follow as a PR stacked on this one.

What is in it

  • 511d4d01 (was c943d157) adds the native entry in gpu/recomp/native_mesh.rs and emit.rs. It reuses XCL's instruction lowering for a single 32-lane hardware wave with lane-owned triangle vertices and primitives, supported exports and bounded output. gpu/recomp/pso.rs compiles the candidate. The GPU fixture in gpu/recomp/tests.rs compares native and two-pass pixels.
  • 39a39796 (was bf7f7e82) adds the optional native PSO in hle/d3d12x/real.rs. D3D12 must accept the mesh and pixel signatures together. Unsupported programs and rejected native PSOs fall back to the existing two-pass PSO.
  • hle/d3d12x/bind.rs records one native DispatchMesh for an eligible direct draw. Eligible plain mesh ExecuteIndirect keeps the existing GPU bounds pass and forwards the title's original count buffer to the native call. This slice changes the HLSL translator source identity, so affected HLSL cache entries rebuild once.

Tested

At the rebased head 1e65e6a2, RTX 5090 32 GB, driver 621.40, Ryzen 7 9800X3D, Windows 11 Pro build 26200.9974, Rust 1.99.1, debug: cargo build --workspace passed; cargo test -p xcl --lib -- native_mesh --nocapture --test-threads=4: 3 passed, 0 failed, 0 skipped (gpu_native_mesh_matches_two_pass, gpu_native_mesh_indirect_preserves_legal_dimensions, native_mesh_output_budget_includes_alignment_and_row_limit); -- mesh: 60 passed, 0 failed.

At 1e65e6a2 on the RTX 3090 VM (NVIDIA 621.24, Intel Core i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, debug), against main 6bfb5c51 on the same machine: cargo test --workspace --no-fail-fast -- --test-threads=4: 2894 passed, 5 failed, 51 ignored (main: 2891 passed, 5 failed, 51 ignored; the 3 more are this PR's native_mesh tests). The same 5 failures on both, main's own: title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3 stream_recheck_* tests, e2e test_title_runs_and_game_folder_is_untouched. SKIPPED: 11 on both (7 no wave64, 3 no debug layer, 1 no heap windows). On both commits the lib binary died with an access violation in the 4-thread run, and its counts are from the runner's 1-thread rerun of it; the run leaves out the 3 uma_driver coherent-window remake tests, as above.

Before the rebase:

RTX 3090 VM, NVIDIA 621.24, Intel Core i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, DXC 1.9.2602.17. Tested at bf7f7e8296760f08b7387ab406f1b60814e1db2a, then the follow-up below at 427330b54638ce7eb7ee14e3b577087a4af4d6e9.

  • cargo build --workspace passed in debug.
  • cargo test -p xcl --lib --no-run and cargo test -p xcl --lib --release --no-run passed.
  • cargo test -p xcl --lib -- native_mesh --nocapture --test-threads=1 passed 2/2, with 0 skipped. The eligible triangle produced identical pixels on the native and two-pass paths. The ineligible fixture was rejected by the native entry and drew the same pixels through two passes.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 at 427330b5: 2603 passed, 5 failed, 49 ignored. SKIPPED: 30 (21 no wave64, 3 refused f16/f32 per-lane forms, 3 no debug layer, 2 no heap windows, 1 driver cache cannot be disabled). The run leaves out the 3 uma_driver coherent-window remake tests that kill the lib binary on 621.x. The 5 failures are main's own (they fail on main fa204595 on this machine): title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3 stream_recheck_* tests, e2e test_title_runs_and_game_folder_is_untouched.

Regression run

These blocks are from 427330b5, before the rebase; a pair on 1e65e6a2 follows when the RTX 5090 is free.

RTX 5090 32 GB, driver 621.24, Ryzen 7 9800X3D, the retail title, 200 s each, scripts/smoke.ps1 with preparation on (-Prep), normal priority and default worker counts, XCL_NATIVE_MESH unset (the native path off, as by default) in both runs. Both runs started from a copy of the same cache (made by an earlier run of main fa204595) and used this machine's usual settings (XCL_UMA_WINDOWS=16, XCL_UMA_DRIVER=mixed:1536:1792, XCL_COHERENT_MB=4095, XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_HUGE_PSO_CONCURRENCY=3). So this pair shows the default path unchanged, not the native path.

main fa204595:

xcl-smoke v1
commit: fa204595a488c60c6c5f905244f0172072c9c2a9
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2258 (PresentX 2258)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 34835 MB

this head 427330b5:

xcl-smoke v1
commit: 427330b54638ce7eb7ee14e3b577087a4af4d6e9
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2187 (PresentX 2187)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35964 MB
  • 1e65e6a2 (was 427330b5), the follow-up after review (triangle-index budget in the output check, legal multidimensional counts above 65,535 groups kept, rejected arguments reported through the existing feedback, native draws in the timing and watch logs): RTX 3090 VM, debug workspace build, cargo test -p xcl --lib --no-run debug and release, -- native_mesh: 3 passed, 0 failed, 0 skipped.

Not tested

No mesh program of the retail title is eligible yet: on an RTX 4090 all 171 that reached the preflight are wave64 groups of 128 threads with 128 vertices and 128 primitives (#3327 (comment)), and this slice takes one wave32 with one vertex and primitive per lane. So in the title it changes nothing even when switched on; the next slice (128-thread native groups) is needed for that. Also not tested: runtime indirect count handling, AMD, Intel, wave64/C2 interplay.

AI use

  • Claude Code (Claude Opus 5.5, Claude Sonnet 5.5), Codex (GPT-6.2-Sol), Antigravity (Gemini 4 Neon, Gemini 4 Hydrogen): an agent swarm wrote, tested, reviewed and described this change.

Generated with Claude Code

https://claude.ai/code/session_013oPUFCA9W9F8Qb5MPK33bR

@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Nov 29, 2026
KDenKC added a commit to KDenKC/xcl that referenced this pull request Nov 29, 2026
Checked: xcl-dev#3327, xcl-dev#3011 C4 and xcl-dev#2092. Budget primitive indices too. Keep legal indirect dimensions, reject over-limit arguments with the existing feedback, and distinguish native meshes in the GPU timestamps and watch ring.

Assisted-by: Codex (GPT-6.2-Sol)
@KDenKC
KDenKC marked this pull request as ready for review November 29, 2026 11:52
@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 29, 2026
@minimalhipster990

Copy link
Copy Markdown

Retail title on RTX 4090: no mesh program passes the native preflight at 427330b5. With XCL_NATIVE_MESH=1, all 176 mesh programs the title created in a 360 s run were logged as using two passes (requires one wave32 and at most one vertex and primitive per lane). No native DispatchMesh or native ExecuteIndirect was recorded. A local diagnostic build logged the interface values behind that refusal. In that run, all 171 programs that reached the preflight were wave64, 128 threads per group, 128 max vertices and 128 max primitives, so each one fails all four conditions. The two courtyard programs from #2092 are among them: bf5a7665d0c6631a (19 parameters) and edff79282d37adb0 (18).

Applying fits_output to those interfaces at 128/128, 154 of the 171 would fit the 32 KiB output budget (14 parameters or fewer). The other 17 would not, including the two above. This is arithmetic on the logged interfaces; no larger native entry was built or tried.

Tested

  • RTX 4090, NVIDIA 621.40, Windows 11 build 26300, Rust 1.99.1, DXC 1.9.2602.17. Clean release build of 427330b54638ce7eb7ee14e3b577087a4af4d6e9 (--locked).
  • XCL_REQUIRE_GPU=mesh cargo test --release --locked -p xcl --lib -- native_mesh --nocapture --test-threads=1: 3 passed, 0 failed, 0 ignored, no SKIPPED.
  • One executable, the same save and a verified copy of the same XCL cache (4,575 files), 360 s each. XCL_NATIVE_MESH unset: 2,065 frames shown. XCL_NATIVE_MESH=1: 2,050 frames shown. Both exited 0 with no device removal. Process commit at the end was 40,668 vs 43,371 MB. Both runs ended on loading artwork, so this pair compares no world scene and no GPU frame time. With no eligible program, it only shows that the refused attempt costs no visible frame rate.
  • The diagnostic build was the same head plus one log line in the refusal branch of native_mesh::preflight, run from an empty cache. It was used only for the interface values above.

Not tested: the full workspace suite, a world scene, GPU timings, and any native draw on this title, since none was eligible.

AI use: Claude Code (Claude Opus 5.5) built both executables, ran the tests and replays, and wrote this report. The person running these tests asked for it.

@KDenKC

KDenKC commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

@minimalhipster990 thank you, this is exactly the number we did not have (our own Not tested listed "the number of eligible programs in the title"). So as it stands this PR draws no mesh program of the retail title natively: the preflight takes one wave32 with one vertex and primitive per lane, and the title's programs are wave64 groups of 128 threads with 128 vertices and 128 primitives. Those still fit D3D12's mesh limits (128 threads, 256 vertices / primitives), so the next slice is a native group of 128 threads that runs each console wave64 as two hardware waves, the way the two-pass path already splits them, plus the 32 KiB output check at 128/128 (your 154 of 171 that fit).

I'm moving this back to draft and will say in the description what it covers today (the entry and draw path, tested on our fixtures) and what it does not (any retail program). The 17 that do not fit the output budget stay on two passes either way.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@KDenKC
KDenKC marked this pull request as draft November 29, 2026 12:31
@github-actions github-actions Bot removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Nov 29, 2026
@Aniseto

Aniseto commented Nov 29, 2026

Copy link
Copy Markdown

Ran the native mesh shader tests at 427330b5 on an NVIDIA Blackwell desktop part.

System

  • GPU: NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, mesh shaders), driver 32.0.16.2140 (621.40)
  • CPU: Intel Core i5-12400F, 64 GB RAM
  • OS: Windows 11 Pro build 26200 x64
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5
  • Build: debug

Results

  • XCL_ADAPTER=NVIDIA cargo test -p xcl --lib native_mesh -- --test-threads=1: 3 passed, 0 failed, 0 ignored. No SKIPPED line in this run.

What this adds
All three native-mesh tests pass on a real 32-lane NVIDIA part: the eligible triangle produces the same pixels through the native and two-pass paths, and the ineligible program is rejected by the native entry and still draws through two passes. The author tested on an RTX 3090 and reports that no retail mesh program is eligible yet; this adds a Blackwell datapoint for the synthetic fixtures, not a title speed-up claim.

Not tested
A retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 427330b, diff read, not a merge-check; draft, conflicts with main (one trivial hunk in real.rs ~9939)):

  • Almost nothing qualifies. The preflight (native_mesh.rs ~9) needs exactly one wave32 group and refuses any program that reads v5 (~32), XCL's only per-group identity, so an eligible program can't tell its groups apart. try_native_mesh (real.rs ~9642) needs the wave range to be exactly 32, so AMD and Intel never qualify. Testers on the PR found 0 of 171-176 retail programs eligible. As it stands that's ~440 lines that change no retail program; the description should say what comes next (v5 through SV_GroupID?) for it to pay off.
  • It rebuilds every user's translated cache once. The emit.rs changes and the new TRANSLATOR_SOURCES entry change the translator's cache identity for everyone, not only the affected entries the description mentions (from reading).
  • Nit: ~26 refuses every store and atomic, not only shared memory, so its message is misleading. It errs on the safe side.

Fine: with XCL_NATIVE_MESH unset nothing changes (native stays empty; the SCALE_ARGS_HLSL edit at bind.rs ~3116 is equivalent when split != 0). The limits are right: at most 32 vertices and primitives, a 32 KiB output budget, no shared memory, and float position and parameters only. Null or out-of-range primitives become degenerate. Dispatch dimensions are checked (~3382). Only plain DispatchMesh signatures take the native path, a refused translation or pipeline keeps the two-pass path, and the GPU test compares pixels and skips on wave64 adapters. It overlaps #3350 (yours) in the HLSL mesh entry; #3504 is another approach.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Foniass

Foniass commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 1e65e6a

No open or merged PR emits console mesh programs as native D3D12 mesh shaders. #3350 (same author) and #2092 change the two-pass path instead. The path is opt-in (XCL_NATIVE_MESH=1) and limited to hardware that runs only wave32 (try_native_mesh). native_mesh::preflight turns down programs that store, use atomics or LDS, or use VGPR 5. Anything turned down falls back to two passes. No problems found in the diff. The PR now merges cleanly into main. Its Build and test check still fails on 1e65e6a, in two uma_driver tests (a_refused_gpu_upload_segment_becomes_custom, mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment) in a file the PR does not touch.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
Keep v5 ranges disjoint across every launched wave, including programs whose output extents exceed declared threads. Add CPU tests for the output-extent and wave-rounding cases.

Checked: xcl-dev#3350 review 7306364917, xcl-dev#3327 interaction, REPO-TRACKER.md and search-two-pass-lanes.md.
Checked: xcl-dev#3011 C4, xcl-dev#3040, xcl-dev#3042, xcl-dev#1936, xcl-dev#1937 and xcl-dev#3243. This entry refuses wave64, including split lowering. Add GPU pixel parity and two-pass fallback coverage.

Assisted-by: Codex (GPT-6.2-Sol)
Checked: xcl-dev#3011 C4, xcl-dev#3040, xcl-dev#3042, xcl-dev#2092, xcl-dev#1936 and xcl-dev#1937. Keep the existing two-pass PSO as fallback. Retain GPU bounds checks for indirect launches and forward the title count.

Assisted-by: Codex (GPT-6.2-Sol)
Checked: xcl-dev#3327, xcl-dev#3011 C4 and xcl-dev#2092. Budget primitive indices too. Keep legal indirect dimensions, reject over-limit arguments with the existing feedback, and distinguish native meshes in the GPU timestamps and watch ring.

Assisted-by: Codex (GPT-6.2-Sol)
@github-actions github-actions Bot added gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) and removed gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Dec 1, 2026
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
Launch enough whole console waves to cover max(threads, max_vertices, max_primitives), keep EXEC at entry limited to the declared threads, and use the launched width as v5's per-group step in both backends. Compute programs are unchanged.

Update mesh shader surveys and barrier fixtures to use the launched width. Add CPU coverage for output extents and wave rounding, plus a two-group GPU draw that checks the v5 step and matching records and pixels from HLSL and direct DXIL.

Checked: xcl-dev#3350 review 7325409956, xcl-dev#3011 C54, and xcl-dev#3327 interaction.
KDenKC added a commit to KDenKC/xcl that referenced this pull request Dec 1, 2026
Launch enough whole console waves to cover max(threads, max_vertices, max_primitives), keep EXEC at entry limited to the declared threads, and use the launched width as v5's per-group step in both backends. Compute programs are unchanged.

Update mesh shader surveys and barrier fixtures to use the launched width. Add CPU coverage for output extents and wave rounding, plus a two-group GPU draw that checks the v5 step and matching records and pixels from HLSL and direct DXIL.

Checked: xcl-dev#3350 review 7325409956, xcl-dev#3011 C54, and xcl-dev#3327 interaction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants