d3d12, dxbc: convert slot 80 thread-dimension dispatches using bound PSO numthreads #170

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

@⁠Vladimir-Human on GitHub · 2026-11-25 12:58 UTC · original
Vladimir-Human:d3d12/slot80-thread-dimensions → main · +517 −28 · 10 files · 1 commits · merged 2026-11-25 14:21 UTC

Refs #164

Summary

Handle COMPUTE_DISPATCH_INITIATOR__USE_THREAD_DIMENSIONS (0x20) in command-list slot 80 (dispatch_flagged):

  • tuxbox-dxbc (runtime/dxbc/src/fspx.rs, runtime/dxbc/src/lib.rs): add shader_compute_threads to extract [numthreads(x, y, z)] from compute DXBC containers (PSV0, SM4/5 SHEX dcl_thread_group skipping CUSTOMDATA, and Xbox XDAT/FSSM compute preambles under native-bindings), plus unit tests.
  • tuxbox-d3d12 (runtime/d3d12/src/device/compute.rs, device/stream.rs, commands/compute_bindings.rs, commands/compute.rs, commands.rs):
    • Capture compute_threads: Option<[u32; 3]> on slot 62 (create_pipeline_x) and slot 86 (stream::create) compute pipelines (including null_compute / null_pipeline stand-ins), and track it on the command list's bound pipeline across CreateCommandListX, Reset, SetPipelineState, and ClearState.
    • In dispatch_flagged, convert flags & 0x20 thread counts to ceil(t / g) groups via overflow-safe u32::div_ceil (0 -> 0), keep 0x0 / 0x8000 (CS_W32_EN) dispatches as group counts, fail closed (E_INVALIDARG / E_NOTIMPL + diagnostic) when 0x20 is set without known [numthreads], and log once on partial boundary round-ups (t % g != 0) because desktop Dispatch does not mask surplus boundary threads without altering shader/root ABIs.
  • Lanes self-test (examples/lanes/selftest.cpp, examples/lanes/README.md, project_tuxbox/verify.py): add thread-dimensions (lanes-selftest-thread-dimensions) covering slot 62 + slot 86 PSOs, Reset / SetPipelineState / ClearState, fail-closed missing/cleared PSO refusal, 0x20/0x8020 exact guard preservation, x=70000 (> 65535 group limit) scaling, 13 partial threads, 0 threads, and group-mode (0x0, 0x8000) dispatches.

Verified on Lanes

  • python tuxbox.py check passed on this branch (not fully runnable on native Windows before MSVC/verify fixes in #169: buffer_import_guest.cpp fails /W4 /WX, verify.py fails on MSVC #ordinal imports, tests/ hits Linux-only fcntl/os.sched_getaffinity errors, and lanes-shader-cache is Proton-only; equivalent Rust CI checks, Windows-compatible Python tests, provider/Lanes build, and direct lanes.exe GPU runs passed below)
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below (thread-dimensions in examples/lanes/selftest.cpp and lanes-selftest-thread-dimensions in project_tuxbox/verify.py)

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 thread-dimensions: lanes-selftest PASS pci=10de:2783 scenario=thread-dimensions passed=1
lanes.exe --selftest all:               lanes-selftest PASS pci=10de:2783 scenario=all passed=11
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; surplus-thread boundary masking for t % g != 0 is out of scope and logged once)

Checks

  • cargo test --locked -p tuxbox-dxbc --features native-bindings: 55 passed, 0 failed
  • cargo test --locked -p tuxbox-d3d12: 99 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_check tests.test_verify tests.test_repository_hygiene tests.test_cli tests.test_d3d12_regressions tests.test_d3d12_status tests.test_package_binaries tests.test_build_msvc tests.test_inspect -v: 46 ran, 45 ok, 1 skipped (test_case_collision on Windows case-insensitive filesystem)
  • cl /W4 /WX on examples/lanes/selftest.cpp: 0 warnings, exit 0

AI-assisted implementation and verification.

