Shaders: pass SignedOpKind::Signed for float dx.op.wavePrefixOp #3149

Open
reeledMarek wants to merge 1 commit from upstream-pr/3151 into main
reeledMarek commented 2026-11-26 10:27:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by reeledMarek on 2026-11-26T10:27:20Z.


Summary

  • In crates/victory-shader/src/emit/lower.rs (Lower::shape), wavePrefixOp unconditionally passed SignedOpKind = 1 (Unsigned) even when op == Op::AddF (dx.op.wavePrefixOp.f32).
  • DXIL requires SignedOpKind = 0 (Signed) for floating-point wavePrefixOp (matching waveActiveOp directly below at Op::AddF => (0, 0)), otherwise dxil.dll validation rejects the shader.
  • Pass self.s.m.i8(u8::from(!float)) and add a synthetic compute wave32 prefix-sum test in crates/victory-shader/src/emit/lower/wave_prefix_tests.rs verifying SignedOpKind = 0 for Op::AddF (plus DXIL validator check on Windows) and SignedOpKind = 1 for Op::AddU.
<!-- greyfinch-sync:Marvisak/VIctory:issue:5508284578 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151). Originally posted by [reeledMarek](https://github.com/reeledMarek) on 2026-11-26T10:27:20Z. --- ## Summary - In `crates/victory-shader/src/emit/lower.rs` (`Lower::shape`), `wavePrefixOp` unconditionally passed `SignedOpKind = 1` (`Unsigned`) even when `op == Op::AddF` (`dx.op.wavePrefixOp.f32`). - DXIL requires `SignedOpKind = 0` (`Signed`) for floating-point `wavePrefixOp` (matching `waveActiveOp` directly below at `Op::AddF => (0, 0)`), otherwise `dxil.dll` validation rejects the shader. - Pass `self.s.m.i8(u8::from(!float))` and add a synthetic compute wave32 prefix-sum test in `crates/victory-shader/src/emit/lower/wave_prefix_tests.rs` verifying `SignedOpKind = 0` for `Op::AddF` (plus DXIL validator check on Windows) and `SignedOpKind = 1` for `Op::AddU`.
oni-swr commented 2026-11-26 11:04:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-26T10:44:06Z.


Independent WARP verification of head c9b42b64 (parent main 63bcca4). Synthetic only, no game data.

Setup: VICTORY_D3D12_WARP=1, VICTORY_WARP=1; DXGI adapter reported "Microsoft Basic Render Driver" (flags=2 software, 0 video memory). The physical GPU was not opened. DXIL validator: dxil.dll 1.8.2502.11 (Windows Kits 10.0.26100.0). rustc: rustc 1.98.1 (48a229cea 2026-09-01). cargo test -j 4.

Result: no defect found in the change.

  • emit::lower::wave_prefix_tests::wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int passes on head. With only the self.s.m.i8(u8::from(!float)) line put back to i8(1), it fails on the float assertion (left [121, None, 0, 1], right [121, None, 0, 0]), so the test does discriminate the change.
  • Integer path unchanged: the i32 call still gets sop = 1 (Unsigned).
  • cargo test -p victory-shader --no-fail-fast -- --test-threads=1: head 299 passed, 4 failed, 3 ignored. main: 298 passed, 4 failed, 3 ignored. The same 4 fail on both: synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}. They are not caused by this PR (the wave-of-32 ones are WARP refusing the fixed-wave pipeline).

Limits of what I could show:

  • dxil.dll 1.8.2502.11 validates the float wavePrefixOp module with sop = 1 (before) and sop = 0 (after), so the validator does not enforce "Signed required for float" here. The change follows the DXIL operand definition, which I did not find a way to confirm through this validator.
  • I could not run the float prefix sum on WARP: a local program with the same shape lowers and validates, but WARP refuses the fixed-wave-32 pipeline (The parameter is incorrect), exactly as it does for the existing wave-of-32 tests above. So there is no runtime comparison of results on WARP; the evidence is the emitted operands plus validation.

