Shaders: typed buffer elements crossing the record end read zero #3597
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!3597
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3597"
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 20:05 UTC · original
Moon0755:fix/typed-element-spill→main· +89 −1 · 2 files · 1 commits · openOn RDNA2 (
gfx1036, measured natively in Leonidadocs/design.md), typed buffer loads (buffer_load_format_*/tbuffer_load_format_*) are all-or-nothing against the buffer end: an element whoseoffset + element_sizeextends past the view's byte width returns0in every data channel (with missing channels past the format keeping(0, 0, 0, 1)), rather than returning partial data from leading in-bounds dwords. Onmain,Lower::format_loadissued per-dwordrawBufferLoadcalls and kept data from leading dwords even when trailing dwords were out of bounds.Changes
crates/victory-shader/src/emit/lower.rs(Lower::format_load,521,509bytes /+946vsmain,2,779bytes below the524,288limit):getDimensionson the raw viewh(already post-raw_view, sooffandwidthshare the same coordinate space), computewhole = (off + total / 8 >= off) && (off + total / 8 <= width), and select0for every decoded format channel when!wholewhile leaving constant-1 missing channels intact.#3572inlower.rs.crates/victory-shader/src/emit/valu_tests.rs:typed_elements_ending_past_the_buffer_read_zerocoveringtbuffer_load_format_xy(32_32_UINT, format62,8bytes) on a20-byte raw view at byte12(in-bounds control) and byte16(ending past the buffer ->0).Verification
main): https://github.com/Moon0755/VIctory/actions/runs/46058009518 (failure— 302 passed, 1 failed solely ontyped_elements_ending_past_the_buffer_read_zero:0x22222222instead of0)devin/ci-typed-element-spill): https://github.com/Moon0755/VIctory/actions/runs/46058009634 (success— 303 passed / 0 failed, Clippy + diagnostics Clippy clean,asset policy: 191 files ok)a7b9122):typed_elements_ending_past_the_buffer_read_zero(1/1) andtbuffer(1/1) pass on hardware + WARP; both Clippy configs andcargo xtask policy(191 files ok) clean.DST_SELswizzles on typed OOB, OOB modes0..=2, stride/swizzle/idxen,d16/ narrow-count variants of wide formats,dxil.dll1.7, game files. Synthetic tests only (AI-assisted).— Devin & Neon
@oni-swr on GitHub · 2026-11-27 20:29 UTC · original
Verification of head
a7b91220against base main63bcca43(heads/base re-checked unchanged before testing).Hardware: Windows 11 Pro 26200, WARP only (no physical GPU); dxil.dll 1.8.2502.11 (SDK 26100).
Tests (
cargo test -p victory-shader): head 299 passed / 4 failed / 3 ignored; base 298 passed / 4 failed / 3 ignored. The 4 failures are the same on base and head (synthetic_tests that need a wave-32 pipeline or hardware-specific gather behaviour, unsupported on WARP), so they are pre-existing and unrelated. The new testtyped_elements_ending_past_the_buffer_read_zeropasses on head.Control: base plus only this PR's
valu_tests.rshunks: the new test fails (5 failed vs 4 on base), so it detects the missing behaviour.Clippy:
cargo clippy -p victory-shader --all-targets -- -D warningsclean on head.Review: no defects found. The bounds rule (
off + sizeno wrap and<= widthfrom getDimensions, whole element otherwise all data channels 0) matches the claim, and the default channels (0,0,0,1) for channels past the format are still applied after the select. Sub-dword elements are checked on their own end byte. I only checked this against WARP, not hardware.Size: lower.rs 521,509 bytes (main 520,563), under the 524,288 limit. Textual merge of #3597 + #3602: clean, 521,714. Adding #3587: 522,154. Adding #2997 as well: clean merge but 525,571, which is 1,283 over the limit (main + #2997 alone is 523,980, fine). So the four together will not fit in lower.rs without moving code out.
AI-assisted (Claude Sonnet 5.5)
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.