Shaders: lower s_bcnt0_i32_b32/b64 and s_ff0_i32_b32/b64 #165
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!165
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/165/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@n-romanovich on GitHub · 2026-11-24 01:02 UTC · original
n-romanovich:feat/scalar-bitcount-firstbit→main· +156 −9 · 2 files · 3 commits · closed without mergingImplements DXIL lowering for the zero-bit counting and find-first-zero scalar ALU instructions in
victory-shader:s_bcnt0_i32_b32: bitwise invertssrc0and counts set bits via DXILunaryBits.i32(31), updatingSCC(result != 0).s_ff0_i32_b32: bitwise invertssrc0and finds the lowest set bit via DXILunaryBits.i32(32, returning-1when all bits are1).s_bcnt0_i32_b64,s_ff0_i32_b64: shares the 64-bit split-dword lowering paths withs_bcnt1_i32_b64ands_ff1_i32_b64over inverted dwords, without requiring DXILINT64.Testing
emit::tests::scalar_bitcount_and_first_zero_execute_on_gpuincrates/victory-shader/src/emit/mod.rscovering 32-bit and 64-bit inputs, inline-1, high-dword hits, andSCCupdates.dxil.dlland executed on D3D12 (NVIDIA GeForce RTX 5060 Ti).cargo fmt -p victory-shader -- --check: passed.cargo clippy -p victory-shader --all-targets -- -D warnings: passed (0 warnings).cargo xtask policy: passed (asset policy: 151 files ok).cargo test -p victory-shader: 70 passed, 0 failed.6638098cee01b43e3@DaviTostes on GitHub · 2026-11-24 01:18 UTC · original
Tested
60e32ceon Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 57 passed, 0 failed (2 test binaries), including the 1 test this PR adds.victory-gpuE0425.No game data used.
@Sunkiller-qc on GitHub · 2026-11-24 01:29 UTC · original
This duplicates #148 (opened earlier, which also adds
s_flbit_i32_b64/_i64), and #163 covers the same opcodes too. The lowering here looks correct, and the GPU test is a plus. It might be worth agreeing with #148's author on which one goes in, e.g. #148's lowering plus this test.Static review, not built or run.
@Lyrnc on GitHub · 2026-11-24 06:22 UTC · original
RDNA2 hardware check of the four instructions: all match.
Setup. AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. Hand-written instructions in a HIP kernel (assembled by the AMD driver's amd_comgr). RDNA2 desktop silicon, not the console's. No game data. 130 cases: low dwords from edge values (including
0and0xffffffff) and random, high dwords0,0xffffffffor random. SCC was read right after each instruction.s_bcnt0_i32_b32/_b64: clear-bit count, SCC = result != 0: 130/130 each.s_ff0_i32_b32/_b64: lowest clear bit,-1when all bits are 1, SCC unchanged: 130/130 each.(#148 covers the same four plus
s_flbit_i32_b64/_i64, also matching.)AI use: Claude Code (Claude Opus 5.5) wrote the probes, ran them on the GPU above and drafted this comment; the numbers come from the hardware run.
@DeerSilver on GitHub · 2026-11-24 10:51 UTC · original
Tested head
50d8a98merged ontomainffe310eon NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only.Merged onto current
main, the test build fails.6638098("per-lane descriptors chosen by control flow", merged with #566 at 09:53) added a fourth argument toresource::track:There's no text conflict, so GitHub still shows the PR as mergeable, but merging it as it is would break
cargo testonmain. The call this PR adds needs the fourth argument.main's own tests passSome(&st);Nonekeeps the old three-argument behaviour.With
, Noneadded locally to that one call, everything passes:scalar_bitcount_and_first_zero_execute_on_gpucargo test --workspace --locked: 343 passed, 0 failed, 6 ignored, against 342 passed / 6 ignored onmain.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.AI-assisted (Claude Code).
@alexdeliu on GitHub · 2026-11-24 17:23 UTC · original
Merged onto
main@ffe310eb, this PR (50d8a98c) no longer compiles its tests.crates/victory-shader/src/emit/mod.rs:824callsresource::trackwith 3 arguments. Since6638098cit takes a 4th,lanes: Option<&Structured>; main's tests passSome(&st)withlet st = structure::structure(&p).unwrap();.Checked with CI's steps (both clippy runs with
-D warnings,cargo test --workspace) on Windows 11, AMD RX 9070. Every open PR: https://gist.github.com/alexdeliu/ef9ef0ebc1776ff104b5aa8eaea18e87@n-romanovich on GitHub · 2026-11-24 17:53 UTC · original
Thanks for testing and pointing this out, @alexdeliu!
Merged latest main and updated resource::track in the test to pass Some(&st) per
6638098c. Verified with cargo clippy --all-targets --locked -- -D warnings and re-ran the GPU test — both compile cleanly and pass with 0 warnings.@alexdeliu on GitHub · 2026-11-24 17:55 UTC · original
@n-romanovich rechecked
cee01b43merged ontomain@ffe310ebon the RX 9070: both CI clippy runs are clean andcargo test --workspacepasses (343 tests).@Marvisak on GitHub · 2026-11-25 00:00 UTC · original
Automated triage for the maintainers. Closing because another open pull request covers the same change.
See #148. s_bcnt0/s_ff0 (b32 and b64) lowering equal in effect to #148's, which also covers s_flbit_i32_b64/_i64. Its GPU test builds HostShader with the old field set and does not compile on main.
If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed