Shaders: lower s_quadmask_b32 and s_quadmask_b64 #87
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/87"
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?
Imported from Zettrox/ztrx. Originally posted by Ingenioeren on 2026-11-25T09:45:09Z.
What
s_quadmask_b32ands_quadmask_b64were refused (lower: Unsupported { what: "s_quadmask_b32" }). Now they are lowered following the RDNA 2 ISA: bitiof the result is set when any of source bits4i..4i+3is set (8 result bits for b32, 16 for b64), the high dword of the b64 result is 0, and SCC is whether the result is nonzero.The lowering folds each nibble into its low bit and collects those bits into the low byte in 32-bit steps, so it does not need INT64.
Why
Upstream VIctory has lowered these since c3a04e2 ("Shaders: lower scalar quadmask instructions"). ztrx's history split off before that commit, so ztrx still refuses any program that uses them. This PR ports that lowering unchanged. Upstream added no test for it, so this PR also adds one.
How tested
I added a new synthetic test,
emit::valu_tests::s_quadmask_folds_each_quad_into_one_bit. It builds GFX10 code in the test and uses no game shaders. It checks the b32 result, the b64 low and high dwords, and SCC for both forms (read throughs_cselect_b32). Each check compares 10 inputs against a Rust reference, including 0, single bits at the dword edges, all ones, and bits spread across both dwords.cargo test --locked --offline -p victory-shader s_quadmask:lower: Unsupported { offset: 36, what: "s_quadmask_b32" };--nocapture).cargo test --locked --offline -p victory-shader: 209 passed, 2 failed. The two failures (emit::rect::tests::the_rectangle_stage_is_a_geometry_shaderandrectangles_are_drawn_whole) also fail onmainon this PC with its localdxil.dll, so they are unrelated.cargo clippy --locked --offline -p victory-shader --all-targets: no warnings.cargo run -p xtask -- policy --staged:asset policy: 2 files ok.cargo fmt --checkshows nothing for the lines this PR adds (the crate has other formatting differences onmain, which this PR leaves alone).Not tested: the test hardware was an AMD RX 6750 XT plus WARP, not an NVIDIA card. This is a code-level translation fix with no vendor-specific behaviour, but there was no NVIDIA run and no game run.
AI assistance: prepared with Claude Code, reviewed by Ingenioeren.
🤖 Generated with Claude Code
Imported from Zettrox/ztrx. Originally posted by hamdog0203 on 2026-11-25T11:51:39Z.
Independent verification on NVIDIA RTX 4060 (8 GB, Wave32, driver 621.35) + WARP + Windows SDK
dxil.dll(10.0.26100.0), Windows 11 x64 (26200.9974),rustc 1.98.1, audited at commit9f920fcbae7cb4a64fd9432730f8763a8a98723f:s_quadmask_b32ands_quadmask_b64incrates/victory-shader/src/emit/lower.rswith comprehensive synthetic tests invalu_tests.rscovering both dwords andSCC(nounsafe).cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)cargo test --locked -p victory-shader --lib s_quadmask -- --nocapture:s_quadmask_folds_each_quad_into_one_bitpassed on both RTX 4060 and WARP +dxil.dll(no skipped backends)cargo test --workspace --locked: the parallel workspace run hit the pre-existing WARP concurrencySTATUS_ACCESS_VIOLATION(0xc0000005) invictory_gpu; re-runningcargo test --workspace --locked -- --test-threads=1passed cleanly across all crates (victory_gpu: 110 passed, 1 ignored;victory_shader: 211 passed, 2 ignored;xtaskasset-policy: 4 passed)Verified on NVIDIA Wave32 hardware and WARP via the workspace suite and synthetic tests (no game run performed).
Imported from Zettrox/ztrx. Originally posted by Aniseto on 2026-11-25T14:49:19Z.
Ran the new quadmask test at
9f920fc(clean PR head onmain90b529f):System
rust-toolchain.toml), MSVC 14.44.35207, DXIL validator 1.9.2609.5 (VICTORY_DXIL), debug buildResults
cargo test --locked -p victory-shader --lib s_quadmask -- --nocapture: 1 passed, 0 failed, 0 ignored, 212 filtered out (exit 0). No skip line with--nocapture.cargo test --locked -p victory-shader --lib -- --test-threads=1: 211 passed, 0 failed, 2 ignored (exit 0). The two ignored are the benchmark and the strict-joins case; the rectangle tests pass here.What this adds
The PR says it was tested on an AMD RX 6750 XT plus WARP, with no NVIDIA run. The other report in the thread covers an RTX 4060 (Ampere). This adds a Blackwell wave32 part on driver 32.0.16.2124 with DXIL validator 1.9.2609.5;
s_quadmask_folds_each_quad_into_one_bitpasses on the real adapter here.Not tested
The title's shader pack, live pipeline creation, retail runs, the console compiler's DXC, release profile, RDNA2/RDNA4 and Intel GPUs.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.