Shaders: lower the console's scalar bit searches (s_flbit_i32_b64, s_ff0_i32_b32/b64) #233

Open
pablogonz12 wants to merge 3 commits from upstream-pr/233 into main
pablogonz12 commented 2026-11-24 22:52:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pablogonz12 on 2026-11-24T22:52:54Z.


Setup: RX 9070 XT (RDNA4), RADV Mesa 26.3.1, Linux, GE-Proton11-14, Series X files.

The decoder names s_flbit_i32_b64, s_ff0_i32_b32, s_ff0_i32_b64 (and the dword
widths in gfx10/fields.rs know their 64-bit sources), but the scalar lowering has no
arms for them: they fall through to the catch-all and a shader containing one is refused
whole. This adds them in DXIL unaryBits, as TuxBox does: the 64-bit searches test the
high word first and continue 32 past the low word's own result, −1 for a zero pair
(s_flbit) or an all-ones pair (s_ff0); none writes SCC.

Complements #171 (GeaorgeAyvazov), which lowers s_bcnt0_i32_b32/b64; that family is
left out here so the two changes do not both touch it.

Adapted from TuxBox (brcly/TuxBox, Apache-2.0, commit 1a50eb9 "shader: restore
s_flbit_i32_b64 and s_ff0_i32 lowering dropped by a merge", Copyright (c) 2026 the TuxBox
authors); NOTICE added. Not ported: s_flbit_i32_i64, which TuxBox guards but does not
lower either.

On an RX 9070 XT this changes 0 of our 751 world programs and 0 of the 25,586 archive
programs
(all 767 emitted DXIL containers byte-identical); it is for the console
programs that carry these instructions, which our captures do not contain. Tests: a
Windows/WARP + hardware oracle for the three against the console's answers, and a
platform-neutral test whose hand-assembled encodings decode to the three names (refused
before). cargo clippy --workspace --all-targets [--all-features] -- -D warnings clean.

AI-assisted: written and tested with an AI coding agent; the port was compared
against TuxBox's source by hand.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5481676937 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/233). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T22:52:54Z. --- Setup: RX 9070 XT (RDNA4), RADV Mesa 26.3.1, Linux, GE-Proton11-14, Series X files. The decoder names `s_flbit_i32_b64`, `s_ff0_i32_b32`, `s_ff0_i32_b64` (and the dword widths in `gfx10/fields.rs` know their 64-bit sources), but the scalar lowering has no arms for them: they fall through to the catch-all and a shader containing one is refused whole. This adds them in DXIL `unaryBits`, as TuxBox does: the 64-bit searches test the high word first and continue 32 past the low word's own result, −1 for a zero pair (`s_flbit`) or an all-ones pair (`s_ff0`); none writes SCC. Complements #171 (GeaorgeAyvazov), which lowers `s_bcnt0_i32_b32/b64`; that family is left out here so the two changes do not both touch it. Adapted from TuxBox (brcly/TuxBox, Apache-2.0, commit 1a50eb9 "shader: restore s_flbit_i32_b64 and s_ff0_i32 lowering dropped by a merge", Copyright (c) 2026 the TuxBox authors); `NOTICE` added. Not ported: `s_flbit_i32_i64`, which TuxBox guards but does not lower either. On an RX 9070 XT this changes **0 of our 751 world programs and 0 of the 25,586 archive programs** (all 767 emitted DXIL containers byte-identical); it is for the console programs that carry these instructions, which our captures do not contain. Tests: a Windows/WARP + hardware oracle for the three against the console's answers, and a platform-neutral test whose hand-assembled encodings decode to the three names (refused before). `cargo clippy --workspace --all-targets [--all-features] -- -D warnings` clean. AI-assisted: written and tested with an AI coding agent; the port was compared against TuxBox's source by hand.
chatgpt-codex-connector[bot commented 2026-11-24 23:09:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:53:01Z.


Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-24T22:52:59.051238Z
We couldn’t complete this review. Comment @codex review to try again.
4db8615 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7146755321 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/233#issuecomment-7146755321). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:53:01Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"4db86158d26e73381dc0024921f08d2c61f8b5af","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ❌ Failed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ❌ **Failed** <relative-time datetime="2026-11-24T22:52:59.051238Z">2026-11-24T22:52:59.051238Z</relative-time><br/>We couldn’t complete this review. Comment `@codex review` to try again. | `4db8615` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-24 23:09:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:53:03Z.


You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7146755981 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/233#issuecomment-7146755981). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:53:03Z. --- You have reached your Codex usage limits for code reviews. You can see your limits in the [Codex usage dashboard](https://chatgpt.com/codex/cloud/settings/usage).
HAL9000RELOADED commented 2026-11-25 20:09:27 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T19:29:53Z.


RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: both new tests pass on the card with this PR. With the tests alone on the base, scalar_bit_searches_match_the_console fails (the other test is inline). No other test changed. Run table: #129 (https://github.com/fxceless/victory-fork/pull/129#issuecomment-7172358511).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7172378940 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/233#issuecomment-7172378940). Originally posted by [HAL9000RELOADED](https://github.com/HAL9000RELOADED) on 2026-11-25T19:29:53Z. --- RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main `d510ee4`: both new tests pass on the card with this PR. With the tests alone on the base, `scalar_bit_searches_match_the_console` fails (the other test is inline). No other test changed. Run table: #129 (https://github.com/fxceless/victory-fork/pull/129#issuecomment-7172358511).
pablogonz12 commented 2026-11-27 10:38:47 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by pablogonz12 on 2026-11-27T10:38:47Z.


Merged main 9a9091d18 in (7ba3e3d8), so the branch is mergeable again. The only conflict was the lowering tests: main moved them to lower_tests.rs and already carries scalar_bit_tests_lower there, so the inline module goes and scalar_bit_searches_lower moves next to it unchanged. The lowering itself auto-merged.

On RX 9070 XT (Mesa 26.3.1 RADV, GE-Proton11-14 Wine, windows target): victory-shader lib 253 passed, 1 failed - emit::tests::stub_pipeline_is_created, which also fails here before this merge (this prefix has no dxil.dll, so the stub validator accepts an all-zero digest). The three scalar-bit tests pass. clippy --workspace --all-targets is clean apart from new lints in valu_tests.rs that main brings in unchanged.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7216134987 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/233#issuecomment-7216134987). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-27T10:38:47Z. --- Merged main `9a9091d18` in (`7ba3e3d8`), so the branch is mergeable again. The only conflict was the lowering tests: main moved them to `lower_tests.rs` and already carries `scalar_bit_tests_lower` there, so the inline module goes and `scalar_bit_searches_lower` moves next to it unchanged. The lowering itself auto-merged. On RX 9070 XT (Mesa 26.3.1 RADV, GE-Proton11-14 Wine, windows target): `victory-shader` lib 253 passed, 1 failed - `emit::tests::stub_pipeline_is_created`, which also fails here before this merge (this prefix has no `dxil.dll`, so the stub validator accepts an all-zero digest). The three scalar-bit tests pass. `clippy --workspace --all-targets` is clean apart from new lints in `valu_tests.rs` that main brings in unchanged.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/233:upstream-pr/233'
git switch 'upstream-pr/233'

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 'upstream-pr/233'
git switch 'upstream-pr/233'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/233'
git switch 'upstream-pr/233'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/233'
git switch 'main'
git merge --squash 'upstream-pr/233'
git switch 'main'
git merge --ff-only 'upstream-pr/233'
git switch 'main'
git merge 'upstream-pr/233'
git push origin 'main'
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
fxceless/victory-fork!233
No description provided.