AI use: Claude Code (Claude Sonnet 5.5) ran this verification; Claude Code (Claude Opus 5.5) coordinated. No game files, dumps, shader names or hashes were used.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7189763311 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151#issuecomment-7189763311). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-26T10:44:06Z. --- Independent WARP verification of head c9b42b64 (parent main 63bcca4). Synthetic only, no game data. **Setup:** `VICTORY_D3D12_WARP=1`, `VICTORY_WARP=1`; DXGI adapter reported "Microsoft Basic Render Driver" (flags=2 software, 0 video memory). The physical GPU was not opened. DXIL validator: dxil.dll 1.8.2502.11 (Windows Kits 10.0.26100.0). rustc: rustc 1.98.1 (48a229cea 2026-09-01). `cargo test -j 4`. **Result: no defect found in the change.** - `emit::lower::wave_prefix_tests::wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int` passes on head. With only the `self.s.m.i8(u8::from(!float))` line put back to `i8(1)`, it fails on the float assertion (left `[121, None, 0, 1]`, right `[121, None, 0, 0]`), so the test does discriminate the change. - Integer path unchanged: the i32 call still gets sop = 1 (Unsigned). - `cargo test -p victory-shader --no-fail-fast -- --test-threads=1`: head 299 passed, 4 failed, 3 ignored. main: 298 passed, 4 failed, 3 ignored. The same 4 fail on both: `synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out}`. They are not caused by this PR (the wave-of-32 ones are WARP refusing the fixed-wave pipeline). **Limits of what I could show:** - dxil.dll 1.8.2502.11 validates the float `wavePrefixOp` module with sop = 1 (before) and sop = 0 (after), so the validator does not enforce "Signed required for float" here. The change follows the DXIL operand definition, which I did not find a way to confirm through this validator. - I could not run the float prefix sum on WARP: a local program with the same shape lowers and validates, but WARP refuses the fixed-wave-32 pipeline (`The parameter is incorrect`), exactly as it does for the existing wave-of-32 tests above. So there is no runtime comparison of results on WARP; the evidence is the emitted operands plus validation. AI use: Claude Code (Claude Sonnet 5.5) ran this verification; Claude Code (Claude Opus 5.5) coordinated. No game files, dumps, shader names or hashes were used.
Dukestar69 commented 2026-11-26 11:31:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T11:31:42Z.

Review: APPROVED


