Shaders: scratch with neither address names no register (GFX10.3 ST mode) #2765
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!2765
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@Moon0755 on GitHub · 2026-11-25 20:01 UTC · original
Moon0755:fix/scratch-st-mode→main· +29 −2 · 2 files · 1 commits · openFound 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
@kotekompotek on GitHub · 2026-11-25 20:03 UTC · original
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.
@Moon0755 on GitHub · 2026-11-25 20:10 UTC · original
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
@cloph-dsp on GitHub · 2026-11-25 20:20 UTC · original
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
AI-assisted (Hy4 flash).
@fuzeofficlal on GitHub · 2026-11-25 20:38 UTC · original
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.@Marvisak on GitHub · 2026-11-25 23:20 UTC · original
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
@DenRakEiw on GitHub · 2026-11-26 00:49 UTC · original · approved these changes
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).
@futurepro62 on GitHub · 2026-11-26 09:30 UTC · original
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
@fuzeofficlal on GitHub · 2026-11-26 12:26 UTC · original · approved these changes
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.