xshader: skip uniform scalar arithmetic and bitcounts in scc_from_mask #558

Merged
glovepost merged 1 commit from upstream-pr/558 into main 2026-12-01 14:48:46 +00:00
glovepost commented 2026-11-29 23:17:59 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-29T23:17:59Z.


Split out from #523 per review. Extends hlsl::driver::abi::scc_from_mask so uniform scalar arithmetic and bit counts (s_add_*, s_sub_*, s_min_*, s_max_*, s_abs_i32, s_bcnt1_*) whose sources do not read exec or vcc are recognized as wave-uniform rather than treated as per-lane masks.

Changes

  • tools/shader-compiler/src/hlsl/driver/abi.rs: skip uniform scalar arithmetic and bit counts without exec/vcc sources in scc_from_mask.
  • tools/shader-compiler/src/tests/hlsl/abi.rs: add scc_from_mask_skips_uniform_scalar_arithmetic_and_bit_counts.

Verification

  • python3 tuxbox.py check --no-gpu passed 9/9 checks:
    • Python tests: 739 run, 1 skipped, 0 failed
    • Shader compiler tests: 649 + 3 + 2 passed (host_profiles unchanged)
    • DXBC tests: 120 passed
    • XG layout tests: 24 passed, 1 ignored; XG entry point tests: 7 passed
    • Storage codec tests: 22 passed
    • ACP HAL tests: 9 passed
    • D3D12 Windows typecheck: passed
  • Tested against 258 recorded ProjectScarlett shader requests using runtime DXC 1.9 (1.9.2609.5) flags (-disable-lifetime-markers -fnew-inlining-behavior, plus -O1 for cs_6_6): 213/213 translated shaders compiled with 0 DXC segfaults (45 unsupported by xshader, identical to origin/main).
  • tools/stage_baseline.py cpu across the 58 locally recorded tools/reference/stage-baseline/sample.json requests (89 translations): 89/89 compiled and 89/89 had byte-identical HLSL and DXIL (0 regressions).
  • GPU tests (tuxbox.py check) and ProjectScarlett were not run against this split branch.

AI-assisted: split, rebased, and tested with LLM tooling.

