xshader mesh: full merged_wave_info in s3, GS_ALLOC_REQ field widths per ISA, v5 readings documented #58
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!58
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/58/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?
@QuentinDanblon on GitHub · 2026-11-21 21:54 UTC · original
QuentinDanblon:fix/mesh-s3-wave-info→main· +96 −12 · 2 files · 85 commits · closed without mergingLibrary / area: tombox-xshader mesh stage (
hlsl/mesh.rs)Exports changed (exports.txt rows): none
Source of the behaviour: RDNA2 ISA §3.12.2 (GS SGPR 3 layout) and §12.5.1 (GS_ALLOC_REQ M0 fields); Mesa main ef594386 (
ac_nir_lower_intrinsics_to_args.c,ac_nir_lower_ngg.c,ac_nir_lower_ngg_mesh.c, MIT); LLPCMeshTaskShader.cpp. Leonida (GPL, used as an observation only) measured that every GTA VI mesh shader reads s3 arithmetically.Changes
s3 = merged_wave_info, all fields. Before, only the wave index [27:24] was set (
(gi / w) << 24), so a shader reading waves-per-group [31:28] got 0. Nows3 = ceil(n/w) << 28 | (gi/w) << 24 | min(w, n − wave_base) * 0x101:The per-wave counts depend on how the driver programs the GE, like v5. They are filled to agree with the existing per-lane v5 reading; under Mesa/LLPC programming they would read 1/1 in wave 0. The code comment says this.
GS_ALLOC_REQ decode now uses the ISA widths: vertices
m0 & 0x3ff(M0[9:0]), primitives(m0 >> 12) & 0x7ff(M0[22:12]). It used 12-bit fields. Mesa/LLPC describe vertices as 11 bits; bit 10 only matters above 1023 vertices, which no mesh limit allows. The comment records the difference.v5 unchanged, both readings documented. Mesa RADV and LLPC (gfx10.x legacy FAST_LAUNCH) put the flat workgroup index in v5, with citations in the comment. The translator assumes
gid.x*threads + tid. That depends on how the console driver programs the GE, which isn't public. The comment says what would settle it: how GTA VI consumesv_readfirstlane_b32 sX, v5(a shift by log2(threads) vs direct use).Tests (
tests/mesh.rs, synthetic, no fixtures; encodings checked with llvm-mc gfx1013)gpu_mesh_merged_wave_info_fields: extracts s3[31:28] and s3[15:0] and renders them. Expected: wave64×128 → [0x4040, 2], wave32×128 → [0x2020, 4], wave64×96 → [0x2020, 2], wave32×80 → [0x1010, 3].gpu_mesh_alloc_req_counts_at_limit_ignore_bits_outside_fields: counts at the PSO limit, with bit 11 and bits 23-31 set.WARP:
--test mesh15 passed (1 fixture test ignored). RTX 5090 (TOMBOX_EXEC_HW=1): 15 passed, every GPU test rendering on hardware.--lib17,--test opcodes22.cargo test -p tombox-xshader --test meshpasses on WARP and hardwareNo game or console files and no binaries included
No fake success; anything not possible is left
missingwith a note@QuentinDanblon on GitHub · 2026-11-21 23:09 UTC · original
Rebased onto
8491769.--test meshgives 12 passed, 3 failed on WARP and on the RTX 5090. Main gives 10 passed, 3 failed with the same three tests (mesh_divergent_barrier_with_lds_is_refused,mesh_divergent_barrier_with_memory_store_is_refused,gpu_mesh_divergent_barrier_without_memory_writes), since the new rule that closes the conditional block before ans_barrier. The two tests this PR adds pass. Details on the three are at the end of #70; I left them alone.@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please remove the 45 comment lines, including the game-specific references. Code must not name titles or game corpora. The code change itself looks right. To resubmit:
git fetchthis repo, branch from the currentmain, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.Pull request closed