Skip to content

Shaders: carry whole-wave integer scans across two 32-lane waves - #1

Merged
r4tedx merged 1 commit into
r4tedx:shader/console-flow-ldsfrom
Raxstreams:codex/whole-wave-prefix
Nov 24, 2026
Merged

r4tedx merged 1 commit into
r4tedx:shader/console-flow-ldsfrom
Raxstreams:codex/whole-wave-prefix

Conversation

@Raxstreams

Copy link
Copy Markdown

This follows Marvisak#439's console-flow lowering for one 64-thread group. An integer prefix sum on the upper host wave needs the lower wave's total. Exchange that total through the existing synchronized group storage. Integer reductions combine the two half-wave reductions using the original operator.

The regression dispatch sums the lane IDs from 0 through 63 and reads back every lane. All 15 split-wave tests passed on an RTX 3080 Ti on this branch. On a local integration build, this also allowed the material-tile initialization compute pass to dispatch during the opening scene. The final scene color is still under investigation.

The test data is synthetic.

@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you for this. It is the next step I had planned after Marvisak#439 (a title run there left a whole-wave section as the largest remaining reason), and it is a smaller change than what I had in mind: the section stays recognised as it is and only its result crosses the halves.

Tested at 9b73d66 on an NVIDIA RTX 5070 (32..32, console flow in two halves) and an AMD Radeon iGPU (RDNA2, 32..64, native), Windows 11, debug, every module through dxil.dll's validator first:

  • cargo test --workspace: 285 passed, 0 failed, 4 ignored. wave64_inclusive_prefix_joins_both_host_waves is exact on both adapters. cargo clippy -p victory-shader --all-targets: nothing new; the touched files are rustfmt-clean.
  • With a trace in the two new branches: that test only goes through the prefix carry. The reduction branch (exchange(c, r) and the match op) is never taken by it. So I added cases for it locally, reusing your scan and reading lane 63 inside the section; all exact on both adapters:
case console's result which half holds the answer
sum of the lane ids 2016 in every lane both
v_max_u32 63 upper
v_min_u32 (identity -1) 0 lower
v_or_b32 63 both
sum over a mask of lanes below 40 (32 in the lower half, 8 in the upper) 780 in those lanes, the others untouched both
  • Groups of 48 and 32 threads with a section still stop with the section reason; 64 translates.

Read, and agree with:

  • The carry being a sum is right: shape only makes prefix scans for AddU / AddF, and floats are refused before it.
  • The total is taken over the already masked value, so lanes outside the mask add the identity.
  • The exchange is emitted where the section is lowered, in straight-line code of its block, not at a use and not under a lane guard, so both halves reach its barriers.

Things I would change or state:

  1. The wave.rs change (v_permlanex16 only with EXEC on every lane or FI set) applies to every host, the per-lane form on 64-lane hosts included, and Shaders: model v_permlane16_b32 in whole-wave sections Marvisak/VIctory#98 edits the same match. It looks right to me (without FI a lane outside EXEC reads as 0, which the simulation did not model), but it is a separate fix from this one: please say so in the description, or split it out.
  2. Float minimum and maximum could cross the halves the same way and stay exact (a float sum cannot: the order differs). Fine to leave refused; worth a line in the description.
  3. Every value a section leaves costs one exchange, which is two group barriers. Not measured.
  4. The test body uses v2 as scratch in every lane (v_permlanex16 writes it under the section's full EXEC), so a caller must not expect an old v2 after it. I tripped over that writing the masked case.

Where this lands. Marvisak#439, which this is based on, is a draft upstream: a whole-title run found modules the console flow emits that dxil.dll refuses, and the cause is not known yet. This PR sends more programs through the console flow, so it would inherit that. Whether it goes into Marvisak#439's branch or stands as its own upstream PR on top of it is the fork owner's call; I have asked. If it goes in, I will add the cases above as a commit after yours.

No game data used on my side. AI-assisted.

@r4tedx
r4tedx merged commit 9b73d66 into r4tedx:shader/console-flow-lds Nov 24, 2026
@r4tedx

r4tedx commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Taken in: shader/console-flow-lds fast-forwarded to your commit, so it is part of Marvisak#439 under your name, followed by 3925b8f with the reduction and mask cases from the review. cargo test --workspace on that head: 288 passed, 0 failed, 4 ignored, on an RTX 5070 and a Radeon iGPU. The PR description upstream credits you and links the review.

The two points from the review that I would still like in a follow-up, from either of us: say in a commit message that the v_permlanex16 change in wave.rs applies to every host, and float minimum and maximum across the halves.

Thank you.

simnJS added a commit to MiamiGame/XTP that referenced this pull request Nov 24, 2026
…s them

The wave64 plan's header credited Peter Bonanni for the whole-wave
sections across the halves and the backward permutes, its section on
them Raxstreams. Both are right: the commits (VIctory #439's a31c82e
and ab7882d) are authored by Peter Bonanni (peter-bonanni), and the
GitHub account Raxstreams offered them as r4tedx/VIctory#1 and #2, as
#439's description says. Both places now say so.
r4tedx pushed a commit that referenced this pull request Nov 25, 2026
Exercise the descriptor cursor regression on the actual heap capacity
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.

3 participants