Shaders: GFX10 FLAT offsets ignore bit 11 #1635
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1636"
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 davutsimsekk on 2026-11-24T20:13:55Z.
GFX10 FLAT offsets are 11-bit and unsigned; the hardware ignores bit 11, unlike GLOBAL/SCRATCH which use a 12-bit signed offset. The decoder already masked with
0x7FF, but nothing said why and nothing pinned it.This adds the comment and a regression test:
flat_load_dword v0, v[1:2]with0xDC30_0800decodes as offset 0, and0xDC30_0FFFas 0x7FF. No behaviour change.Test
flat_offsets_ignore_bit_eleveningfx10::tests.cargo test -p victory-shader --lib: 121 passed, 0 failed, 1 ignoredcargo clippy -p victory-shader --all-targets --locked -- -D warnings: cleanrustfmt --edition 2024 --checkon both changed files: cleanImported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T20:26:25Z.
Review: APPROVED
Verified locally merged onto
origin/main(Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib gfx10::— 13 passed, 0 failed (includingflat_offsets_use_all_twelve_bits)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— okClean 12-bit FLAT offset mask fix with targeted regression test. Looks good.
AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by TinkerBell-90 on 2026-11-24T20:27:26Z.
Review: COMMENTED
Tested
ba2c202against its baseffe310eon Linux x86-64 with Rust 1.98.1 (native target for the tests; clippy also run forx86_64-pc-windows-msvc).I think the old mask is the intended one. On GFX10 the FLAT segment offset is 11 bits, unsigned, and the hardware ignores bit 11. Only GLOBAL and SCRATCH use all twelve bits, signed:
AMDGPUAsmParser::validateFlatOffset: "For pre-GFX12 FLAT instructions the offset must be positive; MSB is ignored and forced to zero."AMDGPUAsmGFX1030.rst) givesflat_load_dwordanoffset11(0..2047), andglobal_load_dword/scratch_load_dwordanoffset12s.llvm-mc -triple=amdgcn -mcpu=gfx1030refusesflat_load_dword v0, v[1:2] offset:2048(also 4095 and -1) with "expected a 11-bit unsigned offset", and assemblesglobal_load_dword v0, v[1:2], off offset:-2048.LLVM's disassembler prints the raw field (
offset:2048for0xDC300800), so a disassembler round trip does not settle it; the assembler rule does. So0xDC30_0800is a flat load at offset 0 on the GPU, which is whatmaindecodes. With this change it decodes as 2048.cargo test -p victory-shader --lib --locked:ffe310eba2c202flat_offsets_use_all_twelve_bitsfails: left 0, right 2048flat_load_dword v0, v[1:2]andflat_load_dword v0, v[1:2] inst_offset:2047inst_offset:2048andinst_offset:4095(
offsetis the closure from this PR's test.)cargo clippy -p victory-shader --all-targets --locked --target x86_64-pc-windows-msvc -- -D warningsis clean, and both changed files passrustfmt --edition 2024 --check.The reach on
mainis small:flat_*is not lowered (Err("flat memory")inemit/lower.rs), and the address tracking inresource.rsonly takesglobal_*, whose arm this PR does not change. Today only the SP3 text of theshader-info --disasmlisting changes. It would matter once flat segment loads are lowered.Suggestion: keep
0x7FF, add a one-line comment that bit 11 is ignored for the FLAT segment, and turn the test around as above. I could not get AMD's RDNA2 ISA guide from here to quote it, so the LLVM sources are my reference.AI-assisted.
Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T20:46:54Z.
Verified head
ba2c202merged cleanly ontomain(ffe310e) on Windows 11 / AMD Radeon RX 9060 XT (RDNA4,gfx1200) + WARP / Rust 1.98.1 MSVC:cargo test -p victory-shader --lib: 121 passed, 0 failed, 1 ignored (new FLAT 12-bit offset test + full GPU/WARP shader suite pass).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.AI-assisted; synthetic tests only, no game files.
[PR #1636] Shaders: FLAT offsets keep all twelve bitsto [PR #1636] Shaders: GFX10 FLAT offsets ignore bit 11Imported from Marvisak/VIctory. Originally posted by davutsimsekk on 2026-11-24T21:12:46Z.
Thanks, you're right. I kept \
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:42:49Z.
Review: APPROVED
Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (
ffe310e), cargo test -p victory-shader --locked → 97 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows.GFX10 FLAT offsets ignore bit 11 (the GFX10 flat-address quirk): flat_offsets_ignore_bit_eleven unit test. +1 macOS test.