**@⁠Vladimir-Human** on GitHub · 2026-11-25 12:58 UTC · [original](https://github.com/brcly/TuxBox/pull/170) `Vladimir-Human:d3d12/slot80-thread-dimensions` → `main` · +517 −28 · 10 files · 1 commits · merged 2026-11-25 14:21 UTC Refs #164 ## Summary Handle `COMPUTE_DISPATCH_INITIATOR__USE_THREAD_DIMENSIONS` (`0x20`) in command-list slot 80 (`dispatch_flagged`): - **`tuxbox-dxbc`** (`runtime/dxbc/src/fspx.rs`, `runtime/dxbc/src/lib.rs`): add `shader_compute_threads` to extract `[numthreads(x, y, z)]` from compute DXBC containers (`PSV0`, SM4/5 `SHEX` `dcl_thread_group` skipping `CUSTOMDATA`, and Xbox `XDAT`/`FSSM` compute preambles under `native-bindings`), plus unit tests. - **`tuxbox-d3d12`** (`runtime/d3d12/src/device/compute.rs`, `device/stream.rs`, `commands/compute_bindings.rs`, `commands/compute.rs`, `commands.rs`): - Capture `compute_threads: Option<[u32; 3]>` on slot 62 (`create_pipeline_x`) and slot 86 (`stream::create`) compute pipelines (including `null_compute` / `null_pipeline` stand-ins), and track it on the command list's bound pipeline across `CreateCommandListX`, `Reset`, `SetPipelineState`, and `ClearState`. - In `dispatch_flagged`, convert `flags & 0x20` thread counts to `ceil(t / g)` groups via overflow-safe `u32::div_ceil` (`0 -> 0`), keep `0x0` / `0x8000` (`CS_W32_EN`) dispatches as group counts, fail closed (`E_INVALIDARG` / `E_NOTIMPL` + diagnostic) when `0x20` is set without known `[numthreads]`, and log once on partial boundary round-ups (`t % g != 0`) because desktop `Dispatch` does not mask surplus boundary threads without altering shader/root ABIs. - **Lanes self-test** (`examples/lanes/selftest.cpp`, `examples/lanes/README.md`, `project_tuxbox/verify.py`): add `thread-dimensions` (`lanes-selftest-thread-dimensions`) covering slot 62 + slot 86 PSOs, `Reset` / `SetPipelineState` / `ClearState`, fail-closed missing/cleared PSO refusal, `0x20`/`0x8020` exact guard preservation, `x=70000` (`> 65535` group limit) scaling, `13` partial threads, `0` threads, and group-mode (`0x0`, `0x8000`) dispatches. ## Verified on Lanes - [ ] `python tuxbox.py check` passed on this branch *(not fully runnable on native Windows before MSVC/verify fixes in #169: `buffer_import_guest.cpp` fails `/W4 /WX`, `verify.py` fails on MSVC `#ordinal` imports, `tests/` hits Linux-only `fcntl`/`os.sched_getaffinity` errors, and `lanes-shader-cache` is Proton-only; equivalent Rust CI checks, Windows-compatible Python tests, provider/Lanes build, and direct `lanes.exe` GPU runs passed below)* - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below (`thread-dimensions` in `examples/lanes/selftest.cpp` and `lanes-selftest-thread-dimensions` in `project_tuxbox/verify.py`) 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 thread-dimensions: lanes-selftest PASS pci=10de:2783 scenario=thread-dimensions passed=1 lanes.exe --selftest all: lanes-selftest PASS pci=10de:2783 scenario=all passed=11 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; surplus-thread boundary masking for t % g != 0 is out of scope and logged once) ``` ## Checks - `cargo test --locked -p tuxbox-dxbc --features native-bindings`: 55 passed, 0 failed - `cargo test --locked -p tuxbox-d3d12`: 99 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_check tests.test_verify tests.test_repository_hygiene tests.test_cli tests.test_d3d12_regressions tests.test_d3d12_status tests.test_package_binaries tests.test_build_msvc tests.test_inspect -v`: 46 ran, 45 ok, 1 skipped (`test_case_collision` on Windows case-insensitive filesystem) - `cl /W4 /WX` on `examples/lanes/selftest.cpp`: 0 warnings, exit 0 AI-assisted implementation and verification.
Refs #164

In slot 80 (dispatch_flagged), bit 5 (0x20, USE_THREAD_DIMENSIONS in
COMPUTE_DISPATCH_INITIATOR) supplies total thread counts (x, y, z) rather
than group counts, while bit 15 (0x8000, CS_W32_EN) selects wave-32 mode.

- tuxbox-dxbc: add shader_compute_threads to inspect [numthreads(x, y, z)]
  from DXBC containers (PSV0, SM4/5 SHEX dcl_thread_group, and
  native-bindings Xbox XDAT/FSSM compute preambles).
- tuxbox-d3d12: record compute_threads on slot 62 and slot 86 compute
  pipelines (including fallback/null stand-ins), track it on the command list's
  bound pipeline (Reset, SetPipelineState, ClearState), and in slot 80
  convert thread counts to ceil(t / g) groups (0 -> 0, overflow-safe via
  u32::div_ceil). Dispatches without bit 0x20 keep group counts unchanged.
- Fail closed (E_INVALIDARG / E_NOTIMPL + diagnostic) if bit 0x20 is set
  without a bound compute PSO's group size, and log once when non-multiple
  thread counts round up because desktop Dispatch cannot mask surplus
  boundary threads without modifying shader/root ABIs.
- lanes: add the thread-dimensions GPU self-test covering slot 62/86 PSOs,
  missing/cleared PSO refusal, 0x20/0x8020 exact guard preservation,
  x=70000 (> 65535 group limit) scaling, 13 partial threads, 0 threads, and
  ordinary group dispatches (0x0, 0x8000).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:35:59 +00:00
github manually merged commit 2edd4a95ea into gh-pr/170/base 2026-11-26 06:36:01 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.