<!-- greyfinch-sync:brcly/TuxBox:issue:5556228581 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/558). Originally posted by [glovepost](https://github.com/glovepost) on 2026-11-29T23:17:59Z. --- Split out from #523 per review. Extends `hlsl::driver::abi::scc_from_mask` so uniform scalar arithmetic and bit counts (`s_add_*`, `s_sub_*`, `s_min_*`, `s_max_*`, `s_abs_i32`, `s_bcnt1_*`) whose sources do not read `exec` or `vcc` are recognized as wave-uniform rather than treated as per-lane masks. ### Changes - `tools/shader-compiler/src/hlsl/driver/abi.rs`: skip uniform scalar arithmetic and bit counts without `exec`/`vcc` sources in `scc_from_mask`. - `tools/shader-compiler/src/tests/hlsl/abi.rs`: add `scc_from_mask_skips_uniform_scalar_arithmetic_and_bit_counts`. ### Verification - `python3 tuxbox.py check --no-gpu` passed 9/9 checks: - Python tests: 739 run, 1 skipped, 0 failed - Shader compiler tests: 649 + 3 + 2 passed (`host_profiles` unchanged) - DXBC tests: 120 passed - XG layout tests: 24 passed, 1 ignored; XG entry point tests: 7 passed - Storage codec tests: 22 passed - ACP HAL tests: 9 passed - D3D12 Windows typecheck: passed - Tested against 258 recorded ProjectScarlett shader requests using runtime DXC 1.9 (`1.9.2609.5`) flags (`-disable-lifetime-markers -fnew-inlining-behavior`, plus `-O1` for `cs_6_6`): `213/213` translated shaders compiled with **0 DXC segfaults** (`45` unsupported by `xshader`, identical to `origin/main`). - `tools/stage_baseline.py cpu` across the 58 locally recorded `tools/reference/stage-baseline/sample.json` requests (`89` translations): `89/89` compiled and `89/89` had byte-identical HLSL and DXIL (`0` regressions). - GPU tests (`tuxbox.py check`) and ProjectScarlett were not run against this split branch. AI-assisted: split, rebased, and tested with LLM tooling.
glovepost commented 2026-11-30 01:00:47 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by glovepost on 2026-11-30T01:00:47Z.


Rebased onto main (f482572a, commit 6d414666358b) with no functional changes from cf5c43f0, and ran the changed GPU checks on NVIDIA:

  • Command: TUXBOX_CHECK_JOBS=2 DXC=<dxc> python3 tuxbox.py check --changed --adapter 10de:1e84 --proton <proton> --prefix <prefix> --windows-dxc <windows-dxc>
  • GPU / driver / backend: NVIDIA GeForce RTX 2070 SUPER (10de:1e84), driver 620.73.04, GE-Proton11-14
  • Results: Lanes and fixtures on the GPU (lanes-bindless-compute, lanes-compute-root, lanes-compute-root-recovery, lanes-raster-tables, lanes-shader-cache) and Shader translator on the GPU all passed (13 passed, 0 failed, 0 not run).
  • Still missing: AMD GPU checks. ProjectScarlett was not run on this commit.

Evidence: TuxBox check of 6d414666358b, no uncommitted changes, GPU 10de:1e84: 13 passed, 0 failed, 0 not run

<!-- greyfinch-sync:brcly/TuxBox:comment:7265766381 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/558#issuecomment-7265766381). Originally posted by [glovepost](https://github.com/glovepost) on 2026-11-30T01:00:47Z. --- Rebased onto `main` (`f482572a`, commit `6d414666358b`) with no functional changes from `cf5c43f0`, and ran the changed GPU checks on NVIDIA: - **Command:** `TUXBOX_CHECK_JOBS=2 DXC=<dxc> python3 tuxbox.py check --changed --adapter 10de:1e84 --proton <proton> --prefix <prefix> --windows-dxc <windows-dxc>` - **GPU / driver / backend:** NVIDIA GeForce RTX 2070 SUPER (`10de:1e84`), driver `620.73.04`, `GE-Proton11-14` - **Results:** `Lanes and fixtures on the GPU` (`lanes-bindless-compute`, `lanes-compute-root`, `lanes-compute-root-recovery`, `lanes-raster-tables`, `lanes-shader-cache`) and `Shader translator on the GPU` all passed (**13 passed, 0 failed, 0 not run**). - **Still missing:** AMD GPU checks. ProjectScarlett was not run on this commit. `Evidence: TuxBox check of 6d414666358b, no uncommitted changes, GPU 10de:1e84: 13 passed, 0 failed, 0 not run`
NickStallman commented 2026-11-30 01:52:32 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-30T01:52:32Z.


The AMD check you were missing, on 6d414666: AMD iGPU (1002:13c0, RADV, Mesa 26.0.8, GE-Proton11-14, Linux), full python tuxbox.py check: 197 pass, 2 fail. The two are d3d12-stream and guest-frame-rgb10, each stopped by its 30 s limit at load 15 (another card's check and a game were running). Their suites run separately afterwards, at load about 6, pass in 3 of 3 runs, so I read the timeouts as our load, not the change. It isn't a clean full check. ProjectScarlett wasn't run on it. We also have mesh-program runs queued for this and #555 on both cards.

Evidence: TuxBox check of 6d41466635, no uncommitted changes, GPU 1002:13c0: 13 passed, 1 failed, 0 not run

<!-- greyfinch-sync:brcly/TuxBox:comment:7266513952 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/558#issuecomment-7266513952). Originally posted by [NickStallman](https://github.com/NickStallman) on 2026-11-30T01:52:32Z. --- The AMD check you were missing, on 6d414666: AMD iGPU (`1002:13c0`, RADV, Mesa 26.0.8, GE-Proton11-14, Linux), full `python tuxbox.py check`: 197 pass, 2 fail. The two are `d3d12-stream` and `guest-frame-rgb10`, each stopped by its 30 s limit at load 15 (another card's check and a game were running). Their suites run separately afterwards, at load about 6, pass in 3 of 3 runs, so I read the timeouts as our load, not the change. It isn't a clean full check. ProjectScarlett wasn't run on it. We also have mesh-program runs queued for this and #555 on both cards. Evidence: TuxBox check of 6d414666358b, no uncommitted changes, GPU 1002:13c0: 13 passed, 1 failed, 0 not run
Claudineijoseprill commented 2026-11-30 03:35:40 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Claudineijoseprill on 2026-11-30T03:35:40Z.


AMD discrete RDNA 1 run, on 6d414666: Radeon RX 5700 XT (1002:731f, RADV, Mesa 25.2.8, GE-Proton11-14, Ubuntu 24.04), python tuxbox.py check --changed with --proton, --prefix and --windows-dxc: 101 pass, 9 fail.

Every gate matches a full check of unchanged main (f482572a) on the same machine; no regressions. The 9 failures are features this card or driver lacks and fail the same on main: 5 lanes-mesh-* and translated-mesh (no mesh shaders), bvh64-query and bvh32-query (no ray tracing), and pixel-interp (flat and half fail with pipeline E_INVALIDARG; RADV doesn't expose VK_KHR_fragment_shader_barycentric on this card).

Not run: a game.

Evidence: TuxBox check of 6d41466635, no uncommitted changes, GPU default adapter: 11 passed, 2 failed, 0 not run

<!-- greyfinch-sync:brcly/TuxBox:comment:7268026158 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/558#issuecomment-7268026158). Originally posted by [Claudineijoseprill](https://github.com/Claudineijoseprill) on 2026-11-30T03:35:40Z. --- AMD discrete RDNA 1 run, on 6d414666: Radeon RX 5700 XT (`1002:731f`, RADV, Mesa 25.2.8, GE-Proton11-14, Ubuntu 24.04), `python tuxbox.py check --changed` with `--proton`, `--prefix` and `--windows-dxc`: 101 pass, 9 fail. Every gate matches a full check of unchanged `main` (f482572a) on the same machine; no regressions. The 9 failures are features this card or driver lacks and fail the same on `main`: 5 `lanes-mesh-*` and `translated-mesh` (no mesh shaders), `bvh64-query` and `bvh32-query` (no ray tracing), and `pixel-interp` (`flat` and `half` fail with pipeline `E_INVALIDARG`; RADV doesn't expose `VK_KHR_fragment_shader_barycentric` on this card). Not run: a game. Evidence: TuxBox check of 6d414666358b, no uncommitted changes, GPU default adapter: 11 passed, 2 failed, 0 not run
brcly commented 2026-11-30 04:12:10 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-30T04:12:10Z.


Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase.

  • Formatting: the whole workspace is now formatted with rustfmt (see the new rustfmt.toml).
  • Lints: every crate denies unwrap(), lossy as casts and undocumented unsafe outside tests.
  • CI: it now also runs cargo fmt --check, rustdoc with warnings denied, and Miri on the providers' unit tests.

The least painful way is to format your branch first, so the rebase only shows real changes:

git fetch origin
git checkout origin/main -- rustfmt.toml
cargo fmt --all && git commit -am "rustfmt"
git rebase origin/main

Then run python tuxbox.py check --no-gpu, which now includes the format step.

If clippy flags something new:

  • A cast: use From for widening, TryFrom for narrowing, and a mask for bit fields.
  • An unwrap(): use ?, or expect with the reason it can't fail.
  • An unsafe block: it needs a // SAFETY: comment.

CONTRIBUTING's "Code checks" section lists the commands. Thanks!

<!-- greyfinch-sync:brcly/TuxBox:comment:7268559848 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/558#issuecomment-7268559848). Originally posted by [brcly](https://github.com/brcly) on 2026-11-30T04:12:10Z. --- Heads-up: main just landed a large cleanup (up to e5d2e913), so this PR needs a rebase. - **Formatting:** the whole workspace is now formatted with rustfmt (see the new `rustfmt.toml`). - **Lints:** every crate denies `unwrap()`, lossy `as` casts and undocumented `unsafe` outside tests. - **CI:** it now also runs `cargo fmt --check`, rustdoc with warnings denied, and Miri on the providers' unit tests. The least painful way is to format your branch first, so the rebase only shows real changes: ```sh git fetch origin git checkout origin/main -- rustfmt.toml cargo fmt --all && git commit -am "rustfmt" git rebase origin/main ``` Then run `python tuxbox.py check --no-gpu`, which now includes the format step. If clippy flags something new: - **A cast:** use `From` for widening, `TryFrom` for narrowing, and a mask for bit fields. - **An `unwrap()`:** use `?`, or `expect` with the reason it can't fail. - **An `unsafe` block:** it needs a `// SAFETY:` comment. CONTRIBUTING's "Code checks" section lists the commands. Thanks!
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
brcly/TuxBox!558
No description provided.