shader: exchange between host waves in a block that holds the title's barrier (2 of the 3 other G-buffer culling shaders, #182; 898d9c1a5605ad81 is still refused) #253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/253"
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?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T05:22:27Z.
Follow-up to #245. With both PRs, 5 of the 6 culling compute shaders that write the G-buffer's indirect mesh-draw group counts translate and run (#182);
898d9c1a5605ad81is still refused.Shape. The other three culling shaders (
4e2edbd69fe414f1,f44473ebe75e0047,898d9c1a5605ad81) were refused with "a cross-lane operation between host waves in divergent code". Each is a group of two console waves (128 threads), so the lockstep fallback doesn't apply. The shader:s_barrier.The lane reads cross host waves and need group barriers. Those went only in blocks that every thread runs exactly once. This block is reached by uniform branches, and a culled wave ends early, so the shaders were refused.
Rule added. A block outside any loop that holds one of the title's own
s_barriers is an exchange site too (barrier_blocks).Evidence:
split_wave_tests::a_whole_wave_or_one_lane_puts_in_lds_reaches_the_group_at_its_barrierruns a synthetic program of the culler's shape (written from the description, with its own registers and reduction) in 128-thread groups. The second wave ends early, as a culled wave does, and both host halves hold flags. It reads 6 in wave 0 and the canary in wave 1, and 14 when both waves stay. Without this change it is refused.4e2edbd69fe414f1,f44473ebe75e0047); no other outcome changes.Barrier blocks behind a first-lane branch (review question). Such a branch can precede the block. The console wave takes a branch on an SCC from
v_readfirstlaneas a whole, so a title may return early before itss_barrier. But each host half computes that SCC from its own first lane, so one half could skip the block while the other waits at the exchange's barrier.barrier_blocksnow excludes a block whose reach condition holds such an SCC (split_scc), aswave_blocksdoes.wave32_tests::a_barrier_block_behind_a_first_lane_branch_is_no_exchange_siteshows the case refused; without the exclusion it translated with the exchange. With marcus-4's branch for #254, the exclusion only becomes conservative for compute: the first-lane read is then exact or refused,split_sccis unchanged, and the two compose.In game (M5 Pro, Series S, warm runs that lived 240 s, target dumps every 15 s from +105 s): before this PR, 255/309/140 culling dispatches were dropped over a run; with the first head (where all three translated) none were. With the merged head,
898d9c1a5605ad81's dispatches still drop. The G-buffer is still almost black, though:The culling was necessary, but it isn't the gate any more. About 470 G-buffer draws are still dropped per world frame. The top refusals are:
We're looking at the drawn half next.
Checks (rebased on
c1b95875): victory-shader 331 and victory-gpu 317 tests pass. Windows clippy on the workspace is clean with-D warnings, andcargo xtask policypasses.docs/native-host.md(the #182 subsection) and thehalves.rsmodule doc are updated.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T05:41:13Z.
This overlaps a local branch of ours that does the same thing for the same three shaders, so thank you; we would rather take yours. One question before merge: the rule says that if any wave reaches the barrier block, every live wave does, but the block is only checked to be outside a cycle and to hold
s_barrier.once_blocksandwave_blocksalso require that it is reached by uniform branches, because an SCC that comes fromv_readfirstlanecan differ between the two host halves of one console wave. Can such a branch precede the barrier block? If it can, please exclude it (a hang would be the failure); if it cannot, please say why in the comment onbarrier_blocks. Related: #254 (v_readfirstlane_b32ignores EXEC on a split wave) is in the tails of these same shaders. Please also give the sweep by output fingerprint, and note that #182 is closed and #258 continues it.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:07:59Z.
Sandile-0511's corpus run (his comment in #258) shows four compute shaders newly translated with this pull request, three of them in the world, and no other output changes, no new refusal. Thank you; that is the comparison by output I asked for.
My question about the barrier block is still open: can a branch whose SCC comes from
v_readfirstlaneand differs between the two host halves precede the barrier block? If it can, exclude it; if it cannot, say why in the comment onbarrier_blocks. The branch is also behind main. Note that marcus-4's branch for #254 changes what a first lane read does in the same shaders, so the answer may depend on it.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T08:53:10Z.
My own corpus run (33,625 containers, compared by output fingerprint, this branch merged onto main
2a3b03d1):4 compute shaders gained (the three cullers f44473ebe75e0047, 4e2edbd69fe414f1, 898d9c1a5605ad81, and 7675b795738af176), nothing lost, no output changed, no hang. Same as Sandile-0511's table. Only the barrier-block question is left.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T09:04:03Z.
Thanks for the two corpus runs. On the barrier block: we're checking now whether a branch whose SCC comes from
v_readfirstlanecan precede it.once_blocksandwave_blocksrely on, with a test where such a branch comes first and the exchange stays refused.barrier_blockswill say why.We'll also rebase onto main and check the answer against marcus-4's branch for #254.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T09:24:42Z.
Updated (rebased on
c1b95875, heada06ac02e):v_readfirstlanecan precede it, and such blocks are now excluded throughsplit_scc, aswave_blocksdoes. Test:wave32_tests::a_barrier_block_behind_a_first_lane_branch_is_no_exchange_site; without the exclusion it translated with the exchange. With marcus-4's #254 branch the two compose: the first-lane read there is exact or refused, andsplit_sccis unchanged. Details are in the description.8ebef857) is no longer on the branch.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T09:50:58Z.
A correction to my update. With the exclusion in the current head (
a06ac02e), the three cullers this PR was for are refused again, on main + #263 + #264 + #267 + #278:898d9c1a5605ad81at 0xfc44e2edbd69fe414f1at 0xf60f44473ebe75e0047at 0x1014All three give "a cross-lane operation between host waves in divergent code". So a branch on an SCC from
v_readfirstlanedoes precede their barrier block, and the hang risk you raised is real for them. Your 09:10Z run used the first head (8ebef857), which accepted them unsafely.Please don't merge the current head expecting the G-buffer gain. We're looking at whether the first-lane value behind that SCC is provably the same in both host halves of these cullers. If it is,
split_scccan leave it out; if not, it needs the exchange #254 is about. I'll update here.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T10:17:52Z.
Update (head
e3d3ce69). This fixes the regression I reported: two of the three cullers translate again, safely.What the cullers do. After the title's barrier, every lane reads LDS word 0 (the group flag) and branches on its first lane. That read is the SCC behind every excluded barrier block in all three cullers.
The rule. Such a first-lane read now splits nothing when all of the following hold:
ds_read_b32at a constant address;s_barriers in its block, with no LDS write in between;The group barrier brings every thread there with the same LDS, and nothing changes the word until all of them have passed the next barrier (
barrier_reads).wave_blocksand the mesh joins keep the old rule.Test.
wave32_tests::a_barrier_block_behind_a_branch_on_an_lds_word_read_after_a_barriercovers four cases:Sweep. I translated 4,129 refused containers dumped from a run (with the native host's options), and compared each one's outcome and DXIL fingerprint before (
a06ac02e) and after:4e2edbd69fe414f1andf44473ebe75e0047now translate.898d9c1a5605ad81stays refused. LDS writes at computed addresses can follow its read before the next barrier, so I can't prove they miss the word.Checks: victory-shader 332 and victory-gpu 317 tests pass, Windows clippy is clean on the workspace, and
cargo xtask policypasses.Not done yet: a game run with this head. Game runs are paused on our Mac for now (GPU hangs, #79), so I haven't measured G-buffer coverage with it.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:32:12Z.
Thank you for the straight account, including the correction about the head that accepted the cullers unsafely. My question about the barrier block is answered: yes it can precede it, and the exclusion is in.
What counts for the merge now is the current head,
e3d3ce69, which has a new rule. My corpus run (four shaders gained) was on the first head, so it does not apply. Your sweep covers the 4,129 shaders that were refused, so it does not show that the shaders that translate today keep their output. I will run my whole corpus one3d3ce69and post the table (gained, regressed, changed per stage); I have not done it yet.Two questions on the new rule. Does "an LDS write" include atomics and
ds_appendandds_consume? And the argument that nothing changes the word until every thread has passed the next barrier: please say what covers the case where one console wave ends early.Also, a force-push does not remove the old commit from GitHub at once. If
8ebef857holds the culler's instructions, tell me and I will ask GitHub to remove it.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T10:49:28Z.
Answers, plus a fix your second question led to. The new head is
834f730c.1. Atomics,
ds_append,ds_consume. Yes, all of them count as LDS writes: every non-GDS DS instruction exceptds_read*,ds_swizzle,ds_permuteandds_bpermute.ds_or_b32to the word is refused.ds_append,ds_consumeand theaddtidforms have no constant address, so they count as touching any word. On a console wave the host splits,ds_append/ds_consumeare refused before this rule anyway; the test checks that too.2. A console wave that ends early, and the gap it revealed. Checking this showed that
e3d3ce69was wrong. It looked only at writes reachable from the read. Another wave can pass a differents_barrierinstruction, on a path without the read, then write the word. The console pairs every live wave's k-th barrier, whichever instruction that is.e3d3ce69accepted such a program, and it is refused now.The rule now works by barrier phase, not by path:
barrier_phasesgives each block the set of barrier counts a path from the entry can have passed ("any" where a loop holds a barrier).A wave that ends early writes nothing more. What it wrote before ending lies in some phase and is checked the same way. A write in an earlier phase (the cullers OR the flag into word 0 before the barrier) is ordered against the read by the barriers in between. Refusing every write after any barrier instead would refuse the cullers themselves.
Test.
wave32_tests::a_barrier_block_behind_a_branch_on_an_lds_word_read_after_a_barriernow covers:ds_append, and another wave writing the word through the same barrier or through its own.Sweep. On our 4,129 refused containers, the results are identical to
e3d3ce69:4e2edbd69fe414f1andf44473ebe75e0047translate with the same DXIL fingerprints, and nothing else changes. Your full-corpus run should use834f730crather thane3d3ce69.Checks: victory-shader 332 and victory-gpu 317 tests pass, Windows clippy is clean, and
cargo xtask policypasses.8ebef857: yes, please ask GitHub to remove it. Its GPU test held about 24 of the culler's instructions verbatim, the block marked "The title's words from here" insplit_wave_tests.rs. Sorry about that. The rewritten test is a synthetic program of the same shape.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T11:54:26Z.
Thank you for the answers, and for catching the case with another wave at a different barrier.
I ran every shader by output on
834f730c: 2 gained (4e2edbd69fe414f1andf44473ebe75e0047), none lost, none changed, no hang.898d9c1a5605ad81is still refused, so the title and description should say 2 of the 3 now; please fix them.I also ran this head in the game, together with #263, #264 and #278 on main
ce2b7860: the 1280x720 G-buffer targets are 60 to 87% covered (31 dumps at 60% or more). The run ended after 238 s in the GPU time-out and title fault we already know, at the same address as before, so that is not from this change.Two things are left before I merge. The old commit
8ebef857has to be gone from GitHub; I will say here when it is. And in the new test,WORD_0andWORD_1(the twods_write_b32words) are the same as in the old one. Please say they are made up for the test and not copied from a shader, or change them.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T12:04:10Z.
Merged. The corpus is clean on
834f730c(2 gained, none lost, none changed) and the game run with it fills the G-buffer. The title and description still say 3 of the 3 cullers; it is 2 now (898d9c1a5605ad81is still refused), which is worth a follow-up. Thank you @Olima34.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-27T12:38:00Z.
On
WORD_0andWORD_1: they're made up.0xD834_0000is the only first dwordds_write_b32can have at offset 0. The second dwords (address v20/v23, data v22) don't occur in the removed8ebef857block. The only words the tests share with it are the lane setup we wrote (v_cmp_eq_u32against 5/40/70,v_cndmask_b32). Title and description are corrected to 2 of the 3.