Repository navigation
Conversation
|
On an RTX 3080 Ti (32 lanes), I replayed 77 captured compute shaders that the #414 translator had rejected for wave64 lanes or shared LDS. With this change applied, 20 of 77 passed both DXIL validation and actual D3D12 compute pipeline creation. The other 57 still failed. This is offline pipeline coverage. I have not verified the dispatch outputs for these shaders. |
|
Verified Not covered: the new console-wave LDS paths executed on a Windows/Wine GPU (parser/emit tests only here) and title behaviour (no game data). |
|
Thank you. 20 of 77 passing both checks is a useful floor, and the 57 are the more interesting part. Could you post how the 57 split, as counts only?
No game data used on my side. AI-assisted. |
|
Re-checked the new head |
|
Tested with the title at Program by program:
Not tested: a 64-lane adapter, a release build, image results, (Claude Code, Claude Opus 5.5: ran the title and compared the logs program by program.) |
|
Thank you, that is exactly the split I was after: 70 of That orders what comes after this PR: whole-wave sections in the console flow first, then groups of several console waves. I am not stacking either on top yet. #320 and this PR are drafts because a whole-title validate run found 20 modules the console flow emits that I have added your numbers to the description. No game data used on my side. AI-assisted. |
|
Following the offline check above, I tested integer whole-wave scans across the two hardware waves. The synthetic 64-lane prefix sum reads back exactly on an RTX 3080 Ti, including 528 for lane 32. The follow-up against this PR's head is r4tedx#1. In a local integration build the material-tile initialization shader passed offline D3D12 compute pipeline creation and dispatched during the opening scene. The final scene color was still dark in the captured frame. |
…64 stack For testers: the wave64 stack (Marvisak#223, Marvisak#233, Marvisak#320, Marvisak#439) with Marvisak#180, whose sampleGrad form makes compute programs that sample with implicit derivatives pass dxil.dll validation. One conflict, in emit/lower.rs, where a compute program is found to need the console's lanes: Marvisak#180's quad gradients read within four lanes, so they go with DPP and ds_swizzle among the reads that stay inside a 32-lane half, and such a program runs on a 32-lane host in two halves. Checked on an RTX 5070 and a Radeon iGPU: cargo test --workspace passes, and a hand-assembled compute image_sample validates and samples the right value in groups of 64x1x1, 8x8x1, 32x1x1, 128x1x1 and 4x4x2.
…73d66, and Marvisak#180) The wave64 stack (Marvisak#223, Marvisak#233, Marvisak#320, Marvisak#439, with Peter Bonanni's whole-wave sections across the halves, 9b73d66) merged with Marvisak#180 (twin descriptor loads and quad gradients for compute samples), at 24b3bcc. That commit has one parent (e49302a); Marvisak#180's changes come in without its commits. Marvisak#233 is in this tree as 1eb9995, the same tree as 3098672, so each file was merged with 3098672 as the base instead of the e0865d2 git chooses. Conflict resolutions: - emit/wave.rs, v_permlane16/x16 in whole-wave sections: Marvisak#98's "every lane active" and 9b73d66's "or fi set" are both kept, for both instructions. - emit/lower.rs, Lower::new: Marvisak#320's test for lane reads and writes in divergent programs counts live instructions only, as Marvisak#233's does with Marvisak#309 (dead SGPR-spill lane instructions are no lane reads). Marvisak#307's waterfall arm of v_readfirstlane still comes before the console-flow arm; Marvisak#320 adds no arm of its own. - Compute samples with implicit derivatives (Marvisak#160, Marvisak#180, Marvisak#306): Marvisak#180 decides plain and biased samples, all of Marvisak#160's forms of them (implicit_derivatives from sample_form: _o, _cl, cube, a16), with Marvisak#160's bias address (bias_at) and level clamp; Marvisak#306's validator 1.8 is now declared only for what still uses the host's derivatives in compute (comparison samples, op 64). The Marvisak#306 test of image_sample now asserts no 1.8 (48-byte PSV0) and still validates and creates the pipeline; a twin test with image_sample_c asserts 1.8. - sgpr_spill test (Marvisak#309): without forwarding, the per-lane form still stops with "a lane mask holding lanes elsewhere read as data", but emit now takes the console flow (Marvisak#320); the test checks both, and that forwarded spills do not ask for the console flow. - Mechanical: per_lane_only in two hand-built Parts in emit/lower.rs tests; emit/mod.rs module order (split_tests before threading). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Marvisak#320 and Marvisak#439 (with peter-bonanni's 9b73d66) are in, with Marvisak#180, whose quad gradients fix the compute samples that failed validation. Records the in-title measurement by testers and this merge's resolutions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
64-lane AMD result for All 22,178 emitted modules on this head successfully created D3D12 pipelines. Across 25,889 shared program labels, the comparison against Full stage table, label-exclusion rule and reason changes: #293 (comment) Offline only; no title executable or world run. AI-assisted (Kimi). |
|
Follow-up correction to my 64-lane comparison: after normalizing the instruction offset present only on failure labels, the matched result is 22 pipeline-creation gains, 2 DXIL-validation gains, and 0 losses across 25,912 shared labels. The 22 gains are Details: #293 (comment) The earlier stage totals were correct; the initial 0-gain figure omitted these emit-to-success transitions. No 64-lane regression was found. |
91af621 to
a32c177
Compare
This PR on an RTX 4090 in the opening cutscene, and a heads-up on
|
|
@latentdev thanks, and the size figures match ours. Our trial merge of Your frame-80 result is useful. Is the local change (a barrier after each LDS access, sections combined across the halves) on a branch you could share, or could you post it as a patch? We would test it on top of the rebased head. No title data was used for this reply; the sizes come from our trial merges in git. AI-assisted |
The one conflict was in apps/victory/src/main.rs, where main's `--jobs` became a `NonZeroUsize` and the branch added `--host-lanes`: `translate::run` takes both, `jobs.map(NonZeroUsize::get)` as main passes it and the branch's `host_lanes` after it. The `emit` and `lower::Parts` call sites main added in tests (census, crosslane, memory, synthetic, `emit::tests`, `resource` and lower.rs's own) pass `Target::ANY`, as the earlier merge did for the ones before them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pure move, so that the merge of main (63bcca4) keeps emit/lower.rs under the asset policy's 512 KiB limit: the inline `mod tests` becomes `mod tests;` beside `mod bvh;`, and its body, one indent level less and otherwise unchanged, is emit/lower/tests.rs. Its `super::` paths still name `lower`. Moving the tests out of lower.rs is desplmfao's idea (Marvisak#2309). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… flow Conflicts, resolved with kawaii-shakal's notes on Marvisak#439: - emit/host.rs: main's process-wide WARP device (`SharedDevice`, `WARP_LOCK`, `lock_warp`, `from_device`) is kept, and its `create_device` takes an optional adapter for the branch's `VICTORY_ADAPTER` and `Host::on`. - emit/lower.rs: `console_read_lane` stays beside main's new `helpers_read` doc; main's `uniform_join` sits above `never_taken`, which keeps the branch's console-flow note. - Lane-mask joins: main's path for data joined with masks at a uniform join (the BVH walks pop masks from memory) stays beside the console flow's masks; `lane_bit` now returns a `Result`, so it takes `?`. `no_mask_lane_on_edge` is kept out of the console flow, whose lanes go along the wave's edges. - emit/lower/tests.rs (lower.rs's tests, moved out before this merge): main's test changes are ported there. Its `lowers` helper calls `lower` directly, so it now lowers a program again in the console flow when the first try asks for it, as `emit_with` does (`a_scalar_result_needs_no_exec`). - The `lower::Parts` sites main added in tests (crosslane, memory, synthetic, lower's) pass `console_cf: false`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… branch Conflicts: - emit/lower.rs, lane-mask joins: the branch's console-flow masks (constants and masks built from scalars, `st.other`) feed main's `match`, which keeps main's path for data joined with masks at a uniform join (the BVH walks) and keeps `no_mask_lane_on_edge` out of the console flow, after kawaii-shakal's notes on Marvisak#439. - emit/lower.rs's tests now live in emit/lower/tests.rs (moved on the console flow branch): the branch's `per_lane_only: false` lines are ported there, and the `lowers` helper keeps the per-lane form where the console flow cannot lower a program, as `emit_with` does here. - The `lower::Parts` sites main added in tests (crosslane, memory, synthetic, lower's) pass `per_lane_only: false`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… LDS branch Conflicts: - emit/lower.rs: the branch's `numeric` and main's `scalar_def`, `sgpr_operand` and `scalar_constant` were added side by side; both are kept. - `ds_bpermute_b32`: main's lowering, which adds the reader's half as the base only for wave64 programs, so a wave32 program reads no `waveGetLaneIndex` (main's `ds_bpermute_wave64_preserves_32_lane_half`), as kawaii-shakal noted. The lane is the same as the branch's in both cases. The comment keeps main's ISA reference and the branch's note on programs split in halves. - lower.rs's tests now live in emit/lower/tests.rs (moved on the console flow branch): the branch's one change to them (`lower_wave` names `crate::emit::Target::ANY`) is ported there. The branch's `select_tests` module stays in lower.rs, as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current
Still open on this head, as triage noted: crissuper20's GTX 1650 hang, and steven-seagull27's partial-group reduction fix. That fix is next, reviewed against this head. Synthetic tests only for this update; no title data used. AI-assisted |
Main's view-mark test builds emit::Options by hand; this branch adds a target field to Options, so the test now fills the rest from Default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Correction to my last comment: CI's clippy failed on the previous head. Main's view-mark draw test ( Verified on #223 AI-assisted |
Main's placed-UAV diagnostics test calls emit::emit with the six arguments it had before this branch added the target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Second follow-up: CI's diagnostics clippy ( Verified on #223 AI-assisted |
Machad3x reported the missing-upper-half minimum and proposed skipping the exchange at 32 threads or fewer in Marvisak#2214. Exercise a nonzero minimum and both sides of the host-wave boundary on the current Marvisak#439 stack. (cherry picked from commit 9cc76b8)
…gh bits Machad3x proposed the split f16 reduction in Marvisak#2214. Exercise both halves of the packed source word for full, lower-forty and upper-half EXEC masks. (cherry picked from commit 591c51c)
The split-halves f16 sum test dispatches only on hardware adapters, so CI and WARP runs check its translation, not which lane gives the high half. Assert that the scan ending in lane 31 leaves Shape::Half with lane 31 (and 63 for the other form), and that the sum translates for groups of 32 and 48 threads as well as 64. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks to Machad3x for finding both problems in #2214 and proposing the fixes, and to @steven-seagull27 for the two branches (9cc76b8, and the f16 sums in fork PR r4tedx#19). Both are taken as they are, with their authorship, plus one small test of ours. The head is now
What we could check here (WARP only):
With No title data was used. AI-assisted |
|
@r4tedx here it is, as a patch against #233's head What it does in the console flow, one console wave per group:
#320 and #439 cover the same ground. Your LDS barrier comes before each access, and your sections now handle partial groups and f16. So this is more for comparison than to merge as it is. Tests: five new ones in
On an RTX 4090 (split) and the Radeon iGPU of a Ryzen 9 7950X3D (native wave64), all 17 The whole The frame-80 result in my earlier comment came from this change on a 63bcca4 stack. Patch against 87d1f42diff --git a/crates/victory-shader/src/emit/lower.rs b/crates/victory-shader/src/emit/lower.rs
index 4b7e321..53e16d9 100644
--- a/crates/victory-shader/src/emit/lower.rs
+++ b/crates/victory-shader/src/emit/lower.rs
@@ -668,16 +668,38 @@ impl<'a> Lower<'a> {
&& (0..p.blocks.len()).all(|b| super::wave::sections(p, b).is_empty());
// The rest of such programs need the halves to exchange values
// (masks read whole, lanes of the other half): the console flow,
- // for a group of one console wave without LDS.
- wants_console_flow = console_lanes
+ // for a group of one console wave.
+ // LDS: a group barrier follows each access (`Lower::inst`); whole-wave
+ // sections: each half reduces its lanes and the halves exchange
+ // (`Lower::console_shape`), so a permute inside one is the
+ // simulation's; one outside reads lanes the halves do not exchange.
+ let permute_outside = (0..p.blocks.len()).any(|b| {
+ let secs = super::wave::sections(p, b);
+ p.blocks[b].insts.iter().enumerate().any(|(i, inst)| {
+ inst.name().contains("permute")
+ && !secs.iter().any(|(&start, sec)| i > start && i < sec.end)
+ })
+ });
+ // (A group of one console wave sharing LDS needs the halves ordered
+ // too, even without lane reads.)
+ let one_console_wave = cs.threads.iter().product::<u32>() <= 64;
+ let has_sections = (0..p.blocks.len()).any(|b| !super::wave::sections(p, b).is_empty());
+ let any_permute = insts().any(|i| i.name().contains("permute"));
+ // LDS and whole-wave sections only in programs that do not reach title
+ // memory by address: in the console flow every lane runs every block,
+ // and a lane the console wave had left out would load from whatever
+ // address it holds (the ray-tracing structure builder's stages, which
+ // also run all or none: run them partly and their stores land on
+ // garbage offsets).
+ let plain = s.lds_dwords == 0 && !has_sections && !any_permute;
+ let extended = !root_memory && !permute_outside;
+ wants_console_flow = (console_lanes || !root_memory && one_console_wave && s.lds_dwords > 0)
&& !split
&& x.native.wave64
&& !x.target.runs(64)
&& x.target.runs(32)
- && s.lds_dwords == 0
- && cs.threads.iter().product::<u32>() <= 64
- && !insts().any(|i| i.name().contains("permute"))
- && (0..p.blocks.len()).all(|b| super::wave::sections(p, b).is_empty());
+ && one_console_wave
+ && (plain || extended);
if x.console_cf {
console_lanes = true;
split = true;
@@ -1319,7 +1341,10 @@ impl<'a> Lower<'a> {
{
return Err("a wave reduction in a mesh shader");
}
- if self.split {
+ // In the console flow both halves run the section (every lane runs
+ // every block): each half's result over its own lanes, then the two
+ // combined through the halves' exchange (below).
+ if self.split && !self.console_cf {
return Err("a wave reduction in a wave64 program split in halves");
}
let c = self.cur;
@@ -1334,6 +1359,9 @@ impl<'a> Lower<'a> {
let id = self.s.m.i32(ident);
let x = self.s.m.select(c, on, x, id);
self.s.flags |= flags::WAVE_OPS;
+ if self.console_cf {
+ return self.console_shape(op, prefix, x);
+ }
let float = matches!(op, Op::AddF | Op::MinF | Op::MaxF);
let (i32t, f32t) = (self.s.t.i32, self.s.t.f32);
let arg = if float { self.as_float(x) } else { x };
@@ -1389,6 +1417,108 @@ impl<'a> Lower<'a> {
Ok(if float { self.as_int(r) } else { r })
}
+ /// Console flow: a whole-wave section's reduction or prefix of `x` (each
+ /// lane's input, the identity where the section's mask leaves it out)
+ /// over the console wave's 64 lanes, which are two host waves of 32.
+ /// Each half reduces its own lanes; the halves exchange those results
+ /// ([`Self::exchange`]): a reduction combines both, a prefix adds the
+ /// lower half's total in the upper half.
+ fn console_shape(&mut self, op: super::wave::Op, prefix: Option<bool>, x: V) -> Result<V, Why> {
+ use super::wave::Op;
+ let c = self.cur;
+ let float = matches!(op, Op::AddF | Op::MinF | Op::MaxF);
+ let (i32t, f32t) = (self.s.t.i32, self.s.t.f32);
+ let arg = if float { self.as_float(x) } else { x };
+ let ty = if float { f32t } else { i32t };
+ let sfx = if float { "f32" } else { "i32" };
+ let reduce = |me: &mut Self, arg: V| -> V {
+ match op {
+ Op::Or | Op::And | Op::Xor => {
+ let k = me.s.m.i8(match op {
+ Op::And => 0,
+ Op::Or => 1,
+ _ => 2,
+ });
+ me.s.op(c, "waveActiveBit.i32", Attr::NoUnwind, i32t, 120, &[arg, k])
+ }
+ _ => {
+ let (code, unsigned) = match op {
+ Op::AddU => (0, 1),
+ Op::AddF => (0, 0),
+ Op::MinU => (2, 1),
+ Op::MaxU => (3, 1),
+ Op::MinI | Op::MinF => (2, 0),
+ _ => (3, 0),
+ };
+ let (k, u) = (me.s.m.i8(code), me.s.m.i8(unsigned));
+ me.s.op(c, &format!("waveActiveOp.{sfx}"), Attr::NoUnwind, ty, 119, &[arg, k, u])
+ }
+ }
+ };
+ let bits = |me: &mut Self, v: V| if float { me.as_int(v) } else { v };
+ let value = |me: &mut Self, v: V| if float { me.as_float(v) } else { v };
+ match prefix {
+ Some(inclusive) => {
+ if !matches!(op, Op::AddU | Op::AddF) {
+ return Err("a wave prefix of an operation other than a sum");
+ }
+ let (k0, k1) = (self.s.m.i8(0), self.s.m.i8(1));
+ let mut r =
+ self.s.op(c, &format!("wavePrefixOp.{sfx}"), Attr::NoUnwind, ty, 121, &[arg, k0, k1]);
+ if inclusive {
+ r = self.s.m.bin(c, Bin::Add, r, arg);
+ }
+ // The upper half's lanes follow the lower half's.
+ let total = reduce(self, arg);
+ let total = bits(self, total);
+ let (lo, _) = self.exchange(c, total);
+ let lo = value(self, lo);
+ let (_, half) = self.console_lane();
+ let z = self.s.m.i32(0);
+ let upper = self.s.m.cmp(c, pred::NE, half, z);
+ let zero = if float { self.as_float(z) } else { z };
+ let add = self.s.m.select(c, upper, lo, zero);
+ let r = self.s.m.bin(c, Bin::Add, r, add);
+ Ok(bits(self, r))
+ }
+ None => {
+ let mine = reduce(self, arg);
+ let mine = bits(self, mine);
+ let (lo, hi) = self.exchange(c, mine);
+ let r = match op {
+ Op::AddU => self.s.m.bin(c, Bin::Add, lo, hi),
+ Op::Or => self.s.m.bin(c, Bin::Or, lo, hi),
+ Op::And => self.s.m.bin(c, Bin::And, lo, hi),
+ Op::Xor => self.s.m.bin(c, Bin::Xor, lo, hi),
+ Op::AddF => {
+ let (a, b) = (self.as_float(lo), self.as_float(hi));
+ let s = self.s.m.bin(c, Bin::Add, a, b);
+ self.as_int(s)
+ }
+ Op::MinF | Op::MaxF => {
+ let (a, b) = (self.as_float(lo), self.as_float(hi));
+ // dx.op FMax 35, FMin 36.
+ let code = if op == Op::MaxF { 35 } else { 36 };
+ let m = self.binary(code, a, b);
+ self.as_int(m)
+ }
+ Op::MinU | Op::MaxU | Op::MinI | Op::MaxI => {
+ let p = match op {
+ Op::MinU => pred::IULT,
+ Op::MaxU => pred::IUGT,
+ Op::MinI => pred::SLT,
+ _ => pred::SGT,
+ };
+ let take_lo = self.s.m.cmp(c, p, lo, hi);
+ self.s.m.select(c, take_lo, lo, hi)
+ }
+ Op::AddH => return Err("a 16-bit wave reduction in the console flow"),
+ };
+ Ok(r)
+ }
+ }
+ }
+
fn run(mut self) -> Result<Lowered, Stop> {
if self.wants_console_flow && !self.x.console_cf {
return Err(unsupported(0, CONSOLE_FLOW));
@@ -3730,7 +3860,26 @@ impl<'a> Lower<'a> {
Fields::Image { .. } => self.image(inst, b, i),
Fields::Buffer { .. } => self.buffer(inst, b, i),
Fields::Exp { .. } => self.export(b, i),
- Fields::Ds { .. } => self.ds(inst, b, i),
+ Fields::Ds { .. } => {
+ let r = self.ds(inst, b, i);
+ // Console flow: the console wave runs an LDS instruction in all
+ // its lanes before the next, and its compiler leaves out the
+ // barriers between lanes of one wave. Here its two halves are
+ // two host waves: each LDS access is followed by a group
+ // barrier, which both halves reach (every lane runs every block,
+ // `CONSOLE_FLOW`), so one half's accesses are done before the
+ // other's next.
+ if self.console_cf
+ && r.is_ok()
+ && !(name.starts_with("ds_swizzle") || name.contains("permute"))
+ {
+ let mode = self.s.m.i32(1 | 8);
+ let void = self.s.t.void;
+ self.s
+ .op(self.cur, "barrier", Attr::NoDuplicate, void, 80, &[mode]);
+ }
+ r
+ }
Fields::Flat { .. } if name.starts_with("global_") => self.flat(inst, b, i),
Fields::Flat { .. } => Err("flat memory"),
};
diff --git a/crates/victory-shader/src/emit/split_tests.rs b/crates/victory-shader/src/emit/split_tests.rs
index 2f096fa..8e95530 100644
--- a/crates/victory-shader/src/emit/split_tests.rs
+++ b/crates/victory-shader/src/emit/split_tests.rs
@@ -433,3 +433,170 @@ fn a_mask_copied_dword_by_dword_stops_instead_of_recursing() {
assert!(e.contains(why), "{lanes_min}..{lanes_max}: {e}");
}
}
+
+/// The console compiler's whole-wave sum (HLSL `WaveActiveSum` on wave64:
+/// DPP within rows, `v_permlanex16` across rows, `v_readlane` 32 across
+/// the halves), as the tile classifier `bad01f53f53248e5` has it: each
+/// half sums its own lanes and the halves exchange.
+const SECTION_SUM: &[u32] = &[
+ 0xBE80_25C1, // s_or_saveexec_b64 s[0:1], -1
+ 0xD501_0002,
+ 0x0002_2080, // v_cndmask_b32 v2, 0, v16, s[0:1]
+ 0x4A04_04E9,
+ 0xDE54_C102, // v_add_nc_u32 v2, v2, v2 dpp8:[1,0,3,2,5,4,7,6]
+ 0x4A04_04E9,
+ 0x9360_1202, // v_add_nc_u32 v2, v2, v2 dpp8:[2,2,0,0,6,6,4,4]
+ 0x4A04_04E9,
+ 0x0009_2402, // v_add_nc_u32 v2, v2, v2 dpp8:[4,4,4,4,0,0,0,0]
+ 0x4A04_04FA,
+ 0xFF09_4002, // v_add_nc_u32 v2, v2, v2 row_mirror bound_ctrl:1
+ 0xD778_0003,
+ 0x0201_0102, // v_permlanex16_b32 v3, v2, 0, 0
+ 0x4A04_0503, // v_add_nc_u32 v2, v3, v2
+ 0xD760_0002,
+ 0x0001_4102, // v_readlane_b32 s2, v2, 32
+ 0x4A04_0402, // v_add_nc_u32 v2, s2, v2
+ 0xD760_000C,
+ 0x0001_0102, // v_readlane_b32 s12, v2, 0
+ 0xBEFE_0400, // s_mov_b64 exec, s[0:1]
+];
+
+/// The console compiler's whole-wave exclusive prefix sum of v16 into v3
+/// (rows by DPP shifts, rows of 16 by `v_permlanex16`, the upper half
+/// after lane 31 of the lower), as `bad01f53f53248e5` has it.
+const SECTION_PREFIX: &[u32] = &[
+ 0xBE8A_25C1, // s_or_saveexec_b64 s[10:11], -1
+ 0xD501_0002,
+ 0x002A_2080, // v_cndmask_b32 v2, 0, v16, s[10:11]
+ 0x7E06_0302, // v_mov_b32 v3, v2
+ 0x4A06_06FA,
+ 0xFF09_1103, // v_add_nc_u32 v3, v3, v3 row_shr:1 bound_ctrl:1
+ 0x4A06_06FA,
+ 0xFF01_1203, // v_add_nc_u32 v3, v3, v3 row_shr:2
+ 0x4A06_06FA,
+ 0xFF01_1403, // v_add_nc_u32 v3, v3, v3 row_shr:4
+ 0x4A06_06FA,
+ 0xFF01_1803, // v_add_nc_u32 v3, v3, v3 row_shr:8
+ 0xBEFE_03FF,
+ 0xFFFF_0000, // s_mov_b32 exec_lo, 0xffff0000
+ 0xBEFF_03FF,
+ 0xFFFF_0000, // s_mov_b32 exec_hi, 0xffff0000
+ 0xD778_4804,
+ 0x0305_8303, // v_permlanex16_b32 v4, v3, -1, -1 fi:1
+ 0x4A06_0704, // v_add_nc_u32 v3, v4, v3
+ 0xD760_000D,
+ 0x0001_3F03, // v_readlane_b32 s13, v3, 31
+ 0xBEFE_0380, // s_mov_b32 exec_lo, 0
+ 0xBEFF_03C1, // s_mov_b32 exec_hi, -1
+ 0x4A06_060D, // v_add_nc_u32 v3, s13, v3
+ 0xBEFE_03C1, // s_mov_b32 exec_lo, -1
+ 0xBEFF_03C1, // s_mov_b32 exec_hi, -1
+ 0x4C06_0503, // v_sub_nc_u32 v3, v3, v2
+ 0xBEFE_040A, // s_mov_b64 exec, s[10:11]
+];
+
+/// Lane 0 alone in EXEC (s[14:15] keeps the whole wave's).
+const LANE_0_ONLY: &[u32] = &[
+ 0x7D84_0080, // v_cmp_eq_u32 vcc, 0, v0
+ 0xBE8E_246A, // s_and_saveexec_b64 s[14:15], vcc
+];
+const WHOLE_AGAIN: u32 = 0xBEFE_040E; // s_mov_b64 exec, s[14:15]
+
+fn joined(parts: &[&[u32]]) -> Vec<u32> {
+ parts.iter().flat_map(|p| p.iter().copied()).collect()
+}
+
+/// A whole-wave sum over every lane of the console wave: both halves'.
+#[test]
+fn whole_wave_sums_add_both_halves() {
+ let body = joined(&[
+ &[0x7E20_0300], // v_mov_b32 v16, v0
+ SECTION_SUM,
+ &[0x7E04_020C], // v_mov_b32 v2, s12
+ ]);
+ console_flow_case("whole-wave sum of lane ids", &body, 64, |_| (0..64).sum());
+}
+
+/// The classifier's append: lane 0 alone in EXEC, the sum of its 8.
+#[test]
+fn whole_wave_sums_of_one_lane() {
+ let body = joined(&[
+ &[0x7E20_0288], // v_mov_b32 v16, 8
+ LANE_0_ONLY,
+ SECTION_SUM,
+ &[WHOLE_AGAIN, 0x7E04_020C], // s_mov_b64 exec, s[14:15]; v_mov_b32 v2, s12
+ ]);
+ console_flow_case("whole-wave sum of lane 0's 8", &body, 64, |_| 8);
+}
+
+/// An exclusive prefix over the console wave: lanes of the upper half
+/// count every lane of the lower one.
+#[test]
+fn whole_wave_prefixes_run_on_from_the_lower_half() {
+ let body = joined(&[
+ &[0x7E20_0281], // v_mov_b32 v16, 1
+ SECTION_PREFIX,
+ &[0x7E04_0303], // v_mov_b32 v2, v3
+ ]);
+ console_flow_case("exclusive prefix of ones", &body, 64, |t| t);
+}
+
+/// The classifier's offsets: lane 0 alone gives 8; the section writes every
+/// lane, past lane 0 the prefix is 8.
+#[test]
+fn whole_wave_prefixes_of_one_lane() {
+ let body = joined(&[
+ &[0x7E20_0288], // v_mov_b32 v16, 8
+ LANE_0_ONLY,
+ SECTION_PREFIX,
+ &[WHOLE_AGAIN, 0x7E04_0303], // s_mov_b64 exec, s[14:15]; v_mov_b32 v2, v3
+ ]);
+ console_flow_case("exclusive prefix of lane 0's 8", &body, 64, |t| if t == 0 { 0 } else { 8 });
+}
+
+/// [`console_flow_case`] for a program with 512 bytes of LDS.
+fn lds_flow_case(label: &str, body: &[u32], threads: u32, want: impl Fn(u32) -> u32) {
+ let Ok(names) = adapters() else {
+ eprintln!("no DXGI; skipped");
+ return;
+ };
+ for name in names {
+ let Ok(host) = Host::on(&name) else {
+ continue;
+ };
+ let mut p = program(body, threads);
+ if let StageIo::Cs(cs) = &mut p.io {
+ cs.rsrc2 |= 1 << 15;
+ }
+ let split = !host.target().runs(64);
+ let groups = 2;
+ let out = run(&host, &p, groups).unwrap_or_else(|e| panic!("{name}: {label}: {e}"));
+ let expect: Vec<u32> = (0..groups).flat_map(|_| (0..threads).map(&want)).collect();
+ assert_eq!(out, expect, "{name}: {label}, {threads} threads (split {split})");
+ eprintln!("{name}: {label}, {threads} threads exact (split {split})");
+ }
+}
+
+/// LDS the console wave shares without barriers (its compiler leaves them
+/// out within one wave): lane 0 clears a counter, every lane adds 1, every
+/// lane reads it. Both halves' adds land before either half reads.
+#[test]
+fn lds_shared_within_the_console_wave_orders_both_halves() {
+ let body = joined(&[
+ &[0x7E02_0280, 0x7E08_0281], // v_mov_b32 v1, 0; v_mov_b32 v4, 1
+ LANE_0_ONLY,
+ &[
+ 0xD834_0000,
+ 0x0000_0101, // ds_write_b32 v1, v1
+ 0xBF8C_C07F, // s_waitcnt lgkmcnt(0)
+ WHOLE_AGAIN,
+ 0xD800_0000,
+ 0x0000_0401, // ds_add_u32 v1, v4
+ 0xBF8C_C07F, // s_waitcnt lgkmcnt(0)
+ 0xD8D8_0000,
+ 0x0200_0001, // ds_read_b32 v2, v1
+ 0xBF8C_C07F, // s_waitcnt lgkmcnt(0)
+ ],
+ ]);
+ lds_flow_case("LDS counter of the whole wave", &body, 64, |_| 64);
+} |
…le memory On a host without 64-lane waves, a wave64 program that reaches title memory by address (root_memory) no longer takes the console flow in halves when it also shares LDS, has whole-wave sections or permutes lanes; it stops with a reason instead. Programs that only exchange lanes or read masks whole keep the console flow, and hosts with 64-lane waves are unchanged. latentdev found the limit (patch on Marvisak#439 against 87d1f42): without it the ray-tracing structure builder stages caa78b8ca62bc3d6 and 28918b7150a7aad5 translated, part of the builder ran and the GPU hung on an RTX 4090. Offline at 32-32 the XboxBvhBuilder.dll programs at 0x25c40 and 0x28770 (those two) validated before and are refused now; the other 50 programs are unchanged. The check lives in emit/lower/console.rs (lower.rs is near the file size limit). The test builds an LDS program with and without a load from an address it makes: refused at 32-32 only with the load, both translate with 64-lane waves. Co-authored-by: latentdev <3763127+latentdev@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ctions Five split_tests hand-assembled by latentdev from the tile classifier bad01f53f53248e5's own code (patch on Marvisak#439 against 87d1f42): a whole-wave sum over every lane and over lane 0 alone, an exclusive prefix over every lane and over lane 0 alone, and an LDS counter both halves add to before either reads it. Adapted to the stack's helpers: the LDS case uses program_lds and program_case. Each test also checks, without an adapter, that the program translates for a 32-lane host in halves (wave size 32) and validates where a validator is installed; the values are checked on hardware adapters only. latentdev ran them exact on an RTX 4090 (in halves) and a Radeon 7950X3D iGPU (native wave64) with their patch. Co-authored-by: latentdev <3763127+latentdev@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Thanks @latentdev. The I compared your patch (against
Offline only, I translated
Pushed as a fast-forward to
Checks on the software adapter (WARP), one test thread:
I can't run tests on hardware here, so the five tests' values have only been checked on your two adapters, and only with your patch. A run of AI-assisted |
nathanbzrr
left a comment
There was a problem hiding this comment.
Reviewed updated 7587052 (through e2d3cfd + 7587052 vs main 63bcca4) on Windows 11 with AMD Radeon RX 7600 (native Wave64) and WARP:
git merge-treeagainstmain(63bcca4): clean (4dbc0d507237c0e5b5dba90fdc87083c2f859839),crates/victory-shader/src/emit/lower.rsis506,876bytes.cargo run -p xtask --locked -- policy:asset policy: 195 files ok.cargo clippy -p victory-shader --all-targets --locked -- -D warnings(default &--all-features): clean.cargo test -p victory-shader --lib --locked split_tests -- --nocapture --test-threads=1(RX 7600):41 passed; 0 failed(32.68s) — includes the 6 newly added tests (lds_in_halves_keeps_out_of_programs_reaching_title_memory,whole_wave_sums_*,whole_wave_prefixes_*,lds_shared_within_the_console_wave_orders_both_halves); RX 7600 executions loggedsplit false(zero native Wave64 regression).VICTORY_WARP=1 cargo test -p victory-shader --lib --locked split_tests -- --nocapture --test-threads=1:41 passed; 0 failed(0.18s) —translates_in_halves(32-lane Wave32 DXIL lowering + DXIL validator) andsgpr_spills_across_a_divergent_branch_stay_per_lane(Host::new(true)) ran cleanly, whileadapters()tests skip WARP (host.rs:105-107).cargo test -p victory-shader --lib --locked -- --test-threads=1(RX 7600):353 passed; 0 failed; 3 ignored(153.89s).
Notes:
e2d3cfd'scrates/victory-shader/src/emit/lower/console.rs(leaves_title_memory_out) cleanly gatesone_waveLDS, whole-wave sections, and*permute*(includingds_bpermute_b32) out of console-flow halves whenroot_memoryis true (lower.rs:829-830), and7587052's unit/validator tests cover both the gate and the whole-wave sum/prefix/LDS patterns on Wave32 targets.- Minor doc note: the PR description body still cites
e9f18c9beforee2d3cfd/7587052. - Hardware scope note: no hardware 32-lane GPU (e.g., NVIDIA) was available on this host, so runtime execution of the split 32-lane LDS barrier / section tests is verified via Wave32 DXIL lowering + validator and RX 7600 native Wave64 (
split false), not hardware 32-lane silicon.
AI-assisted; synthetic tests only, no game files.
|
Thanks @nathanbzrr. The description now names head |
Current head
7587052(2026-11-26), on top ofe9f18c9below, still withmainat63bcca4(merge-tree clean). New sincee9f18c9: the placed-UAV test fix merged up from #223; steven-seagull27's partial-group reductions and f16 whole-wave sums from fork PR #19 (611184e,f968c54, author kept) and2658128;e2d3cfdkeeps LDS, whole-wave sections and*permute*in halves out of programs that reach title memory (root_memory, from latentdev's patch);7587052adds latentdev's console-flow tests (co-authored). lower.rs is 506,876 bytes. At7587052, WARP only:cargo xtask policyok, clippy clean,VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- --test-threads=1349 passed, 4 failed, 3 ignored (2658128: 343 / 4 / 3; the same 4mainfailures as below). nathanbzrr's review ran the shader tests at7587052on an RX 7600 (native 64-lane): 353 passed, 0 failed. Nobody has run these split tests on 32-lane hardware at7587052. No title run for this update.At
e9f18c9, merged withmainat63bcca4(merges only, no rebase:maininto #223, then each PR's new head into the one above it). Withmain's growth,crates/victory-shader/src/emit/lower.rswould pass the asset policy's 512 KiB limit, so #233 first moves lower.rs's inline tests intoemit/lower/tests.rs, unchanged but for one indent level, (desplmfao's idea, besidemain'semit/lower/bvh.rs). Here lower.rs is 506,583 bytes. The conflict resolutions follow kawaii-shakal's notes, and each merge commit lists them. Local verification at this head and at the head of each PR under it, on Windows 11 with the software renderer only (WARP, no hardware adapter for this update):cargo xtask policyok;cargo clippy --locked -p victory-shader --all-targets -- -D warningsclean;VICTORY_WARP=1 cargo test --locked -p victory-shader --lib -- --test-threads=1: 341 passed, 4 failed, 3 ignored. The 4 failures aremain's own: onmain63bcca4the same command gives 298 passed and the same 4 failed. They aresynthetic_testswhose "hardware" passVICTORY_WARP=1puts on WARP. No title run for this update. AI-assisted (Claude).Stacked on #320, which is on #233, which is on #223. They are one line of work and merge in that order; each PR's diff contains the ones under it. The commits that are new here start at
7388024(table below). Head:7587052.History, 2026-11-24: The whole stack was rebased onto
main8e79c80on 2026-11-24 (upstream merged about 55 PRs that day and added CI). New upstream tests callemitand buildlower::Partsdirectly, so the wave-range argument and the two fields this stack adds are given to them in the commits that introduce them (in #223, #233 and #320). CI's first run on these PRs failed in tests, not in clippy: GitHub's runner has no GPU and lists Windows' software renderer (4-lane waves) as an adapter, and tests here assumed every listed adapter runs 32-lane waves. The tests are fixed where they were introduced: the hardware-adapter list leaves that renderer out by its ids and name, and the one test that takes the default device accepts a host without 32-lane waves. No translator code changed. The test-only commite6936e3(the lane-read loop test skips hosts without SM 6.6) is folded into #320, where that test is added, so 16 commits are new here. Each commit builds on its own. The head before the rebases was055aef9. Commit ids in testers' reports below and in older comments are from before the rebases; the table gives each commit's old id.No new features will be added to this PR. It has grown as testers and contributors reported things; from here it only gets fixes for what review finds. The next step of the work (groups of more than 64 threads) is on a fork branch and is not part of this.
What
#233 runs console wave64 compute programs on hosts without 64-lane waves (NVIDIA) as two 32-lane waves, in the "console flow" where a program needs its whole wave. It still stopped programs that share LDS inside one wave, and a few other forms. This PR takes those:
s_barrier. The console runs an instruction in all 64 lanes before the next, so a lane reads what another lane wrote one instruction earlier. In the console flow both halves reach every LDS access together, so a group barrier before each access puts it after every earlier one.ds_bpermute_b32, which did not translate on any host: a read within the lane's own 32-lane half.... in a group of more than 64 threads,ds_permute across the halves,a whole-wave section), and atranslate --validateline that prints a failing module's thread-group size, wave size anddx.opnames.Nothing changes for programs that translated before, with two exceptions measured below: on hosts that run 64-lane waves about 18 title programs with a lane read in a divergent branch change from the per-lane form to the console flow, and programs both forms refuse may report a different reason.
Commits new in this PR
7388024one_wave_shares_lds_in_instruction_order,lds_order_holds_when_one_half_is_busy88cb024c7806a8translate --validateprints what a refused module declares and callsthe_last_modules_summary_...9745f35a31c82e9b73d66b0f64c9,6090b47whole_wave_reductions_join_both_host_waves,masked_whole_wave_sum_straddles_the_halves3925b8f,e49302afa72507lds_written_and_read_in_different_masked_blocksa32c177ddaae368876ed3ab7882dds_bpermute_b32as an in-half read (r4tedx/VIctory#2)416714c826577ebackward_permute_in_other_masks_groups_and_formsf653ea400888acfloat_whole_wave_reductions_join_both_host_waves,masked_and_prefix_float_sums_cross_the_halves965ce30783feee2467891e461457v_cndmask_b32takes masks held as numbers; fixes the high dword of such a wave64 mask when two instructions write itselects_on_masks_held_as_numbersd2189ff1c06eddlane_read_loop_with_a_joined_exec_back_edge9e98b2b04971f8901eef9f12df1elane_reads_in_branches_beside_a_whole_wave_section,a_mask_copied_dword_by_dword_stops_instead_of_recursinge4d899f1ca87f7d2189ff)selects_from_independently_written_mask_words055aef9Measured
On the title, by testers on their own copies
RTX 3070 Ti Laptop, driver 610.88, four-build comparison: across three runs containing #439, DRED named compute
42683eebec081520, dispatched as(128, 64, 1), at device removal on its first world dispatch. Onmainthe driver refused this pipeline and the run later hung inExecuteIndirect. With #578 alone the run lasted 420 s and dropped 85–98% of world draws. The separate RTX 3070 skip run below used a different stack and driver.On an RTX 3070 with the #439
1ca87f7integration stack and loop limit 32, skipping direct and indirect dispatches of42683eebec081520still ended in device removal at menu frame 1880. DRED named an indirect mesh operation with a nullu9and empty breadcrumbs. The faulting operation is undetermined. RTX 3070 skip run9745f35: againstmain, 71 compute programs gained and 0 lost; ofmain's 119 driver-refused programs 70 run. The LDS reason goes from 38 to 0.f653ea4, whole-title translate with pipelines: 0 pipelines refused; the LDS reason 120 → 0; compute programs emitted 1,470 (at Shaders: wave64 compute on 32-lane hosts, in halves and in the console flow #233) → 1,668.e49302a: againstmain, 0 validation or pipeline results change over 25,889 programs. This is the host the stack is meant to leave alone.f653ea4, in the PR set that stays in the world on #71, against the same set with #189 (loop limit 32, one 7-minute run each): no device removal with either. With this stack, draws dropped for want of a host pipeline go from 1,470 to 958 per frame, and the richest G-buffer target in a dumped frame is 67.9% covered by a coherent view against 10.5% with wrong geometry. The presented frame is black in both, and this stack's frame time is higher (1,233 ms against 850 ms).Nobody has run the title on a head after
f653ea4. The world hang (#71) is unchanged by this stack at the default loop limit.Locally: an offline translate over a local copy of the title's shaders
victory translate --host-lanes 32-32 --validate --list(and32-64): CPU only, no pipelines, nothing launched or rendered. Counts and reasons only; nothing from the title is in this PR. At055aef9(before the rebases), and again after the first rebase onmain2e4e280with the same results; not rerun on8e79c80, which merged more shader PRs:main. A tester's count atf653ea4(1,668) matches mine at that head. For a 32..64 host: 1,735 emitted, 1,681 validated, which a tester measured independently on an RX 9070 with pipelines created (1,735 / 1,681 / 1,735).sample(see the note below).e4d899frule +6 (32..32) and +12 (32..64), numeric selects +3 (32..64 only). On the tester tree, which has the descriptor PRs, the numeric-select commit is worth 24.e4d899fnow take the console flow (they have a lane read in a divergent branch beside a whole-wave section).Validation note
Compute programs that sample with implicit derivatives (
image_sample) are emitted asdx.op.sample, which validator 1.6 / 1.7 rules do not allow outside pixel shaders.mainemits 23 such modules; this stack lets more such programs translate, so more of them appear (54 here). The cause is not in this stack: diagnosis with a hand-assembled reproduction. #180 replaces these samples and #201 tracks the class; a census rerun measured #180 taking the class to 0 onmain. Merging #180 first, or together, keeps those modules from reaching a driver unvalidated.How this relates to other open PRs
PSV0, so it does not refuse what this stack emits.docs/wave64-on-wave32.mdshows as deleted in this diff, with this PR's plan text in it: #233 folded the plan intodocs/architecture.md, and the merge carries that up. The design notes are in this description.Not verified
ds_bpermute_b32stays in each half: AMD, "RDNA 2" Instruction Set Architecture Reference Guide (30 Nov 2020), §10.4.4 "LDS Lane-permute Ops", pp. 96–97: "in wave64 mode the permute operates only across 32 lanes at a time of each half of a wave64 … it executes as if were two independent wave32's. Each half-wave can use indices in the range 0-31 to reference lanes in that same half-wave", "only index bits [6:2] are used", "Reading from disabled lanes returns zero". The lowering follows this (lane((addr + offset) >> 2) & 31in the reader's half, 0 where it is inactive). The opcode table's pseudocode (§12.13, p. 206) writesmod 64, which disagrees with §10.4.4; we follow §10.4.4.ds_permute_b32is not translated yet and still keeps a program out of the split.f653ea4has been run in the title, by anyone. The local run only translates and validates.s_mov_b32) stop with a reason; following them is not done.Tested
Historical, at an earlier head: Independent Windows 10 22H2 run on an RTX 4060 Ti at
c153b21with #175 and #362: 155 shader tests passed, 0 failed, 1 benchmark ignored. The split-wave and joined-back-edge tests executed on hardware and returned exact results. WARP, DXIL validation, and compiler-dependent comparisons had skips. Hardware run and skip breakdownWindows 11, an NVIDIA RTX 5070 (32..32) and an AMD Radeon iGPU (RDNA2, 32..64) in one machine. Every test in the table is hand-assembled GFX10, validated by
dxil.dll, dispatched on each hardware adapter and compared lane by lane with the console's result, except the two that only check what the translator emits (the_last_modules_summary_...,selects_from_independently_written_mask_words).main63bcca4: At1ca87f7, onmain8e79c80, with the commands upstream's CI runs:cargo clippy --workspace --all-targets --locked -- -D warningsand the same with--all-featuresare clean at the head of each of the four PRs;cargo test --workspace --locked: 346 passed, 0 failed, 6 ignored (RTX 5070 + Radeon iGPU). Under the CI runner's conditions emulated here (the software renderer as the default device and no hardware adapter listed) the shader crate's tests pass at each head, the GPU ones by skipping. Before the rebases,cargo test --workspaceat055aef9: 299 passed, 0 failed, 4 ignored.cargo xtask policy: ok at that head and, after the tests move, ate9f18c9.AI-assisted. The tests are synthetic and do not use the title. The counts under "Locally" come from the offline translate run described there.
🤖 Generated with Claude Code