shader: lower subword, indexed, and OOB-checked code-table buffer loads (#4) #486
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!486
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-482"
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?
@lucasferreira1610 on GitHub · 2026-11-27 22:00 UTC · original
lucasferreira1610:vibe/code-table-buffer-loads-6f14bc→main· +316 −37 · 3 files · 1 commits · openWhat this changes
Refs #4
Extends
Lower::code_buffer_loadincrates/victory-shader/src/emit/lower.rsfor buffer descriptors built around a constant table appended to shader code (s_getpc_b64):buffer_load_ubyte,buffer_load_sbyte,buffer_load_ushort,buffer_load_sshort): lowers 1- and 2-byte loads viaLower::code_subword, including unaligned 16-bit loads straddling two dwords, instead of refusing them as non-dword loads.idxen): uses the descriptor's stride in dword 1 (bits 16–29) instead of refusing indexed loads.OOB_SELECTbounds checking (modes 0–3): replaces the hardcoded mode-3 shortcut and fixes a 32-bit unsigned wrap-around bug in mode 3 (voffset + immediate + payload_end <= recordscould previously wrap on large/negative offsets). Uses 64-bit widening only whenindex * strideis present in mode 3 with non-zero stride; keepsSOFFSETexcluded from bounds.bits >> 30 != 0),ADD_TID_ENABLE, non-buffer types (control & 0xC080_0000 != 0), and stores/atomics/format loads, matchingcomputed_buffer.crates/victory-shader/src/emit/gfx_refusal_tests.rsand updatesdocs/native-host.md.How it was tested
cargo test -p victory-shader -p xtask(404 passed, 0 failed, 3 ignored) andcargo test --target x86_64-apple-darwin --lib -p victory-shader -p victory-loader -p victory(victory-shader: 404 passed, 0 failed; victory-loader: 29 passed, 0 failed) andcargo test -p victory-hle --lib(144 passed, 0 failed)cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings(0 warnings) andcargo clippy -p victory-shader --all-targets -- -D warnings(0 warnings) andcargo xtask policy(398 files ok)Checklist
VICTORY_*variable and documented@AnastasisKon on GitHub · 2026-11-28 18:36 UTC · original · approved these changes
Reviewed and verified locally on head
59ca4f75(worktree /private/tmp/review-482):The rewrite is careful where it matters: mode 3's payload-end check is now computed in u64 (const_end and rem are u64), with 64-bit widening of index*stride+voffset only when an indexed, non-zero-stride mode-3 access could wrap u32 — that fixes the wrap-around the old shortcut had. Modes 0/1/2 follow table 35 (mode 0 checks voffset against stride minus the constant part plus index < records; mode 2 disables checks but an empty descriptor still reads 0), SOFFSET stays out of the bounds as in computed_buffer, and code_subword assembles 1/2-byte loads byte-by-byte so an unaligned halfword straddling two dwords reads correctly, with sign extension via shl/ashr. Descriptor validation (swizzle bits, ADD_TID, non-buffer control) matches computed_buffer. Approving.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.