d3d12, dxbc: refuse incompatible WaveSize(N) compute shaders before driver compile #171

Manually merged
github merged 1 commit from gh-pr/171/head into gh-pr/171/base 2026-11-26 06:36:06 +00:00
Owner

@⁠Vladimir-Human on GitHub · 2026-11-25 13:01 UTC · original
Vladimir-Human:shader/wave32-wave64-diagnostics → main · +295 −34 · 8 files · 1 commits · merged 2026-11-25 14:21 UTC

Refs #151

Summary

Implement Direction (1) for #151: detect incompatible [WaveSize(N)] portable compute DXIL shaders before calling the host D3D12 driver, log an explicit wave-range refusal, and record CS.refused=host-lacks-wave<N> in pipeline-failures/*.tsv (leaving tools/rank_pipeline_failures.py, tests/test_rank_pipeline_failures.py, and docs/PROJECTSCARLETT.md untouched to avoid conflicting with #167):

  • tuxbox-dxbc (runtime/dxbc/src/fspx.rs, runtime/dxbc/src/lib.rs): add wave_lane_range(psv: &[u8]) -> Option<(u32, u32)> reading MinimumExpectedWaveLaneCount and MaximumExpectedWaveLaneCount from PSV0 PSVRuntimeInfo0 (+16/+20), ignoring unconstrained (0, 0) / (0, u32::MAX) and invalid min > max.
  • tuxbox-d3d12:
    • device/dxgi.rs: cache host D3D12_FEATURE_D3D12_OPTIONS1 [WaveLaneCountMin, WaveLaneCountMax] once per host device via OnceLock.
    • device/shader_cache.rs: add portable_wave_range(shader) inspecting PSV0 on ShaderCode::Portable DXIL containers (ignoring XDAT/NOBC).
    • device/compute.rs & device/stream.rs: check unsupported_wave_size in slot 62 (create_pipeline_x_inner) and slot 86 (stream::create fields[5]) before private_root / CreateComputePipelineState / CreatePipelineState; on disjoint ranges, skip the driver compile, log via diagnostics::compute_wave_failure (host lacks wave64 (supported wave range [32, 32])), record CS.refused=host-lacks-wave<N> via failures::refusal, and return the null compute stand-in when TUXBOX_NULL_PIPELINES=1 or E_INVALIDARG otherwise.
    • diagnostics.rs & failures.rs: factor describe_dxbc / log_compute_failure and add failures::refusal for local pre-driver stage refusals.