Verified against origin/main (63bcca4):

  • cargo test -p victory-shader --lib wave_prefix_tests:: -- --test-threads=1: passed (wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Cleanly passes SignedOpKind::Signed for float dx.op.wavePrefixOp calls per DXIL spec.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6073410987 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151#pullrequestreview-6073410987). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T11:31:42Z. **Review:** APPROVED --- Verified against `origin/main` (`63bcca4`): - `cargo test -p victory-shader --lib wave_prefix_tests:: -- --test-threads=1`: passed (`wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Cleanly passes `SignedOpKind::Signed` for float `dx.op.wavePrefixOp` calls per DXIL spec. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
futurepro62 commented 2026-11-26 21:14:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T21:14:28Z.


NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head c9b42b6 (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7203529509 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151#issuecomment-7203529509). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-26T21:14:28Z. --- NVIDIA full-suite run, to go with the reports above by oni-swr, since none of them names a GPU run. Tested exact head `c9b42b6` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
fuzeofficlal commented 2026-11-26 21:52:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T21:52:39Z.

Review: APPROVED


Verified on c9b42b64:

  • cargo xtask policy: 192 files ok.
  • cargo clippy --locked -p victory-shader --all-targets -- -D warnings (default and --all-features): clean.
  • crates/victory-shader/src/emit/lower.rs size is 521,161 bytes (under the 512 KiB ceiling).
  • cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::lower::: 34 passed, 0 failed under both VICTORY_WARP=0 and VICTORY_WARP=1, including emit::lower::wave_prefix_tests::wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int.

Passing u8::from(!float) for SignedOpKind (0 = Signed for wavePrefixOp.f32, 1 = Unsigned for wavePrefixOp.i32) at lower.rs:1252 matches the DXIL specification and aligns with waveActiveOp (lower.rs:1183, 1280), and inspecting the emitted call arguments directly in wave_prefix_tests.rs is great since dxil.dll only validates overload/signature and does not reject sop=1 on float calls. One tiny formatting note: rustfmt --edition 2024 --check flags lines 55-58 of crates/victory-shader/src/emit/lower/wave_prefix_tests.rs where the three bitwise-OR operand terms in vop3 wrap onto separate lines instead of one line. LGTM.

<!-- greyfinch-sync:Marvisak/VIctory:review:6080886248 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151#pullrequestreview-6080886248). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T21:52:39Z. **Review:** APPROVED --- Verified on `c9b42b64`: - `cargo xtask policy`: `192 files ok`. - `cargo clippy --locked -p victory-shader --all-targets -- -D warnings` (default and `--all-features`): clean. - `crates/victory-shader/src/emit/lower.rs` size is `521,161` bytes (under the 512 KiB ceiling). - `cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::lower::`: **34 passed, 0 failed** under both `VICTORY_WARP=0` and `VICTORY_WARP=1`, including `emit::lower::wave_prefix_tests::wave_prefix_op_sets_signed_op_kind_for_float_and_unsigned_for_int`. Passing `u8::from(!float)` for `SignedOpKind` (`0 = Signed` for `wavePrefixOp.f32`, `1 = Unsigned` for `wavePrefixOp.i32`) at `lower.rs:1252` matches the DXIL specification and aligns with `waveActiveOp` (`lower.rs:1183, 1280`), and inspecting the emitted call arguments directly in `wave_prefix_tests.rs` is great since `dxil.dll` only validates overload/signature and does not reject `sop=1` on float calls. One tiny formatting note: `rustfmt --edition 2024 --check` flags lines `55-58` of `crates/victory-shader/src/emit/lower/wave_prefix_tests.rs` where the three bitwise-OR operand terms in `vop3` wrap onto separate lines instead of one line. LGTM.
andrewpozdnakov7-jpg commented 2026-11-28 14:37:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T14:37:29Z.


I combined your exact c9b42b6 head with #470 at ed2d2c8 in branch 1cadfb8. Both commits are direct parents. The difference from #470 is entirely test code. Its float and unsigned sum lowering already emits the operands your test expects, so the regression can travel with #470 if it lands first.

I compiled a short HLSL compute shader that calls WavePrefixSum with both float and uint. DXC 1.9.2609.5 emits SignedOpKind=0 for the float call and 1 for the unsigned call. Your generated test on main emits 1 for both unless the fix is applied. dxil.dll 1.9.2609.5 accepts both float operands, which agrees with the earlier 1.8.2502.11 result in this thread. The regression checks parity with Microsoft's emitter.

All 35 lowering tests pass on the combined head, including your float and unsigned operand test and #470's minimum-prefix scan. The separate 35-test VALU suite passes on WARP 1.0.22 with Agility 1.620.2 and the debug layer off and on. The prefix probes checked emitted DXIL. Strict all-feature shader Clippy and the asset policy passed.

Please retain the original Git authors if carrying the test or lowering changes separately. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240808586 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3151#issuecomment-7240808586). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T14:37:29Z. --- I combined your exact `c9b42b6` head with #470 at `ed2d2c8` in [branch `1cadfb8`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/3151-470-prefix-validation). Both commits are direct parents. The difference from #470 is entirely test code. Its float and unsigned sum lowering already emits the operands your test expects, so the regression can travel with #470 if it lands first. I compiled a short HLSL compute shader that calls `WavePrefixSum` with both `float` and `uint`. DXC 1.9.2609.5 emits `SignedOpKind=0` for the float call and `1` for the unsigned call. Your generated test on main emits `1` for both unless the fix is applied. `dxil.dll` 1.9.2609.5 accepts both float operands, which agrees with the earlier 1.8.2502.11 result in this thread. The regression checks parity with Microsoft's emitter. All 35 lowering tests pass on the combined head, including your float and unsigned operand test and #470's minimum-prefix scan. The separate 35-test VALU suite passes on WARP 1.0.22 with Agility 1.620.2 and the debug layer off and on. The prefix probes checked emitted DXIL. Strict all-feature shader Clippy and the asset policy passed. Please retain the original Git authors if carrying the test or lowering changes separately. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3151:upstream-pr/3151'
git switch 'upstream-pr/3151'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/3151'
git switch 'upstream-pr/3151'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3151'
git switch 'upstream-pr/3151'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3151'
git switch 'main'
git merge --squash 'upstream-pr/3151'
git switch 'main'
git merge --ff-only 'upstream-pr/3151'
git switch 'main'
git merge 'upstream-pr/3151'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3149
No description provided.