shader: support verified byte-stride indexed raw SRV reads #48
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/brcly--TuxBox!48
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/48/head"
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?
@Valdi320 on GitHub · 2026-11-24 11:44 UTC · original
Valdi320:work/scarlett-verified-raw-index→main· +296 −16 · 6 files · 2 commits · merged 2026-11-24 20:14 UTCThe public ProjectScarlett log in #39 contains 43 refusals for raw IDXEN addressing. This change addresses the subset where native code proves a linear stride-one SRV descriptor (the existing direct root and mesh root SRV constructors). For direct roots, require the entire four-word construction within the same basic block and reject any intervening descriptor-word clobber. The existing mesh descriptor proof checks the exact native words. Unknown runtime strides and indexed raw writes/atomics remain rejected.
Use index plus optional second-VGPR byte offset and immediate/scalar offset. Keep one-dword loads (no Load2/3/4) and suppress reads on guest-inactive lanes for the new path.
Validation:
No retail shaders were recompiled; the number of affected actual requests is not yet measured. AI-assisted contribution.
@trigger337 on GitHub · 2026-11-24 11:47 UTC · original
AI-assisted: yes
Hardware/compiler validation on Linux (CachyOS x86_64, AMD Radeon RX 6900 XT / RADV Navi 21, Vulkan 1.4.333):
tuxbox-xshaderRust unit tests (cargo test --target x86_64-unknown-linux-gnu --manifest-path tools/shader-compiler/Cargo.toml):hlsl::raw_width::byte_index_proof_rejects_unknown_stride_and_clobbers: passhlsl::raw_width::indexed_descriptor_proof_does_not_cross_a_basic_block: passhlsl::raw_width::proven_byte_index_emits_addresses_without_widening_loads: passIntegration & Smoke Tests (
python3 -m unittest discover -s tests):Strict proof window checks (enforcing that direct roots prove 4-word construction within the same basic block without clobber, rejecting unknown runtime strides and raw writes/atomics, and emitting per-dword loads without widening) compile and test cleanly on Linux.
@brcly on GitHub · 2026-11-24 19:56 UTC · original
Please resolve any conflicts before I can merge
@JohnVonWells on GitHub · 2026-11-24 15:14 UTC · original · reviewed
Reviewed on Arch Linux + RX 6950 XT (RDNA2).
cargo test --features legacy-hlsl -p tuxbox-xshader -- raw_index byte_index indexed_descriptor proven_byte: 3/3 pass (incl. the three newraw_widthcases).The proof shape in
raw_index::local_byte_descriptoris pleasantly tight:s_mov/s_orwith the exact format literal (0x11014fac) + size-1+ root low +(root+1 | 65536)for stride-1. Any deviation — missing dword, aliasing between base and root, a clobber of the base register between construction and the load, a different stride literal, or a basic-block boundary — refuses.byte_index_proof_rejects_unknown_stride_and_clobbers,indexed_descriptor_proof_does_not_cross_a_basic_block). That's how I like proof predicates audited.Also good:
raw_byte_index.remove(&ins.offset)at the start of the MUBUF case keeps the proof from surviving a second CFG visit — small detail that would bite later.raw_byte_index.clear()inresolve_resources's recording pass matches the convention used by neighbouring sets (msel,bsel, …).exec_lo & 1uguard on IDXEN loads addresses the case where an inactive lane's VGPR holds garbage. Since unproven IDXEN now errors out earlier, in practice this only wraps the proven byte-stride path, which is the right place to be defensive.Two small observations (not blockers):
base + 3is derived frombase % 4 == 0andbase <= 100, so the address arithmetic can't overflow — the guards look belt-and-braces, which I'm fine with.println!("BEGIN_HLSL…")comment calls out running under--nocapture. Neat trick for GPU validation without exposing a test-only API; worth keeping.LGTM.