Verified on Lanes

  • python tuxbox.py check passed on this branch (branch is based on a79aedb prior to MSVC /W4 and #ordinal verify fixes in #169, tests/ hits 5 pre-existing Linux-only fcntl/os.sched_getaffinity test errors on Windows, and lanes-shader-cache is Proton-only; equivalent Rust CI checks, targeted Python tests, lanes.exe, and a direct RTX 4070 SUPER [WaveSize(64)] vs [WaveSize(32)] d3d12_xs.dll probe passed below)
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below (Lanes runs cs_6_0 without [WaveSize(64)] so it exercises the non-refusal path; incompatible [WaveSize(64)] vs compatible [WaveSize(32)] cs_6_6 pipelines are directly verified against d3d12_xs.dll slots 62 and 86 on RTX 4070 SUPER)

GPU, driver and backend: NVIDIA GeForce RTX 4070 SUPER (pci=10de:2783), NVIDIA driver 32.0.16.2114, Windows 11 native backend (MSVC 19.44.35207, Windows SDK 10.0.26100.0 DXC, Rust 1.95.0).

Paste the summary printed at the end:

lanes.exe --selftest all: lanes-selftest PASS pci=10de:2783 scenario=all passed=7
lanes.exe --replay:       lanes-replay PASS pci=10de:2783 course=16/16 win=16/16 safe-miss=1 collision=1 frames=2 input=gameinput
(lanes-shader-cache is Proton-only)

Direct RTX 4070 SUPER cs_6_6 [WaveSize(64)] vs [WaveSize(32)] probe (d3d12_xs.dll slots 62 & 86):
- TUXBOX_NULL_PIPELINES=0: hr62_w64=0x80070057 hr86_w64=0x80070057 hr62_w32=0x00000000 hr86_w32=0x00000000
  log: host lacks wave64 (supported wave range [32, 32])
  tsv: slot62 & slot86 -> 0x80070057 ... CS.refused=host-lacks-wave64
- TUXBOX_NULL_PIPELINES=1: hr62_w64=0x00000000 hr86_w64=0x00000000 hr62_w32=0x00000000 hr86_w32=0x00000000
  tsv: slot62 & slot86 -> stand-in ... CS.refused=host-lacks-wave64

Checks

  • cargo test --locked -p tuxbox-dxbc: 20 passed, 0 failed
  • cargo test --locked -p tuxbox-dxbc --features native-bindings: 54 passed, 0 failed
  • cargo test --locked -p tuxbox-d3d12: 101 passed, 0 failed
  • cargo test --locked -p tuxbox-xg-layout: 14 passed, 0 failed
  • cargo test --locked --manifest-path tools/shader-compiler/Cargo.toml: 279 unit + 2 integration passed, 0 failed
  • cargo check --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 -p tuxbox-bvh: exit 0
  • python -m unittest tests.test_rank_pipeline_failures tests.test_repository_hygiene tests.test_check tests.test_verify -v: 17 passed, 0 failed

AI-assisted implementation and verification.

**@⁠Vladimir-Human** on GitHub · 2026-11-25 13:01 UTC · [original](https://github.com/brcly/TuxBox/pull/171) `Vladimir-Human:shader/wave32-wave64-diagnostics` → `main` · +295 −34 · 8 files · 1 commits · merged 2026-11-25 14:21 UTC Refs #151 ## Summary Implement Direction (1) for `#151`: detect incompatible `[WaveSize(N)]` portable compute DXIL shaders before calling the host D3D12 driver, log an explicit wave-range refusal, and record `CS.refused=host-lacks-wave<N>` in `pipeline-failures/*.tsv` (leaving `tools/rank_pipeline_failures.py`, `tests/test_rank_pipeline_failures.py`, and `docs/PROJECTSCARLETT.md` untouched to avoid conflicting with #167): - **`tuxbox-dxbc`** (`runtime/dxbc/src/fspx.rs`, `runtime/dxbc/src/lib.rs`): add `wave_lane_range(psv: &[u8]) -> Option<(u32, u32)>` reading `MinimumExpectedWaveLaneCount` and `MaximumExpectedWaveLaneCount` from `PSV0` `PSVRuntimeInfo0` (`+16/+20`), ignoring unconstrained `(0, 0)` / `(0, u32::MAX)` and invalid `min > max`. - **`tuxbox-d3d12`**: - `device/dxgi.rs`: cache host `D3D12_FEATURE_D3D12_OPTIONS1` `[WaveLaneCountMin, WaveLaneCountMax]` once per host device via `OnceLock`. - `device/shader_cache.rs`: add `portable_wave_range(shader)` inspecting `PSV0` on `ShaderCode::Portable` DXIL containers (ignoring `XDAT`/`NOBC`). - `device/compute.rs` & `device/stream.rs`: check `unsupported_wave_size` in slot 62 (`create_pipeline_x_inner`) and slot 86 (`stream::create` `fields[5]`) before `private_root` / `CreateComputePipelineState` / `CreatePipelineState`; on disjoint ranges, skip the driver compile, log via `diagnostics::compute_wave_failure` (`host lacks wave64 (supported wave range [32, 32])`), record `CS.refused=host-lacks-wave<N>` via `failures::refusal`, and return the null compute stand-in when `TUXBOX_NULL_PIPELINES=1` or `E_INVALIDARG` otherwise. - `diagnostics.rs` & `failures.rs`: factor `describe_dxbc` / `log_compute_failure` and add `failures::refusal` for local pre-driver stage refusals. ## Verified on Lanes - [ ] `python tuxbox.py check` passed on this branch *(branch is based on `a79aedb` prior to MSVC `/W4` and `#ordinal` verify fixes in #169, `tests/` hits 5 pre-existing Linux-only `fcntl`/`os.sched_getaffinity` test errors on Windows, and `lanes-shader-cache` is Proton-only; equivalent Rust CI checks, targeted Python tests, `lanes.exe`, and a direct RTX 4070 SUPER `[WaveSize(64)]` vs `[WaveSize(32)]` `d3d12_xs.dll` probe passed below)* - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below *(`Lanes` runs `cs_6_0` without `[WaveSize(64)]` so it exercises the non-refusal path; incompatible `[WaveSize(64)]` vs compatible `[WaveSize(32)]` `cs_6_6` pipelines are directly verified against `d3d12_xs.dll` slots 62 and 86 on RTX 4070 SUPER)* GPU, driver and backend: NVIDIA GeForce RTX 4070 SUPER (`pci=10de:2783`), NVIDIA driver `32.0.16.2114`, Windows 11 native backend (MSVC `19.44.35207`, Windows SDK `10.0.26100.0` DXC, Rust `1.95.0`). Paste the summary printed at the end: ```text lanes.exe --selftest all: lanes-selftest PASS pci=10de:2783 scenario=all passed=7 lanes.exe --replay: lanes-replay PASS pci=10de:2783 course=16/16 win=16/16 safe-miss=1 collision=1 frames=2 input=gameinput (lanes-shader-cache is Proton-only) Direct RTX 4070 SUPER cs_6_6 [WaveSize(64)] vs [WaveSize(32)] probe (d3d12_xs.dll slots 62 & 86): - TUXBOX_NULL_PIPELINES=0: hr62_w64=0x80070057 hr86_w64=0x80070057 hr62_w32=0x00000000 hr86_w32=0x00000000 log: host lacks wave64 (supported wave range [32, 32]) tsv: slot62 & slot86 -> 0x80070057 ... CS.refused=host-lacks-wave64 - TUXBOX_NULL_PIPELINES=1: hr62_w64=0x00000000 hr86_w64=0x00000000 hr62_w32=0x00000000 hr86_w32=0x00000000 tsv: slot62 & slot86 -> stand-in ... CS.refused=host-lacks-wave64 ``` ## Checks - `cargo test --locked -p tuxbox-dxbc`: 20 passed, 0 failed - `cargo test --locked -p tuxbox-dxbc --features native-bindings`: 54 passed, 0 failed - `cargo test --locked -p tuxbox-d3d12`: 101 passed, 0 failed - `cargo test --locked -p tuxbox-xg-layout`: 14 passed, 0 failed - `cargo test --locked --manifest-path tools/shader-compiler/Cargo.toml`: 279 unit + 2 integration passed, 0 failed - `cargo check --locked --target x86_64-pc-windows-msvc -p tuxbox-d3d12 -p tuxbox-bvh`: exit 0 - `python -m unittest tests.test_rank_pipeline_failures tests.test_repository_hygiene tests.test_check tests.test_verify -v`: 17 passed, 0 failed AI-assisted implementation and verification.
Refs #151

Query D3D12_FEATURE_D3D12_OPTIONS1 once per host device in DxgiDevice and read MinimumExpectedWaveLaneCount/MaximumExpectedWaveLaneCount from portable DXIL PSV0 headers via tuxbox_dxbc::wave_lane_range.

When a compute pipeline in slot 62 or slot 86 requires a wave lane range disjoint from the host device (for example [WaveSize(64)] on a wave32-only [32, 32] GPU), skip CreateComputePipelineState (and any fallback retry), log the wave-range refusal via diagnostics::compute_wave_failure, record CS.refused=host-lacks-wave<N> in failures.rs, and return the null compute stand-in (or E_INVALIDARG with TUXBOX_NULL_PIPELINES=0).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:36:04 +00:00
github manually merged commit 6161046441 into gh-pr/171/base 2026-11-26 06:36:06 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.