Shaders: the operand of a GWS instruction is read from the address field #2761
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!2761
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2761"
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 19:54 UTC · original
Moon0755:fix/ds-gws-operand→main· +27 −1 · 2 files · 1 commits · openFound by comparing
gfx10/with LLVM's AMDGPU backend.Problem
ds_gws_init,ds_gws_sema_brandds_gws_barrierhave one operand, and it is encoded in bits 39-32, where other DS instructions have their address. LLVM'sDSInstructions.tdmarks the three withhas_gws_data0("data0 is encoded as addr") and writesgfx10/fields.rsread the operand from the first data field, bits 47-40. So the decoder namedv0whatever register the instruction held, andir::buildrecorded a read of the wrong register.Fix
For
ds_gws*the data operand is taken from bits 39-32. One line; the three GWS instructions without an operand are unaffected (they have no data).Test
gfx10::sp3::tests::gws_operands_are_in_the_address_field: four encodings from LLVM'sllvm/test/MC/AMDGPU/gfx10_asm_ds.sand the text LLVM gives for them, for example[0x34,0x12,0x76,0xd8,0xff,0x00,0x00,0x00]isds_gws_barrier v255 offset:4660 gds.Verification
GitHub Actions on
windows-latest, on the fork, with the jobs narrowed tovictory-shaderandxtask:271 passed; 0 failed; 3 ignored;ds_gws_barrier v0 offset:4660 gdswherev255is expected.Not checked: whether a title program uses these instructions. The lowering does not translate them, so today the effect is on the disassembly text and on the reads
ir::buildrecords.— Fable
`ds_gws_init`, `ds_gws_sema_br` and `ds_gws_barrier` have one operand, and it is encoded where other DS instructions have their address (LLVM: "data0 is encoded as addr", `Inst{39-32}`). The decoder read it from the first data field, bits 47-40, so it named v0 whatever the instruction held, and the IR read the wrong register. Test: `gws_operands_are_in_the_address_field`, encodings from LLVM's gfx10_asm_ds.s. Co-Authored-By: Claude Fable 5.2 <[email protected]>@kotekompotek on GitHub · 2026-11-25 20:03 UTC · original
Verified against the DS encoding: ds_gws_* has no_addr already, so the single operand in bits 0-7 of w1 (the addr field) was previously dropped entirely - data[0] read bits 8-15 and got zero. Starting the data fields at bit 0 for ds_gws puts the operand back as a real read. Test encodings match LLVM's gfx10_asm_ds.s.
@fuzeofficlal on GitHub · 2026-11-25 20:04 UTC · original
Reviewed and verified
1a2ca3d9on Windows 11 againstmain(13f91ca).Code review
ds_gws_*encodings inopcodes.rs:838-843against the GFX10 DS encoding (ADDR=w1[7:0],DATA0=w1[15:8]):ds_gws_sema_release_all,ds_gws_sema_v,ds_gws_sema_p) havedata = 0and are unaffected.ds_gws_init,ds_gws_sema_br,ds_gws_barrier) encode their operand inADDR(w1[7:0]), whereas otherno_addr = trueops withdata = 1(ds_write_addtid_b32) still encode inDATA0(w1[15:8]). Settingfirst = if name.starts_with("ds_gws") { 0 } else { 8 }infields.rs:322matches both, and feeds cleanly into bothsp3.rsdisassembly andir.rsread-register /M0dependency tracking.Verification (Windows 11,
rustc 1.98.1MSVC)cargo test --locked -p victory-shader --lib --features host gfx10: 17 passed, 0 failed (includinggws_operands_are_in_the_address_field).cargo test --locked -p victory-shader --lib --features host "ir::": 9 passed, 0 failed.cargo clippy --locked -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings;cargo xtask policy: 184 files ok; cleangit merge-treeagainst13f91ca.@cloph-dsp on GitHub · 2026-11-25 20:07 UTC · original
Independent local verification (AI-assisted, Hy4 flash): Windows / rustc+cargo 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup. Checked out pull/2761/head at
1a2ca3d. \CARGO_BUILD_JOBS=2 cargo test --locked -p victory-shader --lib gws_operands_are_in_the_address_field --quiet\ -> 1 passed; ... gfx10::sp3::tests --quiet\ -> 9 passed, 0 failed. \git diff --check origin/main..HEAD\ clean. Negative control: the new test name is absent from origin/main. Encodings are synthetic LLVM MC test vectors, not game-derived. No blocking findings; did not run the full victory-shader lib because a pre-existing crash in emit::memory_tests reproduces on unmodified main here.@oni-swr on GitHub · 2026-11-25 20:16 UTC · original
Independent WARP/CPU verification: PR head
1a2ca3dEnvironment: Windows 11, rustc/cargo 1.98.1, debug build,
VICTORY_WARP=1 VICTORY_D3D12_WARP=1(Microsoft WARP only, no physical GPU), Windows SDK 10.0.26100.0dxil.dll1.8.2502.11 onPATH. Tested the PR head itself (single commit directly onorigin/main13f91caee2, so identical to the merge tree). All commandscargo ... --locked.Baseline on origin/main:
test -p victory-shader --lib --features host(andhost,diagnostics, and with default features): 267 passed, 3 failed, 3 ignored. The 3 pre-existing failures are WARP-only:emit::synthetic_tests::{a_mask_joined_with_data_at_a_uniform_loop_is_its_number, permutes_read_the_lane_named_and_zero_from_lanes_left_out}(hardware: no pipeline for a wave of 32) andgathers_at_a_level_match_the_hardware(lane mismatch). clippy--all-targets --features host,diagnostics -D warnings: clean.On this PR:
test -p victory-shader --lib --features host: 268 passed, 3 failed, 3 ignored.--features host,diagnostics: the same. The 3 failures are exactly the baseline ones. +1 new test, passing.clippy --locked -p victory-shader --all-targets --features host,diagnostics -- -D warnings: clean.gfx10/fields.rsfrom origin/main:gfx10::sp3::tests::gws_operands_are_in_the_address_fieldfails (ds_gws_* v0wherev255expected), then restored the PR file.Review: for
ds_gws_init,ds_gws_sema_brandds_gws_barrierthe data0 operand is read from the address byte (bits 7:0 of the second word) instead of bits 15:8. The otherds_gws_*ops have zero data operands, so the shift base does not affect them. I hand-decoded the four test words against the opcode table (0x19, 0x1b, 0x1d, gds bit): they match.ir.rs:890only matchesds_gwsby name. No issues found.Not tested: a physical GPU, any retail title or game behavior, a release build, non-Windows targets.
AI disclosure: this verification was run by Claude Code (Claude Sonnet 5.5). No game files, dumps, shader names or retail hashes were used.
@Marvisak on GitHub · 2026-11-25 23:19 UTC · original
Automated triage for the maintainers.
This makes the DS decoder in
crates/victory-shader/src/gfx10/fields.rs(Instruction::fields,Encoding::Dsarm) read the single operand ofds_gws_init,ds_gws_sema_brandds_gws_barrierfrom bits 7:0 of the second dword instead of bits 15:8, matching LLVM'shas_gws_data0encoding. I checked that allds_gws*ops are alreadyno_addr, that the three operand-less GWS ops havedata = 0and are unaffected, and that the test words decode to the expected opcodes (0x19/0x1b/0x1d) with the gds bit set;ir.rsnow records a read of the right VGPR. CI (check) passes.This is a recommendation for a maintainer to look, not an approval.
Generated by Claude Code
@Dukestar69 on GitHub · 2026-11-26 04:09 UTC · original · approved these changes
Tested merged onto
origin/main(63bcca4) on Windows 11 x64:cargo test -p victory-shader --lib gfx10::sp3::tests: 9 passed, 0 failed (including newgws_operands_are_in_the_address_field).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
@futurepro62 on GitHub · 2026-11-26 09:22 UTC · original
NVIDIA full-suite run, to go with the reports above by Dukestar69, cloph-dsp, fuzeofficlal, oni-swr, since none of them names a GPU run. Tested exact head
1a2ca3d(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.gws_operands_are_in_the_address_field.--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
1a2ca3d9againstorigin/main(63bcca43; cleangit merge-tree, and verified clean orthogonal three-way merge with #2765):data[0]from the physical ADDR byte (w1[7:0]) whenname.starts_with("ds_gws")(crates/victory-shader/src/gfx10/fields.rs:319-326) matches LLVM'sgfx10_asm_ds.sencodings byte for byte across all four vectors (sp3.rs:911-931), leaves the three operand-lessds_gws_*ops (data = 0) andds_write_addtid_b32(w1[15:8]) intact, restores accurate VGPR dependency tracking inir.rs:886-905alongsideM0/implicitEXEC, and keeps the side-effectfulUnsupported("GDS")refusal inemit/lower.rs:3166-3184, 3519-3556.Local checks on
1a2ca3d9: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.