WIP: Preserve packed scalar bits when reading a compute lane mask #535

Draft
holoslicer wants to merge 1 commit from holoslicer/Darner:fix/preserve-packed-scalar-bits into Main
Contributor

Refs #67. Tested offline on an RTX 3090. An in-game shadow comparison is still needed.

Contributor role (optional)

Already requested in #529.

What it changes

The compute translator refused a shadow shader when a scalar AND/OR result had also been tracked as a lane mask. When only a subset of lanes is active, a wave ballot cannot recover the original 32-bit number.

After ordinary compute lowering exhausts its existing paths and reports this specific refusal, retry with the original scalar bits for 32-bit AND and OR. Both sources must have exact dwords, and the destination must be an ordinary scalar register. EXEC and VCC retain their existing handling. If the retry fails, report the original error.

How it was tested

  • Tested bff7629 on c8258f9, Windows x64, RTX 3090 with NVIDIA driver 617.42. The same private Wave32 input failed on the release, main and #501. A synthetic program in the PR reproduces the refusal without game data.
  • Run cargo test --locked -p darner-shader --lib packed_scalar_mask_keeps_bits_outside_the_active_lanes -- --nocapture. The baseline fails lowering. The change dispatched both scalar-branch paths and read back all five expected 32-bit values, including high bits with only one active lane. This machine's WARP adapter lacks the required 32-lane wave size.
  • Across 2,734 unique compute shaders from one local cache, main emitted 2,733 and this branch emitted 2,734. All 2,733 previously accepted programs produced identical DXIL digests, byte lengths and ray-query metadata.
  • For the four compute cases discussed on #501 and #67, the Microsoft DXIL validator accepted all four candidate outputs and an RTX 3090 created all four compute pipelines. The newly accepted case lifted four of four traversal loops to hardware ray tracing. Pixel output, dispatch cost, frame rate and crash behavior remain unmeasured.
  • cargo clippy --locked -p darner-shader --all-targets --all-features -- -D warnings and cargo xtask policy passed on this revision. The workspace gates and a same-scene in-game A/B are outstanding. Submitted as a draft.
  • cargo test --locked --offline -p darner-shader --lib -- --test-threads=1 --skip oracle64::legacy_mul_forms_are_exact passed 568 tests with 16 ignored. The exhaustive all-f32 multiply oracle was the one explicitly excluded test.

Checklist

  • Reproduced the failure and compared shader output and hardware readbacks on the same machine.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md. The committed fixture is synthetic.
  • This patch has no prerequisites.

Checked for overlap

  • Searched issues and PRs for #67, the lane-mask refusal and packed scalar operations, including PRs touching the emitter.
  • #501 improves the folded wave64 path. Its head still refuses the native Wave32 case fixed here. This patch does not require #501. Other recent work touching the emitter includes #504, #510 and #515.
Refs #67. Tested offline on an RTX 3090. An in-game shadow comparison is still needed. ## Contributor role (optional) Already requested in #529. ## What it changes The compute translator refused a shadow shader when a scalar AND/OR result had also been tracked as a lane mask. When only a subset of lanes is active, a wave ballot cannot recover the original 32-bit number. After ordinary compute lowering exhausts its existing paths and reports this specific refusal, retry with the original scalar bits for 32-bit AND and OR. Both sources must have exact dwords, and the destination must be an ordinary scalar register. EXEC and VCC retain their existing handling. If the retry fails, report the original error. ## How it was tested - Tested `bff7629` on `c8258f9`, Windows x64, RTX 3090 with NVIDIA driver 617.42. The same private Wave32 input failed on the release, main and #501. A synthetic program in the PR reproduces the refusal without game data. - Run `cargo test --locked -p darner-shader --lib packed_scalar_mask_keeps_bits_outside_the_active_lanes -- --nocapture`. The baseline fails lowering. The change dispatched both scalar-branch paths and read back all five expected 32-bit values, including high bits with only one active lane. This machine's WARP adapter lacks the required 32-lane wave size. - Across 2,734 unique compute shaders from one local cache, main emitted 2,733 and this branch emitted 2,734. All 2,733 previously accepted programs produced identical DXIL digests, byte lengths and ray-query metadata. - For the four compute cases discussed on #501 and #67, the Microsoft DXIL validator accepted all four candidate outputs and an RTX 3090 created all four compute pipelines. The newly accepted case lifted four of four traversal loops to hardware ray tracing. Pixel output, dispatch cost, frame rate and crash behavior remain unmeasured. - `cargo clippy --locked -p darner-shader --all-targets --all-features -- -D warnings` and `cargo xtask policy` passed on this revision. The workspace gates and a same-scene in-game A/B are outstanding. Submitted as a draft. - `cargo test --locked --offline -p darner-shader --lib -- --test-threads=1 --skip oracle64::legacy_mul_forms_are_exact` passed 568 tests with 16 ignored. The exhaustive all-f32 multiply oracle was the one explicitly excluded test. ## Checklist - [x] Reproduced the failure and compared shader output and hardware readbacks on the same machine. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. The committed fixture is synthetic. - [x] This patch has no prerequisites. ## Checked for overlap - [x] Searched issues and PRs for #67, the lane-mask refusal and packed scalar operations, including PRs touching the emitter. - #501 improves the folded wave64 path. Its head still refuses the native Wave32 case fixed here. This patch does not require #501. Other recent work touching the emitter includes #504, #510 and #515.
TrustNo1 changed title from WIP: [pr-fix][shaders][RAYTRACING] Preserve packed scalar bits when reading a compute lane mask to WIP: Preserve packed scalar bits when reading a compute lane mask 2026-12-06 03:27:35 +00:00
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'fix/preserve-packed-scalar-bits:holoslicer-fix/preserve-packed-scalar-bits'
git switch 'holoslicer-fix/preserve-packed-scalar-bits'

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 'holoslicer-fix/preserve-packed-scalar-bits'
git switch 'holoslicer-fix/preserve-packed-scalar-bits'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'holoslicer-fix/preserve-packed-scalar-bits'
git switch 'holoslicer-fix/preserve-packed-scalar-bits'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'holoslicer-fix/preserve-packed-scalar-bits'
git switch 'Main'
git merge --squash 'holoslicer-fix/preserve-packed-scalar-bits'
git switch 'Main'
git merge --ff-only 'holoslicer-fix/preserve-packed-scalar-bits'
git switch 'Main'
git merge 'holoslicer-fix/preserve-packed-scalar-bits'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
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
TrustNo1/Darner!535
No description provided.