gpu, shader: Intel Arc DG2/Battlemage optimizations and hardware execution fallbacks #1066

Closed
github-bot wants to merge 4 commits from gh-pr/1066/head into gh-pr/1066/base
Owner

@⁠UnkwnDev on GitHub · 2026-11-24 15:27 UTC · original
UnkwnDev:arc-optimizations → main · +836 −70 · 7 files · 4 commits · closed without merging

Resolves #740

Summary

Hardware execution fallbacks and shader optimizations targeting Intel Arc DG2 and Battlemage architectures.

Changes

  • Indirect draw stream compaction pass to eliminate empty draw stalls on host command lists.
  • DXIL WaveSize clamping to hardware capability (e.g. Wave32 on Arc) and bit-exact NaN handling.
  • Packed dot product lowering to DXIL dot4AddPacked and fused multiply-adds (v_dot4_i32_i8, v_dot4_u32_u8, v_dot2_f32_f16, v_dot2_i32_i16, v_dot2_u32_u16, v_dot8_u32_u4).
  • Whole-wave simulation width clamping to wave_size_max for Wave32 execution.
  • Comprehensive unit and integration test fixtures.
**@⁠UnkwnDev** on GitHub · 2026-11-24 15:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1066) `UnkwnDev:arc-optimizations` → `main` · +836 −70 · 7 files · 4 commits · closed without merging Resolves #740 ### Summary Hardware execution fallbacks and shader optimizations targeting Intel Arc DG2 and Battlemage architectures. ### Changes * Indirect draw stream compaction pass to eliminate empty draw stalls on host command lists. * DXIL WaveSize clamping to hardware capability (e.g. Wave32 on Arc) and bit-exact NaN handling. * Packed dot product lowering to DXIL dot4AddPacked and fused multiply-adds (v_dot4_i32_i8, v_dot4_u32_u8, v_dot2_f32_f16, v_dot2_i32_i16, v_dot2_u32_u16, v_dot8_u32_u4). * Whole-wave simulation width clamping to wave_size_max for Wave32 execution. * Comprehensive unit and integration test fixtures.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:47 +00:00
github-bot closed this pull request 2026-11-26 04:18:47 +00:00
Author
Owner

@⁠UnkwnDev on GitHub · 2026-11-24 18:30 UTC · original

Rebased cleanly onto main at ffe310e. Conflicts in crates/victory-shader/src/emit/valu_tests.rs have been resolved to preserve our Wave32 simulation and packed dot product tests alongside the waterfall/EXEC tests from #566, including synchronizing dispatch tests under ONE_AT_A_TIME. All workspace tests and clippy checks (--all-targets, with and without --all-features) pass cleanly.

Regarding the split: if separating the victory-shader changes from the Windows-only victory-gpu compaction pass makes review and testing on macOS easier, let me know and I can extract the shader commits into a separate PR.

**@⁠UnkwnDev** on GitHub · 2026-11-24 18:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1066#issuecomment-7140748236) Rebased cleanly onto main at ffe310e. Conflicts in crates/victory-shader/src/emit/valu_tests.rs have been resolved to preserve our Wave32 simulation and packed dot product tests alongside the waterfall/EXEC tests from #566, including synchronizing dispatch tests under ONE_AT_A_TIME. All workspace tests and clippy checks (--all-targets, with and without --all-features) pass cleanly. Regarding the split: if separating the victory-shader changes from the Windows-only victory-gpu compaction pass makes review and testing on macOS easier, let me know and I can extract the shader commits into a separate PR.
Author
Owner

@⁠UnkwnDev on GitHub · 2026-11-24 18:51 UTC · original

Updated branch at dc1aa37 following a self-review pass:

  1. Fixed VOP2/VOP3 v_dot2c_f32_f16 operand extraction in crates/victory-shader/src/emit/lower.rs: since non-VOP3P encodings leave opsel_hi unset, v_dot2c_f32_f16 now explicitly slices [15:0] and [31:16] via f16_operand instead of reading the low half twice.
  2. Added v.clamp saturation for integer dot products (v_dot4_i32_i8, v_dot4c_i32_i8, v_dot4_u32_u8, v_dot2_i32_i16, v_dot2_u32_u16, v_dot8_u32_u4) and routed v_dot2_i32_i16/u16 through packed_src so VOP3P opsel/opsel_hi are honored.
  3. Added a shared-memory prefix scan in crates/victory-gpu/src/indirect.rs for single-group batches (<= 64 commands) so compaction preserves exact command order and avoids global atomic contention.
  4. Eliminated environment variable mutation from wave::tests::wave64_section_simulates_wave32_when_clamped.

Re-verified with cargo clippy --workspace --all-targets --locked -- -D warnings, --all-features, and full cargo test --workspace --locked (all tests passing, including new VOP2 dot2c, integer clamp, and opsel hardware tests).

**@⁠UnkwnDev** on GitHub · 2026-11-24 18:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1066#issuecomment-7141240798) Updated branch at dc1aa37 following a self-review pass: 1. Fixed VOP2/VOP3 v_dot2c_f32_f16 operand extraction in crates/victory-shader/src/emit/lower.rs: since non-VOP3P encodings leave opsel_hi unset, v_dot2c_f32_f16 now explicitly slices [15:0] and [31:16] via f16_operand instead of reading the low half twice. 2. Added v.clamp saturation for integer dot products (v_dot4_i32_i8, v_dot4c_i32_i8, v_dot4_u32_u8, v_dot2_i32_i16, v_dot2_u32_u16, v_dot8_u32_u4) and routed v_dot2_i32_i16/u16 through packed_src so VOP3P opsel/opsel_hi are honored. 3. Added a shared-memory prefix scan in crates/victory-gpu/src/indirect.rs for single-group batches (<= 64 commands) so compaction preserves exact command order and avoids global atomic contention. 4. Eliminated environment variable mutation from wave::tests::wave64_section_simulates_wave32_when_clamped. Re-verified with cargo clippy --workspace --all-targets --locked -- -D warnings, --all-features, and full cargo test --workspace --locked (all tests passing, including new VOP2 dot2c, integer clamp, and opsel hardware tests).
Author
Owner

