Repository navigation
Conversation
Wave prefixes now take the reduction's kind and signedness, as the active one does: AddU/AddF keep kind 0, and MinU/MaxU/MinI/MaxI/MinF/ MaxF pass kinds 2 and 3 with the matching sop. Inclusive prefixes of a min or max fold the lane's own term back in with the ordering compare and a select rather than an add. The new test leaves a min prefix in a value a store after the section reads, so the value cannot stay missing: on main the store is refused with "a wave prefix of an operation other than a sum".
towiice
left a comment
There was a problem hiding this comment.
Tested:
- Hardware: NVIDIA GeForce GTX 1650 SUPER (Turing TU116, 4 GB VRAM, 32-wide subgroups / wave32, driver 610.88), Windows 11 x64 (26H2 / 10.0.26300), toolchain
stable-x86_64-pc-windows-gnullvm(llvm-mingw 23.1.6). - Test command:
cargo +stable-x86_64-pc-windows-gnullvm test -p victory-shader - Result: 70 passed, 0 failed (6.55 s).
- Verified
emit::lower::tests::a_wave_prefix_of_min_lowerspasses cleanly and lowers the wave32 inclusive min prefix without the previous refusal panic.
Clean diff, well-scoped mapping matching the DXILWaveOpKindspecification.
- Verified
|
Verified Not covered: wave-prefix min/max on real hardware and title shaders (no game data). |
|
Two things on
AI-assisted (Claude Code), read-only review. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 6dd6d5f on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed).
(kind, sop)matches the DXIL enums: Sum 0, Product 1, Min 2, Max 3, and signed 0, unsigned 1. Inclusive min and max fold the lane's own term back with the right compare for each type (ULT/UGT, SLT/SGT, OLT/OGT). For floats,select(olt(r, arg), r, arg)returnsargwhenris NaN. That differs fromfmin's NaN rule, but matches what a scan built fromv_min_f32sees only if the input is NaN-free. That's acceptable.- HLSL only has
WavePrefixSumandWavePrefixProduct, so DXC never emitswavePrefixOpwith Min or Max. I checked whether the validator accepts it anyway. I temporarily made the test'slowers_withrun the emitted container throughdxil.dll, anda_wave_prefix_of_min_lowersvalidated OK. Validation is not execution, though: drivers have never seen prefix Min/Max from DXC, so a GPU test (valu_tests::run_cases) comparing lanes on hardware and WARP would be the real proof.
AI-assisted (Claude Code).
…d max Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings the branch up to date with origin/main (ffe310e), 131 commits on. Conflict resolution, all in crates/victory-shader/src/emit/lower.rs and confined to the #[cfg(test)] module: - kept main's single test helper `lowers(words, rsrc2)` and dropped the branch's `lowers`/`lowers_with` pair, so the helper takes rsrc2 directly; - ported the branch's new test call from `lowers_with(&words, 1 << 15)` to `lowers(&words, 1 << 15)`; - checked every `lowers(` call site for arity (all now pass rsrc2) and every `resource::track` call for main's fourth `Some(&st)` argument; the test helper already passed it after the merge. No lowering logic was changed: the diff against origin/main is this PR's wave-prefix min/max lowering plus its test.
|
Independent validation of current head
This confirms that the existing synthetic MinU module is accepted by the validator and this driver; it does not establish numerical correctness for all six min/max operations. In particular, the earlier floating-point NaN concern remains untested: the current inclusive float fold still uses |
An inclusive wave-prefix min/max folded the lane's own term back in with a compare and select (`OLT`/`OGT`). When that term is the NaN the compare is false and the select returns the NaN, where the `v_min_f32`/`v_max_f32` sequence being lowered keeps the non-NaN operand: inclusive min of lane 0 = 1.0 and lane 1 = NaN gave NaN, and must give 1.0. Use `max_min`, the same `FMin`/`FMax` plus signed-zero fix the translator already emits for those instructions. Integer min/max keep the compare and select, where a false compare is the right answer. `a_wave_prefix_of_min_lowers` also validates its module through `dxil.dll` where one is loadable: no compiler emits `wavePrefixOp` kind 2/3, so nothing else checks that the instruction is well formed.
|
@upipibi Pushed 1. NaN in the inclusive fold — fixed. You were right. The inclusive fold now calls 2. What I could settle from source: The part I have not settled is the driver, and I have no hardware run here. I have not claimed it works. I added a validation step to If you think an undocumented kind should not ship at all, the fix is a |
catminou4
left a comment
There was a problem hiding this comment.
Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.
Applied as the net diff of upstream PR Marvisak#470 (head a754127), 3 commits: a754127,95212d93,6dd6d5ff.
|
Hardware readback for Setup. One group of 32 threads,
Each cell holds for both the inclusive and the exclusive form.
So on these two drivers only the unsigned min/max on the RTX 4080 work as lowered. This is one GPU and one driver version per vendor, and the Radeon driver dates from September 2025. Test: AI-assisted (Claude Code), run on my own hardware. |
`wavePrefixOp` kinds 2 and 3 are what HLSL uses for a min or max prefix, and no driver implements them. Hardware readback on PR Marvisak#470 shows NVIDIA returning the unsigned prefix for the signed kinds and failing `CreateComputePipelineState` for the float ones, and AMD returning values unrelated to the inputs. Lower them as a Hillis-Steele scan of `waveReadLaneAt` steps instead, with each step merged by the same operation the translator emits for `v_min_u32` and friends, so a float fold keeps the non-NaN operand. An exclusive prefix reads the inclusive one a lane down and puts the identity in lane 0. A step that would read below lane 0 clamps to lane 0 and its result is discarded. Sum prefixes keep `wavePrefixOp`, whose kind 0 both vendors implement.
|
Automated triage for the maintainers. Needs work. Update after
Points 1 and 2 would change the verdict. CI: passing ( Generated by Claude Code |
What
The wave prefix path lowered
wavePrefixOpfor sums only. Every other operation fell out ata wave prefix of an operation other than a sum, even though the active-reduction arm right below it already mapped min and max.This widens the prefix arm to
MinU/MaxU/MinI/MaxI/MinF/MaxF, with a(kind, sop)table that mirrors the active-reduction one. Exclusive prefixes pass through. Inclusive min/max fold the lane's own term back in with an ordering compare plus select, becausewavePrefixOpexcludes it.Bitwise prefixes stay refused, with a corrected message: DXIL
WaveOpKindhas no bitwise member (Sum/Product/Min/Max), sowavePrefixOpcannot express them at all.Signature verified against the DXIL spec:
dx.op.wavePrefixOp.<i32|f32>(121, value, i8 kind, i8 sop).Verified
emit::lower::tests::a_wave_prefix_of_min_lowers: a wave32 whole-wave section that leaves a per-lane inclusiveMinUprefix, consumed by ands_write_b32. Without the fix the store reads the missing value and the program fails witha wave prefix of an operation other than a sum(offset 160). With the fix it lowers.cargo test -p victory-shader: 57 passed, 0 failed (56 baseline + 1).cargo fmt --check -p victory-shaderclean;cargo clippy -p victory-shader --all-targetsno new warnings.cargo xtask policy: 151 files ok.emit/wave.rstracking, not this refusal arm, so no overlap.AI-assisted (Hermes Agent); I reviewed the diff and ran the tests and gates myself.