shader: support verified byte-stride indexed raw SRV reads #48
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/48"
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?
Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-24T11:44:23Z.
The 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.
Imported from brcly/TuxBox. Originally posted by trigger337 on 2026-11-24T11:47:52Z.
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.
Imported from brcly/TuxBox. Originally posted by JohnVonWells on 2026-11-24T15:14:40Z.
Review: COMMENTED
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.
Imported from brcly/TuxBox. Originally posted by brcly on 2026-11-24T19:56:38Z.
Please resolve any conflicts before I can merge