Shaders: scratch with neither address names no register (GFX10.3 ST mode) #2763
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2765"
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 Moon0755 on 2026-11-25T20:01:27Z.
Found by comparing
gfx10/with LLVM's AMDGPU backend.Problem
On GFX10.3 a scratch access may have neither a VGPR nor an SGPR address (LLVM calls it ST mode; gfx1010 rejects the form). The SGPR field then holds 0x7F, the code of EXEC_HI. LLVM's
FLATInstructions.tdwrites that value for exactly this case, scratch without a VGPR address, and prints the operands asoff, off.gfx10/fields.rstreats every SGPR code other than 125 as an operand, so it builtexec_hifor it: the text wasscratch_load_dword v1, off, exec_hi, andir::buildrecorded a read of EXEC_HI.Fix
For the scratch encoding, 0x7F in the SGPR field is no operand; it is stored as the null register, which the text already prints as
offand the IR already skips. The VGPR address stays absent, as before. Global and flat are untouched.Test
gfx10::sp3::tests::scratch_without_an_address_names_no_register: four encodings from LLVM'sllvm/test/MC/AMDGPU/flat-scratch-st-mode.s(two loads, two stores) and the text LLVM gives for them, for example[0x00,0x40,0x30,0xdc,0x00,0x00,0x7f,0x01]isscratch_load_dword v1, off, off.Verification
GitHub Actions on
windows-latest, on the fork, with the jobs narrowed tovictory-shaderandxtask:271 passed; 0 failed; 3 ignored;exec_hiwhereoffis expected in all four.Not checked: whether a title program uses this form. The lowering does not translate scratch accesses, so today the effect is on the disassembly text and on the reads
ir::buildrecords.Notes
fields.rs, and the tests are in different places ofsp3.rs.— Fable
Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T20:03:55Z.
Correct per LLVM: saddr 0x7F on 10.3 scratch is the 'off, off' ST-mode form, not EXEC_HI - mapping it to NULL keeps both the printed operand list and the tracked reads honest. One scope question: global_* shares the same ST-mode encoding on GFX10.3 in LLVM's tables (global_load/store also print 'off, off' when saddr is 0x7F) - this fix is Scratch-only, so a global with no SGPR address still reads EXEC_HI. If title shaders ever emit that form it needs the same arm; fine to land as scratch-only if none do.
Imported from Marvisak/VIctory. Originally posted by Moon0755 on 2026-11-25T20:10:16Z.
Thanks for checking. On the scope question: I do not find a global ST form in LLVM.
FLAT_Real_gfx10writes the field asso 0x7F is written only for scratch without a VGPR address. A global access always has its VGPR address and takes the null register (0x7D) when there is no SGPR: in
flat-global.s,global_store_byte v[3:4], v1, offis[0x00,0x80,0x60,0xdc,0x03,0x01,0x7d,0x00], which the decoder already prints asoff. I found noglobal_* ... off, offin LLVM's MC tests (flat-scratch-st-mode.s,gfx10_asm_flat.s,flat-global.s,gfx1030_new.s). If you have an encoding where a global holds 0x7F, I will add the arm.— Fable
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-25T20:20:29Z.
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
AI-assisted (Hy4 flash).
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T20:38:06Z.
Reviewed and verified
0ffa453fon Windows 11 againstmain(13f91ca).Encoding::Scratchwithsaddr == 0x7F(GFX10.3 ST mode) toNULL(125) while keepingaddr = Noneensuressp3.rsprintsoff, offandir.rsstops recording a spuriousEXEC_HIread, without affectingGlobalorFlat.cargo test --locked -p victory-shader --lib --features host gfx10::: 17/17 passed (includingscratch_without_an_address_names_no_register);ir::: 9/9 passed.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok; cleangit merge-treevs13f91caand#2771.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T23:20:31Z.
Automated triage for the maintainers.
In
crates/victory-shader/src/gfx10/fields.rs(Instruction::fields, the FLAT/global/scratch arm), a scratch access whose SGPR field is 0x7F (GFX10.3 ST mode, no VGPR and no SGPR address) now stores the null register instead ofexec_hi, so the disassembly printsoff, offandir::buildno longer records an EXEC_HI read. I checked that the VGPR address was already absent in this case (it is only taken whensaddr == NULL), that global and flat are untouched, and that this matches LLVM'sFLAT_Real_gfx10encoding and itsflat-scratch-st-mode.stests; the test words decode to the expected scratch opcodes. CI (check) passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-26T00:49:47Z.
Review: APPROVED
Verified against
origin/main(63bcca4):cargo test -p victory-shader gfx10::sp3::tests: passed.cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 192 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-26T09:30:08Z.
NVIDIA full-suite run, to go with the reports above by cloph-dsp, fuzeofficlal, since none of them names a GPU run. Tested exact head
0ffa453(on its base13f91ca).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 774 passed, 0 failed, 9 ignored.scratch_without_an_address_names_no_register.--skipleaves out tests that fail on main63bcca4on this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T12:26:20Z.
Review: APPROVED
Reviewed and verified
0ffa453fagainstorigin/main(63bcca43; cleangit merge-tree, and verified clean orthogonal three-way merge with #2761):Encoding::Scratchwithsaddr == 0x7FtoNULLwhile leavingaddr = None(crates/victory-shader/src/gfx10/fields.rs:398-423) matches LLVM's GFX10.3 ST-mode encodings (flat-scratch-st-mode.s) byte for byte across all four vectors (sp3.rs:868-886), without disturbingGlobal,Flat, or 12-bit signed byte offsets.ir.rs, skippingNULLeliminates the spuriousEXEC_HIscalar address read while preserving implicitEXEC, andemit/lower.rs:3519-3561continues to reject scratch ops through the side-effectfulUnsupported("flat memory")path.Local checks on
0ffa453f:rustfmt --edition 2024 --check,xtask policy(184 files ok),cargo clippy -p victory-shader --all-targets -- -D warnings(default &--all-features),gfx10::(17 passed),ir::(9 passed), andemit::lower::tests(27 passed) all pass.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.