Shaders: support 32-lane wave64 lowering for partial-dispatch compute shaders #22
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22"
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 DexNom/VIctory. Originally posted by davi713albano-coder on 2026-11-25T18:57:24Z.
Summary
Addresses part of the 32-lane GPU (NVIDIA) ray-tracing builder block reported in #14 and #15 (
Shader wants wave lane count of 64 but maximum wave lane count for device is 32, D3D12 debug id 622):Lower::newskipped wave64-to-wave32 lowering wheneverpartial == true(if !partial && wave == 64 && host_max_wave() == 32 ...), becauseLower::runimplemented partial-dispatch thread masking with an earlyRetin the prologue that would deadlock group barriers (wave_base,exchange_halves,split_lds).XboxBvhBuilder'sBox32/Box16rehydration kernels (box_rehydrationincrates/victory-shader/src/emit/mod.rs) always emittedWaveSize(64)and failedCreateComputePipelineStatewithE_INVALIDARGon 32-lane GPUs.Changes
partialwave64 compute shaders to enter 32-lane lowering onhost_max_wave() == 32(crates/victory-shader/src/emit/lower.rs).self.halves.is_none()(native 64-lane hosts such as Radeon or non-wave64 shaders).self.halves.is_some()(console wave64 emulated across two 32-lane host waves), computepartial_active = (limit == 0) || (group * width + thread < limit)in the entry block without returning early (enter_partial_dispatch/with_partialincrates/victory-shader/src/emit/packed_mask.rs), keeping inactive tail threads alive through group barriers while masking:Lower::guard: stores, atomics, VGPR writes, guest-memory fault reporting,v_readfirstlane_b32),v_cmp_*/v_cmpx_*lane bits (lane_bits_for),mask_dwordwhenst.active.contains(&lo)—EXEC,VCC,s_bcnt1_i32_b64,s_ff1_i32_b64,v_mbcnt_*),scc_some,wave_wide,wave_reduce,active_f64_sum, and scalar guest-memory loads (memory_smem).partial_thread_dispatch_on_32_lane_host_emits_wave32_and_masks_wave_counts_and_writesincrates/victory-shader/src/emit/wave64_tests.rsverifyingPSV0declaresWaveSize(32), Microsoft DXIL validation passes, and (on 32-lane hardware) cross-lanes_bcnt1_i32_b64 execcounts and stores match across tail boundaries (0, 1, 7, 31, 32, 33, 45, 63, 64).Note on hardware testing
Verified full
CI(windows-latest:clippy,clippy --all-features,cargo test --workspace --locked,xtaskasset-policy check, anddxil.dllvalidation) andScreen. Live 32-lane hardware verification (e.g., on RTX 3060 Ti / RTX 4070 from #14 / #15) is still needed and welcomed — this specifically resolves the twobox_rehydrationWaveSize(64)refusals; any remaining non-partial64-lane pipelines on 32-lane hosts are separate.No title data used. AI-assisted.
Imported from DexNom/VIctory. Originally posted by FIJI1299 on 2026-11-25T19:17:54Z.
Verified commit
92897d2on live 32-lane (wave32) NVIDIA hardware (following up on the 32-lane NVIDIA reports in #14 and #15):Environment
621.40, nativewave32)1.8.2502.11(Windows SDK10.0.26100.0)Results
victory-shadertest suite (cargo test -p victory-shader --lib -- --test-threads=1): 238 passed, 0 failed, 4 ignored (366.25s), including allwave64lowering tests (wave64_tests.rs).victory-gputest suite (cargo test -p victory-gpu --lib -- --test-threads=1): 188 passed, 0 failed, 3 ignored (4.68s).box_rehydrationruntime execution (no game data on this machine).Imported from DexNom/VIctory. Originally posted by Artking175 on 2026-11-25T21:04:23Z.
I checked the full builder set on RTX 2060 (Windows 10, driver 531.41). With pinned
92897d2, the same Agility 1.614.1 / DXIL validator / loader overlay andVICTORY_HOST_MAX_WAVE=32as the control,translate --jobs 1 --validate --pipelines --list XboxBvhBuilder.dllreturned:2e01ab492897d246fa699aThe two recovered PSOs are for container hashes
3297538b1176c897and138a77fa89f35ae4. The other three still stop in #22 ata first-lane read where not every lane runs. The earlier partial-dispatch fixture separately passed the RTX 2060 hardware readback with nine counts. This measures offline coverage of the two changes. Full #35 check.Imported from DexNom/VIctory. Originally posted by j-fuxa on 2026-11-26T01:41:07Z.
Console thread ids for console wave32 programs in 2-D/3-D groups
Not about the partial-dispatch change itself. It is posted here because it sits beside
wave_base/halvesincrates/victory-shader/src/emit/lower.rs(main at64bd58f5).What we found.
thread_id(and the fallback at the end ofconsole_thread) builds the console flat thread id aswaveReadLaneFirst(flattenedThreadIdInGroup)rounded down to the wave size, plus the lane index. The comment above it calls this a bijection "while each host wave holds a wave-aligned run of flat ids". On the 32-lane hosts we tried, that does not hold for 2-D groups. An RTX 4060 Laptop and a Radeon 780M both fill them with rows of 24+ threads taken from 16x2 tiles.wave_basealready avoids this ("NVIDIA's 8 x 8 groups"), but only whenhalvesis set (wave == 32 && native.wave64). A console wave32 program that uses console lanes, in a group larger than one host wave, still takes the rounding path.Evidence. A compute program that stores each thread's console id, built with the old rounding. Ids stored out of total, identical on both GPUs: 32x2 32/64, 32x8 128/256, 64x4 128/256, 32x32 512/1024, 32x2x2 64/128, 10x10 68/100. 12x12 and 24x8 failed pipeline creation on the 4060 ("Not enough memory resources") and stored 96/144 and 128/192 on the 780M. In the title's shader archive three programs were wrong this way, all 32x2 sky ambient-map compute passes. 1-D groups are not affected. The wave tests we looked at (
wave64_tests.rs,lower_tests.rs) use 1-D groups, so they would not show it.What fixed it for us. A groupshared ticket, used only for console-lane programs in groups larger than one host wave. Zero a counter, barrier, each full host wave's first lane takes a block of wave-size ids with an atomic add, the partial wave takes the last block, and the console id is base + lane. 221 compute programs in the archive take it.
Caveats. The numbers come from our own fork. For this repo we only read the code; we did not build it, and we did not test a discrete Radeon GPU. Separately,
wave_baseadds a constant 32 per host wave. If a group size is not a multiple of 32 and the short wave takes its ticket before a full one, later ids can pass the group size. The form we settled on avoids that: each wave doesatomicAdd(counter, WaveActiveCountBits(true))and its lanes usebase + WavePrefixCountBits(true)(DXIL opcode 135,dx.op.waveAllOp).Imported from DexNom/VIctory. Originally posted by Artking175 on 2026-11-26T05:22:33Z.
I tested the multidimensional console-wave32 report on RayTime main
64bd58fwith an RTX 2060 (Turing, driver 531.41, Windows 10, Agility 1.614.1). The synthetic shader usesv_readlane_b32so it takes the console-lane path. It atomically increments one counter per computed flat console thread ID and checks for duplicate, missing and out-of-range IDs.All ten geometries produced exactly one increment per expected ID with no writes into the padding. That includes 32×2, 32×8, 32×32, 64×4, 8×8, 32×2×2, 10×10, 12×12, 24×8 and a 64×1 control. Each shader validated and created a hardware PSO. I could not reproduce the collision on this Turing setup. The RTX 4060 Laptop and Radeon 780M results remain a separate hardware case.
Imported from DexNom/VIctory. Originally posted by andrewDoing on 2026-11-26T23:04:31Z.
Independent physical RTX 5070 verification at
92897d2: required Windows SDK DXIL validation and actual PSO creation, asserted the shader PSV minimum/maximum wave size was 32, and executed one wave64 console group for all 65 count settings 0–64. All 4,160 GPU output DWORDs matched expected active-lane popcounts or inactive zero; count 0 means unrestricted. No title Box16/Box32 captures or gameplay were tested.Verification was AI-assisted with GPT-6.2 Astra.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.