Repository navigation
Shaders: drop group sync for race-free divergent single-wave barriers on narrow-wave hosts - #2035
rivaldodev wants to merge 1 commit into
Conversation
|
Triage verdict — Keep as a draft and verify the selected wave width ( Evidence
Checks and limits
Next step
This verification was AI-assisted. |
2a5fe15 to
5b34703
Compare
5b34703 to
bfb7c39
Compare
|
I used PortBridge to review the current A lane-dependent loop exit can mark a barrier that every thread reaches in the first iteration. If one host wave writes data before that first arrival and the other reads after it, the mode 11 → 10 change permits the read of the old value. The static control grants a completed store full visibility. The difference follows from the missing arrival dependency, separate from the selected-wave-capability question. The existing Exact pinned source checks and finite schedule model. I did not build or dispatch a potentially nonuniform barrier shader. The narrow safe omission rule needs positive evidence that no other invocation can observe the ordering. For shared effects, #192 and #1433 already cover broader convergent approaches. AI-assisted PortBridge review (OpenAI Codex). |
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
146 passed / 0 failed / 2 ignored. Narrow-wave host barrier handling (+2 tests) — barrier lowering for sub-32-lane waves; mixed gpu+shader, gpu half Windows-only.
|
Automated triage for the maintainers. Needs rebase. This PR no longer merges cleanly into From the earlier needs-work note, still open: show what the new test does on Generated by Claude Code |
Offline measurement on a retail dumpResult: no count change against I merged head bfb7c39 onto No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
bfb7c39 to
c61da5c
Compare
|
Addressed all points from triage,
Ready for re-triage. |
docs/value-vs-upstream.md: the most-starred forks are all doing shader fidelity (JMAN730 42 stars, DexNom wave64 masks, PastiiJay FidelityFX) and nobody measures frame composition, host memory or how to drive the menus. Group by group: rpcrt4 and Marvisak#928 are upstream's; COPY_PLAIN, FRAME_LOG, DRIVER_WATCH supersede ours; the texture-refresh numbers complement Marvisak#388 and Marvisak#1873; the staging budget, the page-bitmap detile, the pad-stick gap (Marvisak#1702's missing half), the terms page, the committed saves, the wave64 sentence (Marvisak#2105/Marvisak#599/Marvisak#2035), the ALERT_ERROR_SUPPORT trap and the memory series complement Marvisak#1479 - with what is worth sending where.
… on narrow-wave hosts Keys the rule on the shader's effective minimum wave width (s.wave_size or D3D12_OPTIONS1::WaveLaneCountMin), restricts omitting SyncThreadGroup to single-console-wave groups with no shared read/write memory effects (no LDS and not both reading and writing buffers/images/flat global memory), refines lane_loop_blocks to exiting branches only, documents shader_cache::build's host initialization side effect, and adds unit tests plus a live narrow-wave GPU dispatch test.
c61da5c to
dca7588
Compare
Split out from #1133 and narrowed to address all triage and reviewer feedback.
Problem
On the console,
s_barrierwaits per wave: a wave whose lanes skip the barrier still arrives. In translated DXIL, control flow runs per lane, so a barrier inside a lane-dependent branch or in a loop with a lane-dependent exit is reached by only some threads. On a wave32 host (e.g. NVIDIA) or an unpinned shader on a 32–64 adapter, one 64-thread console wave spans two host waves, and a host wave that skipsGroupMemoryBarrierWithGroupSynchangs the GPU.Narrow, race-free approach (addressing triage,
@jeremygold02, and@akimfomin)WaveLaneCountMin, notWaveLaneCountMax):crates/victory-gpu/src/host.rsrecordsD3D12_OPTIONS1::WaveLaneCountMinviavictory_shader::emit::set_host_wave_min.Lower::barrier_unsynceduseslet effective_wave = self.s.wave_size.unwrap_or_else(super::host_wave_min);.WaveSize(64)keepeffective_wave == 64(never drop sync); unpinned shaders on 32–64 or 32-only adapters useWaveLaneCountMin(32); 64-only adapters use 64 (translate identically tomain).!has_shared_rw+ single console wave):should_drop_barrier_synconly dropsSyncThreadGroup(keeping memory fences2 | 8) when:effective_wave < console_wave, ANDgroup_threads <= console_wave), AND!has_shared_rw: the shader uses zero LDS (s.lds_dwords == 0) and does not both write and read memory across buffers, images, orFlatglobal memory (so no invocation can read data written by another invocation across the barrier — eliminating both LDS and UAV/Flat-global read-after-write races).SyncThreadGroup.lane_exit_loop_blocksgroups back-edges by loop header and only marks a loop when an exiting block (with a successor outside the loop body) has a lane-dependent branch.shader_cache::build()keys onhost_wave_min()and documents its side effect (initializingcrate::host::host()on first call soWaveLaneCountMinis known before the cache key is fixed).Tests & Hardware Proof
emit::lower::tests::divergent_single_wave_barrier_runs_on_narrow_wave_hardware(live GPU dispatch + DXIL validation):s_barrierinsideif (lane < below)(below = 1, 10, 32, 33, 64).WaveLaneCountMin=32, Max=32): completes without hanging and all 64 lanes write the exact reference output (19 + lane).emit::lower::tests::lane_loop_blocks_only_marks_loops_with_lane_dependent_exits: verifies uniform-exit loops with inner lane branches are NOT marked, while lane-dependent header exits and early breaks ARE marked.emit::lower::tests::narrow_wave_barrier_sync_only_drops_for_divergent_single_console_wave_groups: verifies 64-only /WaveSize(64)-pinned, uniform barriers,has_shared_rw(LDS / UAV+Flat R/W), multi-console-wave groups, and unknown group sizes all keepSyncThreadGroup.victory-gpushader_cache::tests:3 passed, 0 failed.