Shaders: lower s_bitset{0,1}_b64, s_brev_b64 and s_bitreplicate_b64_b32 #166
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/166"
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 Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-24T01:02:48Z.
Implements DXIL lowering for four 64-bit scalar bit-manipulation instructions in
victory-shaderusing pure 32-bit DXIL operations (noINT64capability required):s_bitset0_b64,s_bitset1_b64: reads both dwords of the 64-bit destination, selects the low/high dword mask viasrc0 & 32, and clears or sets bitsrc0 & 31without modifyingSCC.s_brev_b64: swaps and bit-reverses the low and high dwords via DXILunary.i32(30).s_bitreplicate_b64_b32: interleaves the low and high 16-bit halves ofsrc0into duplicated bit pairs across the 64-bit destination.Testing
emit::tests::scalar_bitops_b64_execute_on_gpuincrates/victory-shader/src/emit/mod.rscovering bit set/clear across both dwords, 64-bit bit reversal, and 32-to-64 bit replication.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.Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:19:30Z.
Tested
04acee2on 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.
Imported from Marvisak/VIctory. Originally posted by Lyrnc on 2026-11-24T06:02:19Z.
RDNA2 hardware check of the four rules: all match.
AMD Radeon iGPU of a Ryzen 7 9800X3D, gfx1036 (RDNA2), AMD driver 32.0.21042.62, Windows 11 Pro 26200. A HIP kernel (assembled by the AMD driver's amd_comgr) runs each instruction on literal operands, then copies the SGPRs out. There are 24 cases: random 64-bit destinations, with src0 drawn from
0, 1, 31, 32, 33, 63, 64, 65, 0xffffffffand random values. SCC was set to 1 befores_bitset0/1_b64and read after. RDNA2 desktop silicon, not the console's. No game data.s_bitset0_b64/s_bitset1_b64: clear / set bitsrc0 & 63of the 64-bit destination (the dword picked bysrc0 & 32), SCC unchangeds_brev_b64: 64-bit bit reverse (dwords swapped and each reversed)s_bitreplicate_b64_b32: bitiof src0 to bits2iand2i+1src0 = 64and65behave as 0 and 1, so only bits 5:0 of src0 are read.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.
Imported from Marvisak/VIctory. Originally posted by DeerSilver on 2026-11-24T10:51:06Z.
Tested head
bd034c0merged 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_bitops_b64_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).
Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T17:23:06Z.
Merged onto
main@ffe310eb, this PR (bd034c0f) no longer compiles its tests.crates/victory-shader/src/emit/mod.rs:818callsresource::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/ef9ef0ebc1776ff104b5aa8eaea18e87Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-24T17:53:40Z.
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.Imported from Marvisak/VIctory. Originally posted by alexdeliu on 2026-11-24T17:56:01Z.
@n-romanovich rechecked
b81071c2merged ontomain@ffe310ebon the RX 9070: both CI clippy runs are clean andcargo test --workspacepasses (343 tests).upstream-sync referenced this pull request2026-11-25 01:07:42 +00:00
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:27:52Z.
Automated triage for the maintainers.
Recommended for a maintainer's look. The verdict hasn't changed. The new head is a single commit rebased onto current
main(940d32f). The lowering ofs_bitset0_b64/s_bitset1_b64,s_brev_b64(twobfrevs with the dwords swapped) ands_bitreplicate_b64_b32in the wide scalar block ofcrates/victory-shader/src/emit/lower.rshasn't changed and still matches the RDNA2 ISA and Lyrnc's gfx1036 probe. I rechecked the expected values inscalar_bitops_b64_execute_on_gpuby hand. TheHostShaderandPartsliterals matchmain's fields, andresource::trackgets its fourth argument.CI: passing.
#1684 also lowers these four instructions. Whichever lands second should drop the overlap.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by n-romanovich on 2026-11-25T00:50:09Z.
@Marvisak, thanks for the review.
Rebased onto
mainas a single commit (634f6f2) and filled in the newHostShaderfields (root_uavs,memory,memory_writes,view_addresses,heap,heap_writes) inscalar_bitops_b64_execute_on_gpu(crates/victory-shader/src/emit/mod.rs).Re-ran
cargo test -p victory-shader --locked -- scalar_bitops_b64_execute_on_gpuon Windows 11 (NVIDIA GeForce RTX 5060 Ti):1 passed, 0 failed.Imported from Marvisak/VIctory. Originally posted by Calvix2k on 2026-11-25T02:39:42Z.
Verification on Windows 10 19045 (RX 7800 XT), your head
0e2e4a6plus the "skip the GPU suites a device cannot run" patch from #1991 (this host reports SM 6.5, so those probes would fail for an unrelated reason):cargo test -p victory-shader --lib— 248 passed, 0 failed, 3 ignored. The four instructions lower and their tests run; the GPU-valued paths skip here and run in CI.No objection from reading the diff: the 64-bit shifts and bit-replicate go through the existing
bin/unarypaths with the same predicates as the neighbouring arms, ands_bitset'sscccomes from the compared bit as the ISA says.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T01:11:22Z.
Code review and RTX 5090 + WARP + DXIL verification at head
0e2e4a6fc3bamerged ontomain(63bcca43c6a0):xtask):crates/victory-shader/src/emit/lower.rsreaches524,562bytes (+274B over the524,288-byte limit), causingcargo xtask policyto fail (exit=1). Extracting these 64-bit scalar bit-op helpers into a submodule underemit/lower/will clear the policy gate cleanly.lower.rs:3585-3679):s_bitset0_b64/s_bitset1_b64build the1u64 << (src & 63)mask viaa & 31/(a & 32) != 0, combine with the priorsdstread fromir.rs:759, and keepEXEC/lane-mask destinations rejected at line 3581.s_brev_b64swaps words with DXILBfRev(op 30);s_bitreplicate_b64_b32spreads both 16-bit halves cleanly; verified againstir.rs:1001-1036that none of the 4 ops touchSCC.dxil.dll10.0.26100.0,VICTORY_D3D12_DEBUG=1, Rust 1.98.1):cargo xtask policy: FAIL (lower.rs: 524562 bytes exceeds the 524288-byte limit)cargo clippy(default +--features diagnostics): 0 warningsemit::tests(18/18, includingscalar_bitops_b64_execute_on_gpu) andemit::semantics_tests(34/34, 1 ignored): passed on both RTX 5090 and WARP.Lowering and GPU execution are solid — just needs moving out of
lower.rsto satisfy the 512 KiB policy check.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-27T00:52:46Z.
Review: COMMENTED
Verified on Windows (RTX 5090 + WARP) against current
origin/main(63bcca43):cargo test -p victory-shader --lib scalar_bitops_b64_execute_on_gpupassed on RTX 5090 and underVICTORY_WARP=1cargo clippy -p victory-shader --all-targets -- -D warningspassed with 0 warningscargo xtask policyfails after merging onto currentorigin/main: Moving the new 64-bit scalar bit-op lowering helper into a submodule undercrates/victory-shader/src/emit/lower/will keeplower.rsunder the 512 KiB limit.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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.