Shaders: split 16-bit raw buffer stores across dword boundaries #3576
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!3576
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3576"
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-27 18:58 UTC · original
Moon0755:fix/buffer-short-store-straddle→main· +102 −12 · 2 files · 1 commits · openOn RDNA2,
buffer_store_shortstores the low 16 bits byte-addressably across dword boundaries: at byte offset3 mod 4, the low byte lands in byte3of the current dword and the high byte lands in byte0of the next dword (at_base + 4). Onmain,Lower::bufferonly wrote the enclosing dword (// shortcut: the field is taken not to cross a dword.), silently dropping the high byte.Changes
crates/victory-shader/src/emit/lower.rs(Lower::buffer,521,778bytes /+1,215vsmain,2,510bytes below the524,288limit):write_fieldclear/set atomic helper across both writes; forwidth == 16atbyte == 3, write byte0ofat_base + 4guarded byno_wrap = IUGT(at_base + 4, at_base)so an out-of-bounds offset atu32::MAXcannot wrap back to dword0.#2208(CAS loop) — happy to rebase once#2208lands.crates/victory-shader/src/emit/valu_tests.rs:short_store_at_byte_three_writes_both_dwordsandshort_store_at_u32_max_does_not_wrap_to_dword_zero(encodings verified withllvm-mc -triple=amdgcn -mcpu=gfx1013 -disassemble, LLVM23.1.5).Verification
main): https://github.com/Moon0755/VIctory/actions/runs/46052583913 (failure— 303 passed, 1 failed solely onshort_store_at_byte_three_writes_both_dwords)gemini/ci-buffer-short-store-straddle,813c866): https://github.com/Moon0755/VIctory/actions/runs/46052578194 (success— full workspace CI + both Clippy builds clean)813c866):short_store_at_(2/2, hardware + WARP), both Clippy configs, andcargo xtask policy(191 files ok) clean.idxen) byte/half stores, all-or-nothing OOB when a 16-bit store starts atview_size - 1, interaction with CAS-loop#2208,dxil.dll1.7, game files. Synthetic tests only (AI-assisted).— Devin & Neon
@oni-swr on GitHub · 2026-11-27 19:29 UTC · original
Verification of #3576 (head
813c866365), independent, WARP only.Environment: Windows 11 Pro 10.0.26200, WARP d3d10warp.dll 10.0.26100.9818 (VICTORY_WARP=1 and VICTORY_D3D12_WARP=1, no physical GPU used), dxil.dll 1.8.2502.11 (SDK 10.0.26100.0), rustc 1.98.1. Base origin/main
63bcca43c6.Command:
cargo test -p victory-shader --lib --locked -j 4 -- --test-threads=1.Baseline: on base, 298 passed / 4 failed / 3 ignored. The 4 failures are WARP lane-emulation tests in
synthetic_tests(a_mask_joined_with_data_at_a_uniform_loop_is_its_number, gathers_at_a_level_match_the_hardware, permutes_mask_high_address_bits_and_divergent_branches, permutes_read_the_lane_named_and_zero_from_lanes_left_out). They fail identically on base, each head and the merge, so they are not caused by either PR.valu_tests.rshunk:short_store_at_byte_three_writes_both_dwordsFAILS on base (dword 1 stays 0, want 0xA5) as claimed.short_store_at_u32_max_does_not_wrap_to_dword_zeropasses on base, since the wrap only exists with the new second write, so it is a regression guard, not a fail-before test.cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean (not the whole workspace).Lower::buffer: the low half goes through the same two-atomic clear/set as before; the second write (byte 3, width 16 only) targetsat_base + 4for the high byte, guarded byguard && byte == 3 && next > at_base(unsigned), which correctly stops u32::MAX wrap; the second dword goes throughraw_viewwith that guard, so OOB handling follows the existing path. The two dwords are separate atomics, so the pair is not atomic as a unit (another lane or thread can observe the low byte updated first); each dword is updated atomically with other lanes' fields preserved, and this matches the previous per-dword guarantee. No wave-size dependence. Duplicated lanes writing the same address are not specially ordered, same as before.7bad309bbf): YES, they conflict incrates/victory-shader/src/emit/lower.rs(same buffer-store block; git merge-tree and a real merge both report a content conflict). #3572 does not conflict with #2208. Whichever lands second needs a rebase; if #2208's CAS loop lands first, the cross-dword split here must be redone on top of it.Verdict: no defect found. AI use: this check was run by Claude Code (Claude Sonnet 5.5).
@kilolimaVI on GitHub · 2026-11-27 19:37 UTC · original
Hardware run, head
813c866: Windows 11, Radeon 780M (RDNA3 iGPU), toolchain 1.98.1.short_store_at_byte_three_writes_both_dwords,short_store_at_u32_max_does_not_wrap_to_dword_zero: 2 passed, 0/5 failures over 5 runs.cargo test -p victory-shaderon the 780M: 304 passed, 0 failed.AI-assisted (Claude).
@pickles976 on GitHub · 2026-11-27 19:43 UTC · original
Matched hardware verification: head
813c866365343f397bce7d56f2846501408f622cversus parent63bcca43c6a00a758510398fa43096ce7e4f7df0, with identical test-only fixtures/helpers on both. Original instruction words and complete expected outputs retained; SDK DXIL validator and physical NVIDIA DXGI identity are mandatory, duplicate Wine-WARP leg removed. Production unchanged.[0xBE000000, 0]instead of[0xBE000000, 0xA5]One real NVIDIA dispatch and full UAV readback per fixture; two validated shaders / three checked output words per checkout. Parent 1 pass/1 fail (1.27 s), head 2 pass/0 fail (1.25 s); fresh intended-tree compilations on both. This directly reproduces the dropped high byte on this Wine/NVIDIA path and verifies the correction. It does not certify indexed addressing, an in-range store crossing a resource boundary, two-dword atomicity, #2208 interaction, original title shaders or gameplay.
Linux 6.17 / Wine 11 / RTX 4060 Laptop 8 GiB / NVIDIA 590.48.1; masking disabled. Diagnostic-relaxed-vtable vkd3d
2576c0b4adfae4a+, not stock certification. Existing guards unchanged; no title launch.Evidence under
.compat-runtime/logs/:verify-pr3576-parent-short-store-20261127T194050Z/,verify-pr3576-head-short-store-20261127T194058Z/. Local fixture changes retained as provenance; no source PR or assets published.AI-assisted verification.
@kilolimaVI on GitHub · 2026-11-27 19:58 UTC · original
Before/after on the same 780M: with this PR's test file on main
63bcca4,short_store_at_byte_three_writes_both_dwordsfails on hardware ([0xBE000000, 0], want[0xBE000000, 0xA5]) andshort_store_at_u32_max_does_not_wrap_to_dword_zeropasses, the same split pickles976 saw on NVIDIA; with the PR both pass (0/5 failures above).AI-assisted (Claude).
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.