recomp: support wave32 split execution for console mesh shaders #39
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!39
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/39/head"
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?
@wrxqed on GitHub · 2026-11-22 19:18 UTC · original
wrxqed:fix/mesh-wave32→main· +34 −8 · 5 files · 1 commits · merged 2026-11-22 21:33 UTCSummary
On adapters without native wave64 support (
WaveLaneCountMax < 64, e.g. NVIDIA GPUs),console_meshpreviously emitted[WaveSize(64)]unconditionally, causingCreateComputePipelineStateto fail withE_INVALIDARG(0x80070057):This adds a
mesh_wave32option (mirroringgeometry_wave32) and wires it fromgeometry_wave32_required(this)intranslated_mesh_stream.Changes
crates/xcl/src/gpu/recomp/mod.rs: addOptions::mesh_wave32(defaultfalse).crates/xcl/src/gpu/recomp/emit.rs: inMode::Mesh, whenwave64 && mesh_wave32, emit[WaveSize(32)]and setxcl_half = (gi >> 5) & 1u,xcl_logical_wave64 = true,lane_id = WaveGetLaneIndex() + 32u * xcl_halfwhile preserving[numthreads(t, 1, 1)].crates/xcl/src/gpu/recomp/pso.rs&crates/xcl/src/hle/d3d12x/real.rs: passgeometry_wave32_required(this)intoconsole_mesh.crates/xcl/src/gpu/recomp/tests.rs: add unit testmesh_wave32_emits_wave32_logical_wave64.Note: Like
geometry_wave32, this usesxcl_logical_wave64split-half emulation (cross-half lane ops remain half-local).Verification (NVIDIA GeForce RTX 5050, 7911 MiB VRAM)
cargo test --release --lib mesh_wave32_emits_wave32_logical_wave64: 1 passed, 0 failedcargo test --release --test gpu_pso_e2e -- --test-threads=1(withXCL_SAMPLE_RPF/XCL_SAMPLE_DLLS): 6 passed, 0 failed (retail_mesh_pipelines_through_the_hook: 7 / 7 MS+PS pipelines; previously 0 / 7).@ivall on GitHub · 2026-11-22 19:28 UTC · original
Thanks for this! The wiring is clean, it mirrors
geometry_wave32nicely and it changes nothing on adapters with wave64.One blocker though: the split geometry path only runs on programs that pass
geometry_wave32_hazards(translate_geometryrejects anything with cross-half semantics). The mesh path here has no such check, so every program gets split.In split mode the two halves can't see each other:
ballot()returns only the half's own bits,WaveReadLaneAtacross halves returns 0, and each half takes its own branches on EXEC / VCC. I rangeometry_wave32_hazardsover every NGG program in the retailshaders.rpf(the packretail_mesh_pipelines_through_the_hooksamples):So on a 32-lane adapter all of them would now create a pipeline but compute wrong results (culling / compaction, vertex and primitive counts), and where the halves branch differently around an
s_barrierthe group can hang the GPU. Today those draws are skipped cleanly because pipeline creation fails; with this change they would draw garbage or TDR. The 7 / 7 ingpu_pso_e2eonly checks that the pipelines are created and the unit test checks the emitted text, so neither catches it.What it needs:
console_meshwhenmesh_wave32is set and return an error for programs that have hazards, liketranslate_geometrydoes (the check isn't geometry-specific, so a shared name would be nice). On today's pack that turns 7 / 7 back into 0 / 7, but the failure stays clean.v_readlane_b32ors_cbranch_execzmust fail to translate withmesh_wave32, and one without them must still translate).With (1) and (2) this would be safe to merge. Actually running these programs on NVIDIA needs real cross-half emulation (ballot / readlane / permlane / DPP and the mask branches across both halves) rather than a split; that's what the mesh dispatcher work (
mesh_wave/mesh_dispatch) is aiming at, so it's worth coordinating with it.@grahamster2 on GitHub · 2026-11-22 20:38 UTC · original
Tested on an RTX 3080 (D3D12 wave range 32..32, mesh tier 1, driver 610.88), merged onto current
mainplus #41 to pick the adapter, withXCL_SAMPLE_RPFset to a retailshaders.rpf:maincargo test --workspace --releaseretail_mesh_pipelines_through_the_hookretail_pipelines_built_in_the_background_behind_a_stand_inThere was no device removal or TDR, but these tests only create the pipelines and never dispatch the 7 programs. On a Radeon RDNA2 iGPU (native wave64, no mesh shaders) nothing changes: 355 passed, and the mesh parts skip.
On @ivall's point that a split computes wrong results: #44 shows it concretely for the geometry split, which uses the same prelude. A
v_mbcntover av_cmpmask in lanes 32..63 got 0..23 instead of 24..47 on this GPU. That form is not ingeometry_wave32_hazardsyet; #44 adds it, so the mesh check below picks it up too.I've pushed the two requested changes on top of this branch as a suggestion. @wrxqed, feel free to take them, or ignore them if you're already on it: https://github.com/wrxqed/xcl/compare/fix/mesh-wave32...grahamster2:xcl:mesh-wave32-hazards (one commit, +34 / -8):
translate_mesh(code, ms, wave64, mesh_wave32)inrecomp/mod.rs, mirroringtranslate_geometry, runsgeometry_wave32_hazardswhen the program is wave64 and split, and returnsmesh program requires unsupported cross-half wave64 semantics: {..}.console_meshuses it.mesh_wave32_rejects_cross_half_operations: wave64 programs withv_readfirstlane_b32and withs_cbranch_execzare refused when split. They still translate natively, and a plain program still splits.With it, the RTX 3080 is back to 0 / 7 and fails cleanly with the hazard error (cross-half lane exchange, branch on a whole-wave mask, branch on a half-local scalar condition), with no device removal. The background stand-in test then fails as it does on
main.@ivall on GitHub · 2026-11-22 21:33 UTC · original
Merged, together with @grahamster2's hazard check (
798ff0d) on top, which is what I asked for above. Thanks to both of you!On an adapter with wave64 nothing changes: all tests pass on an RX 9070,
gpu_pso_e2ewith a retailshaders.rpfincluded. On 32-lane adapters, wave64 mesh programs that need cross-half semantics are now refused cleanly with the hazard list, and programs without such semantics run split. Every program in today's retail pack needs those semantics, so those draws are still skipped. Really running them needs cross-half emulation, not a split.