Shaders: expand 64-bit inline constants as signed ints and binary64 floats #1577
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!1577
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1577"
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?
@mgunes1311-lab on GitHub · 2026-11-24 19:24 UTC · original
mgunes1311-lab:shader-inline64-constants→main· +337 −42 · 4 files · 12 commits · openSummary
On GFX10 (RDNA2), inline constant operands (
128..=208and240..=248) expand to 64 bits according to operand width rather than zero- or sign-extending their 32-bitf32patterns: integer inline constants (0..=64,-1..=-16) sign-extend to 64 bits, while the nine floating-point inline constants (0.5,-0.5,1.0,-1.0,2.0,-2.0,4.0,-4.0,1/(2*pi)) expand to their IEEE-754 binary64 bit patterns (0x3fe00000_00000000through0x3fc45f30_6dc9c882). LLVM's AMDGPU backend encodes any matching 64-bit integer, bitmask, or descriptor constant with these inline codes (getInlineImmVal64) to save a literal word.Previously:
Lower::sop's 64-bithalfhelper readOperand::Const(240..=248)as a 32-bitf32in the low dword and sign-extended its sign bit into the high dword (for example turning-1.0into0xffffffff_bf800000instead of0xbff00000_00000000, and1.0into0x00000000_3f800000instead of0x3ff00000_00000000).Lower::src64only matchedOperand::Const(128..=208), letting240..=248fall through to zero-extended 32-bitf32values in 64-bit vector shifts and comparisons (v_lshlrev_b64,v_lshrrev_b64,v_ashrrev_i64,v_cmp_*_{u64,i64}).structure::Lanes::operandrejectedOperand::Const(240..=248)on both wave32 and wave64 scalar mask instructions (such as2.0for lane 30 / lane 62 or-2.0for the top two lanes), degrading constant lane masks intoAtom::Opaque.resourcecopy/select propagation (copy_sourcefors_mov_b64andTracer::pickedfors_cselect_b64/s_cmov_b64) only followed128..=208, missing constant sampler/descriptor words materialized with 64-bit inline floats (such ass_mov_b64 s[lo:hi], 2.0for[0, 0x40000000]).Changes
resource::inline64(code: u8) -> Option<u64>alongsideresource::inlineand use it incopy_source(s_mov_b64) andTracer::picked(s_cselect_b64,s_cmov_b64).Operand::Constinstructure::Lanes::operandviainline64in wave64 andinlinein wave32 so inline-float constant lane masks becomeAtom::Constant.resource::inline64inLower::sop(half, before the 32-bith == 0fallback) andLower::src64so all 64-bit scalar and vector consumers see exact RDNA2 64-bit inline constants without requiringINT64on 32-bit-pair scalar ops.resourceandstructureplus end-to-end DXIL-validated hardware GPU and WARP compute execution tests inemit::valu_testscovering128..=208and all nine240..=248constants across 64-bit scalar and vector instructions.Verification
cargo test -p victory-shader --locked&--all-features(including hardware D3D12 SM 6.6 + WARP execution)cargo clippy --workspace --all-targets --locked -- -D warnings&--all-featuresRUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --lockedcargo run -p xtask --locked -- policy --staged@geiyiliyabumo on GitHub · 2026-11-24 19:36 UTC · original
Verified commit
30ccd23on Windows 11 / AMD Radeon RX 9060 XT (RDNA4,gfx1200, SM 6.6) + WARP:cargo test -p victory-shader --lib: 125 passed, 0 failed, 1 ignored (including the new 64-bit inline constant GPU tests).AI-assisted; synthetic tests only, no game files.
@Marvisak on GitHub · 2026-11-25 01:31 UTC · original · edited 2026-11-25 22:26 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main:mainhas moved since the last triage, and the branch now conflicts incrates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
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.