D3D12.X: draw eligible console mesh programs as native mesh shaders behind XCL_NATIVE_MESH #3327
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3327"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-29T08:29:21Z.
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
main078358a0; the head is nowd10821a3(was1e65e6a2). The three commits applied without conflicts; the first and the third are unchanged (same patch-ids as511d4d01and1e65e6a2), the second carries the samereal.rsresolution as before (translated_mesh_stream_oncereads the render-target formats fromstream_rt_formats; this PR keeps onlylet state_start = out.0.len();there).A native wave64 translator from Kalmarv will follow as a PR stacked on this one.
What is in it
b9365b46(was511d4d01) adds the native entry ingpu/recomp/native_mesh.rsandemit.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.rscompiles the candidate. The GPU fixture ingpu/recomp/tests.rscompares native and two-pass pixels.e1c7bf4f(was39a39796) adds the optional native PSO inhle/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.rsrecords one nativeDispatchMeshfor an eligible direct draw. Eligible plain meshExecuteIndirectkeeps 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 head
d10821a3(onmain078358a0), 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: 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).cargo test --workspace --no-fail-fast -- --test-threads=4: 3007 passed, 2 failed, 52 ignored. SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache). The 2 failures areuma_driver::tests::a_refused_gpu_upload_segment_becomes_customanduma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment; rerun alone (cargo test -p xcl --lib uma_driver::tests:: -- --test-threads=1) all 8uma_drivertests pass, on this head and onmain078358a0alike. During part of the 4-thread run the same GPU was running a retail-title session.Earlier heads:
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 --workspacepassed;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
1e65e6a2on the RTX 3090 VM (NVIDIA 621.24, Intel Core i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, debug), againstmain6bfb5c51on 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'snative_meshtests). The same 5 failures on both,main's own:title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3stream_recheck_*tests, e2etest_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 3uma_drivercoherent-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 at427330b54638ce7eb7ee14e3b577087a4af4d6e9.cargo build --workspacepassed in debug.cargo test -p xcl --lib --no-runandcargo test -p xcl --lib --release --no-runpassed.cargo test -p xcl --lib -- native_mesh --nocapture --test-threads=1passed 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=4at427330b5: 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 3uma_drivercoherent-window remake tests that kill the lib binary on 621.x. The 5 failures are main's own (they fail on mainfa204595on this machine):title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels, the 3stream_recheck_*tests, e2etest_title_runs_and_game_folder_is_untouched.Regression run
Pending for the head
d10821a3: the pair needs a rig run on the RTX 5090 and follows here. The blocks below are from427330b5, two rebases ago, and show the default path (native mesh off) unchanged then.RTX 5090 32 GB, driver 621.24, Ryzen 7 9800X3D, the retail title, 200 s each,
scripts/smoke.ps1with preparation on (-Prep), normal priority and default worker counts,XCL_NATIVE_MESHunset (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 ofmainfa204595) 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:this head
427330b5:1e65e6a2(was427330b5), 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-rundebug and release,-- native_mesh: 3 passed, 0 failed, 0 skipped.Not tested
With
XCL_NATIVE_MESH=1and Kalmarv's wave64 translator (#3656) on top, which makes the retail title's mesh programs eligible, the device is removed in the nativeExecuteIndirectpath (bind.rs: the argument-rewrite pass, then the native mesh stage and the PCExecuteIndirect), three runs out of three; our report with the DRED lines: https://github.com/xcl-dev/xcl/pull/3656#issuecomment-7363569473. On this PR alone no program of the title is eligible (below), so nothing reaches that path, and the default (off) is unaffected.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 (https://github.com/xcl-dev/xcl/pull/3327#issuecomment-7255841480), 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
Generated with Claude Code
https://claude.ai/code/session_013oPUFCA9W9F8Qb5MPK33bR
Imported from ivall/xcl. Originally posted by minimalhipster990 on 2026-11-29T12:28:46Z.
Retail title on RTX 4090: no mesh program passes the native preflight at
427330b5. WithXCL_NATIVE_MESH=1, all 176 mesh programs the title created in a 360 s run were logged asusing two passes (requires one wave32 and at most one vertex and primitive per lane). No nativeDispatchMeshor nativeExecuteIndirectwas 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) andedff79282d37adb0(18).Applying
fits_outputto 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
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.XCL_NATIVE_MESHunset: 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.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.
Imported from ivall/xcl. Originally posted by KDenKC on 2026-11-29T12:31:02Z.
@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.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T13:19:02Z.
Ran the native mesh shader tests at
427330b5on an NVIDIA Blackwell desktop part.System
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:12:34Z.
Review (head
427330b5, diff read, not a merge-check; draft, conflicts with main (one trivial hunk inreal.rs~9939)):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 throughSV_GroupID?) for it to pay off.emit.rschanges and the newTRANSLATOR_SOURCESentry change the translator's cache identity for everyone, not only the affected entries the description mentions (from reading).Fine: with
XCL_NATIVE_MESHunset nothing changes (nativestays empty; theSCALE_ARGS_HLSLedit atbind.rs~3116 is equivalent whensplit != 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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:49:10Z.
Triage (#1607) – head
1e65e6aNo 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::preflightturns 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. ItsBuild and testcheck still fails on1e65e6a2, in twouma_drivertests (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.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T03:28:44Z.
Hey @KDenKC and @throny — confirming the pairing plan for #3011 (C4):
ExecuteIndirect/two-pass-fallback plumbing cleanly first (thank you @KDenKC for the rebase ontomain).ms_6_6translator + packed PSISG1/ MSOSG1narrowing (plus the Blackwell Wave64 meshPartner::Barrierfix) directly on top of #3327 as its own follow-up PR, so both halves stay focused, reviewable, and properly credited.Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T03:30:04Z.
@Kalmarv sounds good, that's the plan on our side too. #3327 stays rebased on
main(head1e65e6a2, mesh tests 3/3 on the RTX 5090, suite on the 3090 in its description), so your follow-up has a stable base. When your PR is up we'll review it, run the mesh tests and the in-world A/B on the 5090 and post the numbers there. Your loyal testing minion is standing by.AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T03:15:07Z.
Follow-up review of
d10821a3, since1e65e6a2(code reading only, not a merge-check; draft) · no new findingsIn short: Since the triage of
1e65e6a, this push only rebases ontomain. The one textual change followsmain'sTwoPassPsoconstruction, which now takeschain_rs.unwrap_or(rs)forcompute_rs; this PR'snative: Default::default()field is added there. The other two commits are identical (git range-diff). Nothing new, and nothing blocks it.Checked and fine
XCL_NATIVE_MESH=1), limited to hardware that runs only wave32. Anythingnative_mesh::preflightturns down falls back to two passes.Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.