Skip to content

gpu,shader: run multi-wave and globally coherent compute builders - #15

Merged
wbkepler merged 1 commit into
mainfrom
gpu/bvh-builders-run
Nov 25, 2026
Merged

wbkepler merged 1 commit into
mainfrom
gpu/bvh-builders-run

Conversation

@wbkepler

Copy link
Copy Markdown
Owner

Summary

Enables compute shaders that use multi-wave console-flow lowering with barriers or lock-free cross-threadgroup UAV synchronization, and lifts the temporary fifth-root-constant dispatch drop so BVH builder dispatches execute instead of being dropped.

Changes

  • Multi-wave console-flow lowering (victory-shader)
    • Allow wave64 console-flow in multi-wave compute groups when every s_barrier is in a uniform block (multi_wave_safe_blocks), allocate per-wave LDS exchange slots, and omit redundant barriers inside divergent branch bodies.
  • Global UAV coherence & store-completion fence (victory-shader)
    • Decouple dirty-page marking (write) from UAV view selection (uav/coherent) in title-memory lowering so UAV and glc/dlc loads bind the raw UAV (view + 1) rather than the read-only SRV (view), preventing stale L1/SRV reads after writes in the same dispatch.
    • Propagate DXIL IsGloballyCoherent (0x4000) on coherent (glc/dlc/atomic) UAV handles (buffer, flat, smem, raw_view, root_view) and root UAV dx.resources metadata.
    • Keep s_waitcnt_vscnt in the IR (ir.rs) and lower s_waitcnt_vscnt null, 0 (plus buffer_gl0_inv/buffer_gl1_inv) to dx.op.barrier(2) (UAVFenceGlobal / DeviceMemoryBarrier) in compute/mesh shaders that write UAVs, and include Fields::Flat stores/atomics in writes_uavs.
  • Lift temporary dispatch drop (victory-gpu)
    • Remove the temporary fifth-root-constant dispatch drop in crates/victory-gpu/src/draw.rs.
  • Tests
    • multi_wave_group_with_lds_barrier_and_readlane_keeps_waves_isolated (split_tests.rs)
    • root_uav_title_memory_coherence_across_groups (memory_tests.rs, DXIL validation + hardware & WARP execution)

Verification

  • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean
  • cargo clippy -p victory --features diagnostics --all-targets -- -D warnings: clean
  • cargo xtask policy: 186 files ok
  • cargo test -p victory-shader: 299 passed, 0 failed
  • cargo test -p victory-gpu -- --test-threads=1: 188 passed, 0 failed
  • Live 240 s world run with a freshly rebuilt shader cache: completed cleanly with zero device removals or panics; steady-state dropped dispatches reduced from ~250/frame to 19/frame (0 indirect) at ~333-347 ms/frame (104-107 ms GPU).

Enable compute shaders that combine wave64 console-flow lowering with
workgroup barriers or lock-free cross-threadgroup UAV synchronization,
and lift the temporary dispatch drop for shaders reading a fifth root
constant.

Changes:
- Multi-wave console-flow lowering (victory-shader): allow console-flow
  for multi-wave compute groups when every s_barrier sits in a uniform
  block, allocate per-wave exchange slots in LDS, and skip redundant
  exchange barriers inside divergent branch bodies.
- Global UAV coherence (victory-shader):
  - Bind the raw UAV view (view + 1) instead of the read-only SRV for
    UAV and globally coherent reads through title memory while keeping
    dirty-page bitmap marking restricted to writes.
  - Propagate DXIL IsGloballyCoherent (0x4000) on coherent (glc/dlc or
    atomic) UAV handles and root UAV resource metadata.
  - Retain s_waitcnt_vscnt in the IR and lower s_waitcnt_vscnt null, 0
    (and buffer_gl0_inv/buffer_gl1_inv) to dx.op.barrier(2)
    (UAVFenceGlobal / DeviceMemoryBarrier) in compute/mesh stages that
    write UAVs, and include global_store/global_atomic in writes_uavs.
- Lift the temporary fifth-root-constant dispatch drop in
  victory-gpu/src/draw.rs.
- Add unit and GPU tests covering multi-wave LDS barrier isolation and
  cross-threadgroup lock-free handoff through a title-memory root UAV.
@wbkepler
wbkepler merged commit bfd433c into main Nov 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant