Shaders: lower s_bitset{0,1}_b64, s_brev_b64 and s_bitreplicate_b64_b32 #166
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!166
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@n-romanovich on GitHub · 2026-11-24 01:02 UTC · original
n-romanovich:feat/scalar-bitops-b64→main· +227 −1 · 2 files · 1 commits · openImplements 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.@DaviTostes on GitHub · 2026-11-24 01:19 UTC · original
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.
@Lyrnc on GitHub · 2026-11-24 06:02 UTC · original
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.
@DeerSilver on GitHub · 2026-11-24 10:51 UTC · original
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).
@alexdeliu on GitHub · 2026-11-24 17:23 UTC · original
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/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:56 UTC · original
@n-romanovich rechecked
b81071c2merged ontomain@ffe310ebon the RX 9070: both CI clippy runs are clean andcargo test --workspacepasses (343 tests).@Marvisak on GitHub · 2026-11-25 00:27 UTC · original · edited 2026-11-25 02:30 UTC
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
@n-romanovich on GitHub · 2026-11-25 00:50 UTC · original
@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.@Calvix2k on GitHub · 2026-11-25 02:39 UTC · original
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.@fuzeofficlal on GitHub · 2026-11-26 01:11 UTC · original
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.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.