Translate scalar zero-bit counts #3566
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3566
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3566"
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?
@xiepeixuan on GitHub · 2026-11-30 01:09 UTC · original
xiepeixuan:auto/shader-scalar-zero-count→main· +72 −3 · 3 files · 2 commits · closed without mergingRefs #1138 (overlap map) and #3389 (a separate scalar-opcode fix). No issue is claimed as fixed.
What it changes
AMD RDNA 2 ISA §12.3, opcodes 13 and 14, gives the same rule over 32 and 64 source bits: “D += (S0[i] == 0 ? 1 : 0)”; “SCC = (D != 0).”
The decoder and SSA already handle these instructions, but a live result is refused by the emitter. Reuse the existing DXIL Countbits lowering, which counts ones, and subtract from the source width. The 64-bit form counts both dwords and adds the counts before subtracting. Both forms set SCC from the resulting zero-bit count.
Uses audit: decoding, operand widths, SSA effects and folded-wave rewriting are unchanged; the existing split of a 64-bit count now has a working 32-bit lowering. The already-supported ones counts and first-set-bit op still emit the same instructions. BCNT1-specific lane-mask paths are not widened by this change. The translator source fingerprint covers this change; no cache-key policy or settings change. Cost before optimisation: one Countbits plus one subtraction for a 32-bit source; two Countbits, one add and one subtraction for a 64-bit source; one nonzero comparison for live SCC. No new branch or 64-bit DXIL integer capability. No production code was ported. The portable test scaffolding follows xiepeixuan's #3389.
Expected effect on NVIDIA
Tier A: shader refusal. A shader with a live scalar zero-bit count (for example, when handling a packed mask or using SCC to choose a path) now lowers. A draw or dispatch using that shader can otherwise be dropped, including on NVIDIA hosts. The refusal and repair are confirmed in a standalone synthetic shader; no specific game scene or frequency was measured.
How it was tested
s_addc_u32makes SCC observable.scalar_zero_bit_counts_update_sccon main41adb55167faplus the test alone failed withWave32: Unsupported { offset: 40, what: "s_bcnt0_i32_b32" }(cargo exit 101). Unmodified Linux crate suite: 295 passed, 0 failed, 2 ignored. Baseline CI.58a5d021b22e119698e941ff5c7524221828c031. Linux crate suite: 296 passed, 0 failed, 2 ignored. Linux CI.cargo check --workspace --locked: exit 0 on both pristine main and the exact fix. Unfiltered crate: 457 → 458 passed, 5 failed, 9 ignored, with the same failing test names. After excluding only the baseline failures: 458 passed, 0 failed, 9 ignored. Both strict Clippy modes have the same pre-existing errors. Windows comparison.cargo testpassed for the changed crate: yes on Linux and on Windows after excluding only the confirmed baseline failures. Production-only rollback in a separate checkout restored the original file hash and the original exit-101 failure. Rollback CI.Checked for overlap
AI-assisted (Codex). Not run in the game.
@trustno1-coder on GitHub · 2026-12-01 18:51 UTC · original
Closing this as part of moving main to the texture and video-memory rework (v2026.12.01.01-test). A lot of the code changed, and this pull request no longer applies cleanly to it; it would need to be rewritten against the new main rather than rebased. Thank you for the work. If the change is still needed, please open a new pull request based on the current main.
Pull request closed