tombox-xshader: support 256-thread mesh shaders and per-primitive PSG1 outputs #172
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!172
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/172/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?
@GDAgent on GitHub · 2026-11-22 17:50 UTC · original
GDAgent:fix/xshader-mesh-256-and-prim-outputs→main· +213 −39 · 16 files · 1 commits · closed without mergingLibrary / area: tombox-xshader (
meta.rs,dxil_meta.rs,lib.rs,gcn.rs,hlsl.rs,hlsl/mesh.rs,tests/mesh.rs)Exports changed (exports.txt rows): none
Source of the behaviour: Xbox Series (
dxc_xs) mesh shaders can use up to 256 threads per threadgroup ([numthreads(256, 1, 1)]withmax_vertices = 256,max_primitives = 128, observed on UE5 NaniteHWRasterizeMS) and export per-primitive attributes declared in the DXBCPSG1chunk on parameter export targets immediately following the vertexOSG1parameter slots (target = 32 + out_params.len() + prim_param_idx). PC D3D12 SM 6.5 caps mesh-shader threadgroups at 128 threads ([numthreads(128, 1, 1)]) while still allowing 256 output vertices and per-primitive attributes inout primitives.Changes:
stage == 13) threadgroup sizes in129..=256inmeta::mesh_thread_count_forwhile keeping amplification shaders (stage == 14) and odd sizes capped at1..=128.129..=256threads and does not use LDS, emit[numthreads(n/2, 1, 1)]and execute a two-pass loop (tb_gi = gi + tb_iter * (n/2)) keeping wave32/wave64 lane geometry intact, then callSetMeshOutputCountsonce and emit both passes' vertex and primitive outputs (guarding the second pass's indices againstmax_vertices/max_primitives). Refuse>128-thread mesh shaders that use LDS rather than risking broken cross-pass synchronization.PSG1/PSGNintoShaderExtract::prim_sig, emit per-primitive fields intostruct SPrim, and routeexptargets32 + out_params.len() ..in mesh shaders totb_pout. Refuseprim_vectors != 0withoutPSG1and refuse per-primitive system values.mesh_256_threads_and_per_primitive_outputs_compile_with_dxcintests/mesh.rscovering 256-thread virtualization,PSG1per-primitive attributes, DXC compilation, and both refusal paths.Tests:
cargo test --release -p tombox-xshader --lib: 79 passed, 0 failed, 2 ignored (GPU-only FMA probe tests).cargo test --release -p tombox-xshader --test mesh -- --skip gpu_: 15 passed, 0 failed, 1 ignored (local dump fixture).cargo test --release -p tombox-xshader --test synthetic: 21 passed, 0 failed (pluscargo test --no-runacross alltombox-xshadertest targets).HWRasterizeMS([numthreads(256, 1, 1)],PSG1TEXCOORD7) translates and compiles cleanly with DXC (ms_6_5).Not verified in a title: live rendered pixels of the translated 256-thread mesh shader have not been visually verified yet beyond DXC compilation and the unit tests above.
cargo test -p tombox-xshaderpasses@omonkeyz on GitHub · 2026-11-22 18:26 UTC · original
Applied in
d22f894(merged inf0213ec) with your authorship kept, thanks. A follow-up, not blocking: a WARP exec test of a 256-thread mesh shader that checks every output lands, including the second-half index guard, would be welcome.Pull request closed