amplification shader: DispatchMesh hardcodes Y=1, Z=1 — ignores 2D/3D mesh dispatch #115
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#115
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Trwthh on GitHub · 2026-11-22 10:24 UTC · original
Bug
In
crates/tombox-xshader/src/hlsl/amp.rs:269, the HLSL emitter always produces:However, the amplification shader's args ring receives 4 dwords via global stores at the
ARGS_HIvirtual address (line 208-212), corresponding to:tb_args[0]= X group counttb_args[1]= Y group counttb_args[2]= Z group counttb_args[3]= reserved/flagsThe Y and Z dispatch group counts are written by the console shader but silently discarded.
Impact
Medium. Any title using 2D or 3D mesh dispatch (Y > 1 or Z > 1) will only get the X dimension dispatched. This means fewer mesh shader groups are launched than intended, resulting in missing geometry. Most titles use 1D dispatch, but some advanced rendering techniques (tiled decal rendering, clustered lighting) use 2D dispatch.
Fix
Replace line 269 with:
The
> 0u ? ... : 1uguards handle the case where the shader only writes arg[0] and the other slots remain at their initialized zero (which is invalid for DispatchMesh).@omonkeyz on GitHub · 2026-11-22 14:05 UTC · original
Not a bug, and the suggested change would break dispatch. The mesh-args entry is not X/Y/Z. The console fixture as3 (source DispatchMesh(g.x + 1, 1, 1)) writes the entry with one global_store_dwordx4: {X, 0, payload VA >> 4 high, payload VA >> 4 low}. tb_args[2] is therefore part of the payload pointer, and using it as Z would dispatch a pointer's worth of groups. The driver also launches AS work as DISPATCH_DIRECT start+count, 1, 1, and our translated mesh shaders read a flat group id (gid.x). The open part, how the console compiler encodes a 2D/3D DispatchMesh, is noted in docs/BLOCKERS.md (
d585b945). No title we run has an amplification shader. Thanks.