@⁠DeerSilver on GitHub · 2026-11-24 23:06 UTC · original

Tested on an Intel Xe-LP iGPU (not Arc) and an NVIDIA card. Setup: one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell, 10de:2d59, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP, 8086:a788, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged onto main ffe310e.

  • cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1 with the D3D12 debug layer on (VICTORY_D3D12_DEBUG=1, and a local, uncommitted change that also turns the debug layer on in victory-shader's test Host): 350 passed, 0 failed, 6 ignored. The four new tests passed in that run, which used the default adapter, the RTX.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean

victory-shader's lib tests on each adapter (cargo test --locked -p victory-shader --lib -- --test-threads=1, with a local switch that creates the test Host on a chosen DXGI adapter and prints its name):

RTX 5060 Laptop Intel UHD
main (not run) 119 passed, 1 failed (v_med3_f32_matches_rdna2_with_nan)
main + this PR 124 passed, 0 failed 123 passed, 1 failed

The PR's NaN bit test fixes v_med3_f32 on the Intel UHD. The failure with the PR is the new wave32_simulation_and_reduction_executes_cleanly:

hardware: compute_pipeline failed: The parameter is incorrect.

The debug layer gives the reason:

D3D12 ERROR: ID3D12Device::CreateComputeShader: Shader wants wave lane count of 32 but maximum wave lane count for device is 16. [ STATE_CREATION ERROR #622: CREATESHADER_INVALIDBYTECODE]

This Xe-LP reports a maximum of 16 lanes, so a shader with a fixed wave size of 32 can't be created there. The test skips WARP on a compute_pipeline error but panics for hardware. Checking D3D12_FEATURE_DATA_D3D12_OPTIONS1.WaveLaneCountMin/Max and skipping when 32 is out of range would fix that. I don't know whether Arc reports the same 16-lane maximum; it's worth checking, since the PR targets Arc.

No game data used. AI-assisted (Claude Code).

**@⁠DeerSilver** on GitHub · 2026-11-24 23:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/1066#issuecomment-7147024209) Tested on an Intel Xe-LP iGPU (not Arc) and an NVIDIA card. **Setup:** one laptop with an NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell, `10de:2d59`, driver 621.24) and an Intel UHD Graphics (Raptor Lake Xe-LP, `8086:a788`, driver 32.0.101.7088), Windows 11 26300, Rust 1.98.1. The PR was merged onto `main` `ffe310e`. - `cargo test --workspace --all-features --locked --no-fail-fast -- --test-threads=1` with the D3D12 debug layer on (`VICTORY_D3D12_DEBUG=1`, and a local, uncommitted change that also turns the debug layer on in victory-shader's test `Host`): 350 passed, 0 failed, 6 ignored. The four new tests passed in that run, which used the default adapter, the RTX. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, with and without `--all-features`: clean victory-shader's lib tests on each adapter (`cargo test --locked -p victory-shader --lib -- --test-threads=1`, with a local switch that creates the test `Host` on a chosen DXGI adapter and prints its name): | | RTX 5060 Laptop | Intel UHD | |---|---|---| | `main` | (not run) | 119 passed, 1 failed (`v_med3_f32_matches_rdna2_with_nan`) | | `main` + this PR | 124 passed, 0 failed | 123 passed, **1 failed** | The PR's NaN bit test fixes `v_med3_f32` on the Intel UHD. The failure with the PR is the new `wave32_simulation_and_reduction_executes_cleanly`: ``` hardware: compute_pipeline failed: The parameter is incorrect. ``` The debug layer gives the reason: ``` D3D12 ERROR: ID3D12Device::CreateComputeShader: Shader wants wave lane count of 32 but maximum wave lane count for device is 16. [ STATE_CREATION ERROR #622: CREATESHADER_INVALIDBYTECODE] ``` This Xe-LP reports a maximum of 16 lanes, so a shader with a fixed wave size of 32 can't be created there. The test skips WARP on a `compute_pipeline` error but panics for hardware. Checking `D3D12_FEATURE_DATA_D3D12_OPTIONS1.WaveLaneCountMin/Max` and skipping when 32 is out of range would fix that. I don't know whether Arc reports the same 16-lane maximum; it's worth checking, since the PR targets Arc. No game data used. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:31 UTC · original

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

A release environment variable (VICTORY_WAVE_SIZE_MAX) makes console wave64 programs that depend on lane order declare WaveSize(32) and simulates their whole-wave sections at 32 lanes, with no emulation and outside the shader cache key: wrong results where it is used. Its other parts exist elsewhere (v_dot4* in main, the med3 NaN test is #1689) or are unrelated (indirect stream compaction against a rewritten indirect.rs).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/1066#issuecomment-7148595278) Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. A release environment variable (VICTORY_WAVE_SIZE_MAX) makes console wave64 programs that depend on lane order declare WaveSize(32) and simulates their whole-wave sections at 32 lanes, with no emulation and outside the shader cache key: wrong results where it is used. Its other parts exist elsewhere (v_dot4* in main, the med3 NaN test is #1689) or are unrelated (indirect stream compaction against a rewritten indirect.rs). If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1066
No description provided.