Shaders: compute reading lanes only within aligned groups declares no wave size #2117
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2117
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2117"
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?
@rminzao on GitHub · 2026-11-25 05:19 UTC · original
rminzao:shaders-narrow-lane-groups-no-wave-size→main· +760 −17 · 17 files · 2 commits · openClaimed in #1633 (claim).
Problem
A compute program that reads other lanes declares the console's exact wave size (
lower.rs, theconsole_lanesdecision;WaveSize(32)orWaveSize(64)). A host refuses aWaveSizeoutside its[WaveLaneCountMin, WaveLaneCountMax]:Many such reads never leave a small aligned group of lanes, though: DPP
quad_permstays in a quad, DPP8 in 8 lanes, DPP row controls in 16,ds_swizzlein quad mode in a quad and in bitmask mode in 2^(highest lane bit it changes + 1). Any host wave of at least G lanes, aligned on G, gives each group the same lanes, whatever the host's wave size.Change
lane_groupgives each instruction the aligned group it reads (table below). When the widest group G of a compute program is smaller than the console wave N, and nothing in it needs the whole wave, the program declares noWaveSizeandLowered/HostShadercarrymin_lanes = G.waveGetLaneCount) instead of the constant N (narrow_thread_id,lane_thread), on the same assumptionthread_idmakes today: a host wave holds an aligned run of flat thread ids. DPProw_mask/bank_maskand constant lane bits take the console lane from the relabelled id (console_lane).victory-gpu:Host::wave_lanes_minreadsOPTIONS1once (logged), and a compute pipeline whose shader hasmin_lanesabove it is refused as "the host GPU's waves are narrower than the lane groups the shader reads".min_lanesis in the shader cache entry.quad_perm,ds_swizzlequad moderow_shl/shr/ror,row_mirror,row_half_mirror,row_share,row_xmaskds_swizzlebitmask modev_mbcnt*,v_readlane/v_writelane, masks read as dataKept whole-wave (declaring
WaveSizeexactly as before): programs withs_barrier(a host wave whose lanes all skip it would hang the host, where the console's wave still arrives), any LDS use (the console compiler leaves out barriers within one wave, so an intra-wave LDS exchange would race across host waves),v_permlane*, av_readfirstlanethat isn't a waterfall read, opaque or constant lane-mask guards, one-wave groups with LDS, and whole-wave sections. A narrow attempt that fails to lower for any reason, or reads a lane mask as data, is lowered again whole-wave, so narrowing never makes a program fail that translates today.Unchanged for every other program: the narrow path is separate (
thread_idgets one early branch). Hashinglowered.dxilfor every input the shader suite lowers, onmain940d32fand on this branch: all 484 thatmainlowers whole-wave or lane-free give byte-identical DXIL; only the new tests' narrow programs differ.Tested
Intel UHD Graphics (driver 31.0.101.4146), RTX 4050 Laptop (595.97) and WARP, Windows 11. New module
emit::lane_group_tests; each GPU test reads back 128 threads lane by lane against a CPU model of the console, with encodings checked against the decoder's text and DXIL validated.quad_reads_run_on_any_host_wave(wave32 + wave64:quad_permwith row/bank masks, quad swizzle)row_reads_run_on_host_waves_of_16_lanes(row_shr:3with masks,row_mirror, DPP8, swizzle xor)half_reads_of_wave64_run_on_host_waves_of_32_laneslane_groups_set_the_fewest_host_lanes,reads_of_the_whole_wave_keep_its_size(readlane, mbcnt, readfirstlane,s_barrier, a whole-wave section),lds_shared_within_the_wave_keeps_its_sizepipeline::host::tests::shaders_reading_lane_groups_need_host_waves_that_hold_themThe RTX 4050 ran through a local, uncommitted switch of the test host to the high-performance adapter. Breaking the console-lane computation, the section fallback or the barrier/LDS rules each makes a test fail.
cargo test -p victory-shader --libon the Intel UHD: 244 passed, 9 failed;main: 238 passed, the same 9 failures (all covered by other open PRs, see #1829).cargo test -p victory-gpu --lib: 141 passed, 3 failed;main: 140 passed, the same 3.cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings, with and without--all-features: clean.cargo check --workspace --all-targets: clean.rustfmt --check: no diffs in the new hunks; the new test file is clean.cargo xtask policy: ok.Overlap: #1922's gate refuses wave64 compute without a declared wave size on hosts under 64 lanes; with this PR the narrow wave64 programs are such programs, so the two need reconciling (whichever lands second). #2035 (barrier sync on narrow waves) is orthogonal: programs with barriers don't narrow here.
Not run: the title, AMD hardware (a 32-64 lane host runs narrow programs at the driver's choice of size), and how many of the title's programs narrow. Programs with LDS or barriers, likely the bulk of lane-dependent compute, are deliberately left as they are.
AI-assisted (Claude Code).
🤖 Generated with Claude Code
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 05:44 UTC · original
A remaining narrow-wave case on b3b5c93d73c73a54528993f370c6eba86fc9c648: DPP16 row_xmask:3 selects lane XOR 3, which stays within each four-lane group. The current classifier assigns it 16 lanes and excludes four-lane WARP. ISA modifier semantics
571b78a sizes this lane group from the mask in one commit on that exact head. The same synthetic dispatch test skipped WARP and failed before. After, the compiled shader ran on WARP for guest wave32 and wave64. All 128 readbacks for each mode matched the lane oracle, including old destination values in masked rows and banks.
Full forced-WARP shader suite: 250 passed, 4 failed, 3 ignored before. After: 251 passed, 3 failed, 3 ignored. The gather, lane-permute and edge-flagged triangle failures were shared. Strict shader Clippy and staged asset policy passed.
@fiestorra on GitHub · 2026-11-25 06:10 UTC · original
This and #2126 rewrite the same arithmetic, they conflict, and one may be a precondition of the other
Two pull requests in the same window are changing how a thread's lane is arranged for cross-lane reads, and they are not independent.
Measured: they conflict, in the one file where it matters:
#2126 (
console_flat, "compute threads that read other lanes keep unique ids in 2-D groups") changes how a thread's console flat id is derived, using a group-shared ticket, because a host may put threads of several rows into one wave; #2117 changes whether a wave size is declared at all, addingmin_lanesand aStop::Widere-lowering for programs that only read within aligned groups of 4, 8, 16 or 32.The question that decides how they land is about your premise for narrow groups. The argument for "an aligned group of
klanes never straddles a host wave" needs the host to fill its waves from consecutive flat ids in group order. #2126's description says that is not what some hosts do: an RTX 5070 Ti fills 2-D groups in 16 × 2 tiles ("24, 32 or 64 wide or not a power of two wide"), and XCL's notes report 2 × 2 quads on an RX 9070. If threads of one aligned group land in different host waves, then a narrow-group read is not within one wave after all, and #2126's ticket is what makes the ids line up again.So:
Stop::Wide) is where it goes wrong if it is.I am not asking for both to be merged together; I am asking for the sentence that says which mechanism owns the 2-D case. At the moment two of them claim it and they disagree by construction.
A note on the evidence, since it decides what a reviewer can check:
translate --validatewill not show this. A declared or missingWaveSizeis refused by the host when the pipeline is created, so the number that moves is the--pipelinescount (or a boot), not the validated count. If either description has a before/after of that count on a host whose lane count differs from the console's, it would settle the review in one line; on this machine (NVIDIA, 32 lanes,32.0.16.2124) I can measure it for whichever of the two lands first, and for the pair once they agree.No game data is involved: file names, hosts and counts.
Written with an AI assistant.
@Marvisak on GitHub · 2026-11-25 10:44 UTC · original · edited 2026-11-26 02:17 UTC
Automated triage for the maintainers.
Merge candidate.
8f190cctakes the first option from the last triage: inLower::new(crates/victory-shader/src/emit/lower.rs),min_lanesis set only for[n, 1, 1]groups, and only when nothing needs the whole wave (masks as data, one-wave LDS,s_barrier,v_permlane,v_readfirstlane_b32outside waterfalls, any LDS, sections); everything else declares the console's wave size as onmain.lane_group_tests::lane_groups_of_2d_thread_groups_keep_the_wave_sizecovers 2-D and 3-D shapes. A program that fails narrow is lowered again whole-wave (Stop::Wide), and that retry cannot loop sincemin_lanesis 0 then. On the host side,HostPipelinerefuses a compute pipeline whenwave_lanes_min()is belowmin_lanes(or unknown), andmin_lanesis part of the shader cache encoding, so old entries fail to decode instead of being misread. The 1-D restriction rests on host layout probes (#2126 and the Intel UHD data in this thread), not console behaviour, which is the right kind of evidence here. CIcheckpasses and it merges cleanly.On your reply: this answers the 2-D blocker. One note for the maintainer: #2084 also adds to
lower.rs, and the two together come to about 525,100 bytes, past the 512 KiBcargo xtask policylimit, so whichever merges second will need another small move out oflower.rs.Generated by Claude Code
@KainanP on GitHub · 2026-11-25 12:30 UTC · original
Data for the triage's 2-D question, from an Intel UHD (Xe-LP, 16-lane waves). This head's 6 new tests pass there (the wave64-half test skips), and they all use a 1-D group. #2126's wave-layout probe on the same iGPU, without
WaveSize, shows 1-D groups in aligned 16-lane runs but most 2-D groups in 4×4 tiles ([8,8,1]first wave = ids 0-3, 8-11, 16-19, 24-27). The probe reportsrelabel bijective falsefor 13 of the 19 shapes that are not[n,1,1], solane_threadwould repeat ids there as well. Full list in item 5 of #1829AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.
@rminzao on GitHub · 2026-11-26 01:43 UTC · original
Rebased onto
main(63bcca4) and pushed8f190cc, taking the first of the triage's two options: only 1-D groups are narrowed.min_lanesis set only when the group is[n, 1, 1]. 2-D and 3-D groups with lane-group reads declare the console's wave size, as onmain. @KainanP's probe (aligned 16-lane runs for 1-D groups on the Intel UHD, 4×4 tiles for most 2-D ones) and #2126's NVIDIA layout both point this way. With #2126's ticket, narrowing 2-D groups could come back later.lane_groups_of_2d_thread_groups_keep_the_wave_sizelowers quad androw_shrreads in[8,16,1],[16,8,1],[32,2,2]and[64,1,2]groups, wave32 and wave64, and assertsmin_lanes0 and a declared wave size. It fails with the restriction removed.main,lower.rswent pastcargo xtask policy's 512 KiB limit.lane_group,narrow_thread_id,lane_threadandconsole_lanemoved unchanged toemit/lower/lanes.rs.lower.rsis now 523,785 bytes.row_xmaskbelow 4: not changed here. As the triage notes it is safe, only less narrow. 571b78a can land on top.cargo test -p victory-shader --libon the Intel UHD: 298 passed, 11 failed, the same 11 asmain. The 7lane_grouptests pass on WARP.victory-gpu: 229 passed, the 3 heap-cap and placed-view failuresmainhas. Clippy (with and without--all-features) andcargo xtask policyare clean.AI-assisted (Claude Code).
@reboot0000-cmd on GitHub · 2026-11-26 03:09 UTC · original
Correcting my own number from three hours ago, and the correction is total: on
8f190ccthe rule now clears 0 of the 396.Same archive (26,503 containers, 26,084 programs), same host (RTX 4090,
WaveLaneCount32..32), same validator (DXC1.8.2502.8), SM 6.6 via #463's Agility exports. This time the candidate is the pull-request head commit itself as a worktree on63bcca4, not a merged approximation, and the control is63bcca4with the same exports — so the two rows differ by exactly the 20 lines that changed.63bcca43main)8f190cc(1-D only)Identical in every column: 0 cleared, 0 newly refused, 0 pipelines lost.
On the earlier head (
b3b5c93, measured against61bfc773this afternoon) the same archive gained 17 pipelines and lost nothing — 16 mipmap-generation programs (im:CS_Texture2DMipmap2/3_*,im:CS_Texture2DArrayMipmap2/3_*) andcascadeshadows_processing:CS_ComputeMinMax. Those 17 offsets are refused again on8f190cc, individually, not in aggregate.Which answers the 2-D question with the only kind of evidence that settles it, from the title's side rather than the ISA's:
a program that cleared under the unrestricted rule and is refused again under 1-D-only gains nothing from the rule as it now stands. All 16
im:*mipmap programs are in that set. The clean reading is that their thread groups are not[n, 1, 1]; the alternative is that the move oflane_groupintolower/lanes.rschanged when the clause fires. Either way the measured effect on this title is nil — and the practical point holds regardless of which it is: whatever the rule buys here, it lives outside 1-D groups, so it is exactly what the 1-D-only restriction gives back.@fiestorra's question about which mechanism owns the 2-D case is therefore not hypothetical for this archive; these 16 programs are the whole measured benefit.Two notes so nobody chases a non-issue:
lane_groups_of_2d_thread_groups_keep_the_wave_sizepasses on this machine, which is consistent with the flat table above — the behaviour and the archive agree.quad_reads_run_on_any_host_wavefails here, and it is this host's OS, not the change: it printsno SM 6.6 hardware device; skipped/no SM 6.6 warp device; skippedfirst, then asserts on a device list that is empty because it has to be. On Windows 10 19044 an image without the Agility/EXPORTdeclarations is capped at shader model 6.5, andcargo testbinaries do not carry them — only thevictoryexecutable does, via #463. Nothing to fix here; worth a line in the test so the next Windows 10 host doesn't read it as a regression.If the 2-D case acquires a mechanism — #2126's per-wave base, or whatever owns it after the discussion above — I can re-run these two rows in about 35 minutes; the harness is built and both runs pass the same integrity checks (container and program counts, per-stage emitted = validated + refused arithmetic) before any number here gets posted.
Counts and program names from the title's own shader archive; nothing shipped.
@DenRakEiw on GitHub · 2026-11-25 05:26 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC, withdxil.dllvalidator):cargo test -p victory-shader --lib wave— 14 passed, 0 failed (includingshaders_reading_lane_groups_need_host_waves_that_hold_them)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (184 files ok)Clean refinement omitting
WaveSizewhen compute lane reads stay within aligned groups, improving Wave32/NVIDIA compatibility while guarding host minimum wave lanes. Looks great.AI-assisted (Gemini 4 Neon).
@catminou4 on GitHub · 2026-11-25 06:33 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.144 passed / 0 failed / 2 ignored. Compute reading lanes only within aligned groups declares... — lane-group constraint declaration; mixed gpu+shader.
@fuzeofficlal on GitHub · 2026-11-26 15:37 UTC · original · approved these changes
Reviewed
8f190ccea45855746c7182f8bd7c847b0c8af0fband verified on Windows 11 with an NVIDIA GeForce RTX 5090 (Wave32-only,32-32lanes), WARP (4-4lanes), D3D12 Debug Layer, and Windows SDKdxil.dll(10.0.26100.0).Audit
crates/victory-shader/src/emit/lower/lanes.rs:14,:54,:73,:112;crates/victory-shader/src/emit/lower.rs:589,:645,:1351,:1384,:1448):lane_groupconservatively classifies DPP quad/DPP8/row controls andds_swizzle_b32(both quad mode and exact bitmask smallest power-of-two aligned group), while falling back to the full console wave for permutes,v_mbcnt*,v_readlane_b32/v_writelane_b32, unknown/wide DPP controls, and mask-as-data reads.cs.threads[1] != 1 || cs.threads[2] != 1), barriers,v_permlane*, non-waterfallv_readfirstlane_b32, LDS/one-wave shared memory, and whole-wave sections (Stop::Wideone-shot retry) safely avoids 2D tiled host wave layouts and lane-width races.lane_thread/console_lanepreserves console lane indices forlane_bitand DPProw_mask/bank_maskon narrower host waves.crates/victory-gpu/src/host.rs:1105,crates/victory-gpu/src/pipeline/host.rs:389,:444,crates/victory-gpu/src/shader_cache.rs:291,:353):too_few_lanescleanly rejects compute pipelines wheneverhost.wave_lanes_min() < shader.min_lanes(including unknown0), and persistingmin_lanesinshader_cache.rsautomatically invalidates existing disk caches viainclude_bytes!("shader_cache.rs").crates/victory-shader/src/emit/lower.rsis at523,785bytes (503bytes below the 512 KiBxtask policylimit), so combining this with another PR touchinglower.rswill likely need moving another helper out.Verification
cargo run -p xtask -- policy(193 files ok)cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(default &--all-features)cargo test -p victory-shader --lib -- --nocapture lane_group_tests::withVICTORY_DXILpointing to SDKdxil.dll: 7/7 passed — on Wave32-only RTX 5090 all three runtime suites ran and matched lane-by-lane across 128 threads (including console wave64 32-lanehalf_swizzle, 16-lane row/DPP8 ops, and 4-lane quads); on WARP (4-4), quad reads ran and 16/32-lane groups skipped cleanly.victory-shadercrosslane_tests::+bvh_tests::: 19/19 passed on hardware; 26/26 passed (lane_group_tests::+crosslane_tests::+bvh_tests::) underVICTORY_WARP=1.victory-gpupipeline::+shader_cache::withVICTORY_D3D12_DEBUG=1: 28/28 passed on RTX 5090; 31/31 passed (--features diagnostics) on WARP.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.