Patch wave32 per-lane tile-list allocations in compute shaders #2
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/gamingwithhomie--larp!2
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2/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?
@Logard0 on GitHub · 2026-12-05 11:57 UTC · original
Logard0:fix/water-tile-alloc→main· +547 −0 · 3 files · 1 commits · closed without mergingFixes dark/missing water light tiles on 32-lane hosts (
TV_GenerateTiles) by patching wave64 compute shaders that allocate tile-list slots viav_cmpxleader election, based on xss3009's idea from the SmXme fork.Background
On 32-lane hosts, the two halves of a 64-lane console wave can reach the tile-list allocation on different loop passes. A half without the elected lane then takes slots reserved by another pass or wave, overwriting earlier tiles and causing them to lose lighting.
Summary of changes
crates/larp-shader/src/tile_alloc.rs): Called fromNativeProgram::patched_codeafterby_hash::replace_codeon 32-lane hosts (host_uses_wave32(), disableable viaLARP_TILE_ALLOC_PATCH=0). Fires only when all criteria match:HwStage::Csandwave64 == true;buffer_atomic_addglcallocations on the samersrcat byte offsets0and32;s_nopands_waitcnt*) arev_mov_b32 v<result>, s<count>,s_bcnt1_i32_b64,s_cbranch_execz, andv_cmpx_*;v_mbcnt_lo_u32_b32,v_readfirstlane_b32,v_mbcnt_hi_u32_b32,v_add_nc_u32chain with matching registers and no intervening writes tov<result>.v_cmpx_*tos_nop 0,s_bcnt1_i32_b64tos_mov_b32 s<count>, 1,v_mbcnt_lotov_mov_b32 v<lo>, 0,v_readfirstlane_b32tos_mov_b32 s<base>, 0, andv_mbcnt_hitov_mov_b32 v<hi>, v<result>, so every active lane allocates 1 slot and uses its own atomic return value.crates/larp-shader/src/lib.rs): Addedtile_alloc.rstosources()and"LARP_TILE_ALLOC_PATCH"toSWITCHES.rsrc, clobbered result register).Verification
cargo test --locked -p larp-shader tile_alloc: 2 passed, 0 failedcargo clippy --locked --tests -p larp-shader: 0 warnings intile_alloc.rs,native.rs, andlib.rsMade with the help of Gemini 4 Neon.
@gamingwithhomie on GitHub · 2026-12-05 14:46 UTC · original · edited 2026-12-05 15:04 UTC
Thanks for the clean PR! After checking
crates/larp-shader/src/emit/by_hash/whole.rs(lines 214-225), stocklarpalready handlesTV_GenerateTiles(0x1aa247ed3653b616) natively viaRule::LocalWaves. Closing this so we don't invalidate users' shader caches unnecessarily — appreciate your other PRs (#1 and #3 are merged!).Pull request closed