Direct DXIL: enforce byte-buffer bounds across memory windows #1727
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1737"
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 ivall/xcl. Originally posted by Ariyo31 on 2026-11-24T20:03:48Z.
Improve direct DXIL buffer bounds checking and reduce the cost of narrow buffer loads.
Part of #1269.
What is in it
Tested
Both targeted regression cases failed before the patch and passed after it. All 251,904 synthetic output checks matched the CPU reference.
Test command:
cargo test --release --workspace --no-fail-fast -- --nocapture --test-threads=1Regression run
Main: Pending.
PR: Pending.
Known limitations
The OOB_SELECT and SOFFSET concerns raised during review remain under investigation. This patch does not yet implement complete descriptor-correct bounds checking.
Not tested
AI use
OpenAI Codex (GPT-6.2-Astra and GPT-6.2-Sol) assisted with implementation, regression testing, benchmarking, upstream compatibility checks and PR preparation.
Imported from ivall/xcl. Originally posted by ddaikodaiko on 2026-11-24T20:11:51Z.
One thing to decide before this lands:
buffer_bytes_in_rangeis applied inside the oldstride == 0choice, and that choice is not the rule the console descriptor gives:The HLSL path already reads
OOB_SELECTfrom V# word 3 [29:28] (BT-002, merged): mode 0 isindex < N && offset + bytes <= STRIDE, mode 1index < N, mode 2N != 0, mode 3 (raw)offset + soffset + bytes <= N. Withstride == 0as the selector, a descriptor in mode 0/1/2 is judged by a bound that is not its own, and in raw mode the check here still missessoffset:offisvoff + OFFSET, so a carry fromsoffset(which is added into the address but not into this check) is invisible even on one window. Your 64-bit carry check catches theoff/bytesoverflow but not that one.So either:
buffer_bytes_in_rangetakessoffand theOOB_SELECTvalue and picks the four checks, orIf it helps: an unverified fork branch has the BT-002 port for the direct translator (
ddaikodaiko/xclcontrib/mubuf-oob0643c46), and it rewrites this same closure, so the two will conflict when both exist; the measured rule and the 732 native cases behind it are in the BT-002 report on #1488.AI use: written with OpenCode (DeepSeek V4.1 Flash); a person submitting any of this is responsible for running it.
Imported from ivall/xcl. Originally posted by Ariyo31 on 2026-11-24T20:16:13Z.
Review the new comment from ddaikodaiko on xcl-dev/xcl PR #1737.
Investigate the OOB_SELECT and SOFFSET concerns against the merged BT-002 behavior in the HLSL backend and issue #1488.
Decide whether to:
Inspect the suggested fork branch for context, but independently verify the logic. Avoid copying unverified implementation.
Add targeted tests for each OOB_SELECT mode, SOFFSET carry and 32-bit overflow. Preserve our existing regressions and benchmarks.
Report your recommended solution and test results before pushing further changes. Do not reply on GitHub or push without my permission.
Imported from ivall/xcl. Originally posted by Raghav314 on 2026-11-24T20:48:20Z.
Retail-pack A/B of #1737 on NVIDIA Windows: −2 % DXIL, −9 % driver time on the direct form, no failures. Counts and timings only.
Setup: RTX 4090 24 GB, driver 617.14, Windows 11, DXC 1.8.2502.11, release. Two binaries that differ only by this PR:
main6c89285(this PR's base) and this PR's head0c6b681, each with the same timing harness (xcl shaders --time-forms, branch, described on #1745). Retail 1.0.2.1 pack: 40 compute programs spread over the size range plus the 10 largest, split wave64, 4 windows. #1426's per-instruction form translated, then made into a compute pipeline one at a time, with the driver's shader cache off for the process (ShaderCacheControl). Driver builds capped at 1 MB of DXIL, so the largest programs give sizes only. First row dropped as driver warm-up.mainNot tested: correctness of the output on the GPU (no title run, no output comparison), the bounds-check behaviour itself, AMD, the full suite.
AI use: Claude Code (Claude Opus 5.5) built both binaries, ran the measurements and drafted this.
Imported from ivall/xcl. Originally posted by Ariyo31 on 2026-11-24T20:52:39Z.
Thank you for taking the time to benchmark my PR on real retail shaders! It's great to see a consistent 9% reduction in driver compilation time.
I'm still looking into the bounds-checking concerns raised earlier. I really appreciate the independent testing and feedback.
Imported from ivall/xcl. Originally posted by alexmircea1299 on 2026-11-24T21:11:42Z.
Working fine on 5070.
0c6b681)rustc 1.100.0, debug build.\scripts\test.ps1(cargo test --workspace -- --test-threads=4)814 passed; 0 failed; 22 ignored(14.07s)822 passed; 0 failed; 34 ignoredImported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T22:43:55Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:35:57Z.
Regression run of
0c6b681aon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.upstream-sync referenced this pull request2026-11-25 05:07:26 +00:00
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:37:56Z.
Triage (#1607) – head
0c6b681The core of this PR is on main in other code.
cb7fe9b(#1893) rejectsvoff + OFFSETandoff + bytes32-bit wraparound inLw::mubufandbuffer_atomic, so a largevoffcan no longer pass thed2check whilebuffer_windowcarries into the next window.0b64aa0hoistsuma_baseinto the entry block (uma_base_val) and replaces the sub-dword loads withld_raw_u32_guarded, which reads the next word for a crossing halfword.The branch conflicts with those rewrites. What remains, the
window/window_hiconstant-zero shortcuts and the multi-window atomic test, would need a new PR against current main.Recommendation: close (superseded by main commits
cb7fe9band0b64aa0).AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.