shader: lower s_bitcmp{0,1}_b{32,64} and s_sext_i32_i{8,16} #142
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!142
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/142/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 00:56 UTC · original
n-romanovich:feat/scalar-bitcmp-sext→main· +144 −0 · 2 files · 3 commits · closed without mergingImplements DXIL lowering for six scalar ALU instructions in
victory-shader:s_bitcmp0_b32,s_bitcmp1_b32: extracts bitsrc1 & 31fromsrc0and writesSCC(== 0/!= 0).s_bitcmp0_b64,s_bitcmp1_b64: selects the low or high 32-bit dword viasrc1 & 32(without requiring DXILINT64), extracts bitsrc1 & 31, and writesSCC.s_sext_i32_i8,s_sext_i32_i16: sign-extends the low 8 or 16 bits ofsrc0toi32viashl+ashr(24/16) without modifyingSCC.Testing
emit::tests::scalar_bitcmp_and_sext_execute_on_gpuincrates/victory-shader/src/emit/mod.rs, covering all six opcodes (bit index masking, high-dwordb64bits, inline-1sign extension, positive/negativesext, andSCCpreservation).dxil.dlland executed the compute shader on D3D12 (NVIDIA GeForce RTX 5060 Ti).cargo test -p victory-shader: 58 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: passed with 0 warnings.cargo xtask policy: passed (asset policy: 150 files ok).cargo test --workspace: all active tests passed (3 tests invictory-formatsignored without external reference files).663809826bdec9478@DaviTostes on GitHub · 2026-11-24 01:05 UTC · original
Tested
4293c7don Arch Linux x86_64, rustc 1.98.1: pass.cargo test -p victory-shader: 57 passed, 0 failed (2 test binaries), including the test this PR adds.s_bitcmp0/1_b32ands_bitcmp0/1_b64) and #120 (s_absdiff_i32,s_sext_i32_i8/i16,s_pack_ll/lh/hh_b32) also lower, and both are open. Three PRs are touching overlapping instruction sets; worth converging on one.victory-gpuE0425.No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
@Sunkiller-qc on GitHub · 2026-11-24 01:05 UTC · original
This overlaps two open PRs by tedin7: #117 adds
s_bitcmp0/1_b32/b64(lower.rs:2306there), and #120 addss_sext_i32_i8/i16(lower.rs:2647there) together withs_absdiffands_pack_*. Both implementations here look correct (lower.rs:2360and:2523). Sincewrites_sccinir.rsalready leaves sext out, the extra entry in the no-SCC list isn't needed. If more than one of these lands, though, the later match arms become unreachable patterns.A possible split:
s_bitcmpfrom this PR or #117 (this one has the GPU-run test), ands_sextonly from #120. Up to the maintainer which one; just flagging it so the work isn't merged twice.Static review, not built or run.
@Lyrnc on GitHub · 2026-11-24 06:22 UTC · original
RDNA2 hardware check of the six 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: sources from edge values (
0, 1, 0x80, 0xff, 0x8000, 0xffff, 0x80000000, 0xffffffff, …) and random, random high dwords for the 64-bit forms, bit indices0, 1, 7, 31, 32, 33, 63, 64, 0xffffffffand random. SCC was read withs_cselectright after each instruction.s_bitcmp0/1_b32: SCC = bitsrc1 & 31clear / set: 130/130 each.s_bitcmp0/1_b64: SCC = bitsrc1 & 63of the pair (dword chosen bysrc1 & 32): 130/130 each.s_sext_i32_i8,s_sext_i32_i16: sign extension, SCC left as it was (checked from both SCC = 1 and SCC = 0): 130/130 each.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.
@n-romanovich on GitHub · 2026-11-24 08:46 UTC · original
Thanks for the review! Addressed the feedback and resolved the compilation issue in the latest commit. All tests pass cleanly.
@DeerSilver on GitHub · 2026-11-24 10:51 UTC · original
Tested head
badfee5merged 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_bitcmp_and_sext_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:22 UTC · original
Merged onto
main@ffe310eb, this PR (badfee5c) no longer compiles its tests.crates/victory-shader/src/emit/mod.rs:826callsresource::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:54 UTC · original
Thanks for the catch, @alexdeliu!
Merged latest main, dropped the duplicate s_bitcmp matching arm (now present via #117), and updated resource::track in the test to pass Some(&st) per
6638098c. Verified with Clippy (-D warnings) and tests on hardware — all pass cleanly.@alexdeliu on GitHub · 2026-11-24 17:55 UTC · original
@n-romanovich rechecked
26bdec94merged 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 #120. s_bitcmp0/1_b32/_b64 are already lowered in main (lower.rs sop(), strip_prefix("s_bitcmp")); the only new lowering, s_sext_i32_i8/i16, is identical to #120's, which covers more. 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