Repository navigation
Shaders: LDS accesses outside the program's allocation read 0 and drop their writes - #1769
Impre-visible wants to merge 1 commit into
Conversation
VIctory V2: community PRs, merged and testedOpen PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: Unofficial community fork of Marvisak/VIctory, GPL-3.0. |
catminou4
left a comment
There was a problem hiding this comment.
Merge conflict with current main (70564ae) — the LDS-allocation bounding change (and_guard + lds_accesses_are_bounded_by_the_allocation test, reads-out-of-allocation → 0 and drops) needs a rebase. The approach looks right statically: bounds are checked against the program's LDS allocation rather than a fixed size. Happy to re-test after rebase.
|
Gap with the sub-dword LDS paths Besides the rebase conflict already mentioned, the bound doesn't reach every LDS address:
The new test only counts calls to the closure, so it can't catch a wrong predicate (as with the Static review (AI-assisted), read against |
|
Merged today's 🤖 Generated with Claude Code |
|
Hardware check of this PR with the device test from #1870. AMD RX 6600 XT (RDNA2, driver 32.0.21045.29003) and WARP, Windows 11, Rust 1.98.1 MSVC, DXC 1.9.2609 validator. Synthetic programs only, no game files. This PR's test checks the lowering (a counter). #1870 has a test that runs the translated program on the device:
#1870 measured the same 306/340 on an RX 6750 XT, so this isn't specific to one card. #1870 is the same fix written separately. If this PR lands, #1870 can close. Its test is worth bringing along: it is about 40 lines in Not checked: the title (no game files here), and the |
|
Automated triage for the maintainers. Proposed close: already in What's left here is a test-only counter ( This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label CI: passing. Generated by Claude Code |
|
Merged the current 🤖 Generated with Claude Code |
|
The Windows run the Not-tested list mentions. Ran on Windows 11 with an RTX 3070 (Ampere, 32-lane waves, driver 616.56), debug build, at AI-assisted (Claude Code). |
|
NVIDIA counterpart of the RX 6600 XT check above: on an RTX 4070, Setup: RTX 4070 (Ada, 32-lane waves), driver 621.01, Windows 11, Rust 1.100.0.
That is the same 306/340 as on the RX 6750 XT and RX 6600 XT, so this is not AMD-specific. On NVIDIA, the stray write lands in the group-shared memory next to the array. Full shader suite ( AI-assisted. |
|
@Mericas77 thank you, that closes the gap I could not close myself: this PR had only a WARP-level test plus title runs on one NVIDIA card, and you now show on hardware that Summary of the independent checks so far, for the maintainers:
The hardware test that proves it is the one from #1870 ( 🤖 Generated with Claude Code |
|
Native Windows run, which the description lists as not done: RTX 4070 Ti (Ada), driver 621.01, Windows 11 Pro build 26300, Rust 1.98.1 pinned, this PR merged on main
Limit: the new test checks the lowering (one bound per LDS access), it doesn't dispatch on the GPU, and I didn't run a title. This doesn't answer the NVIDIA group-shared layout question. AI-assisted (Claude). |
…allocation read 0, drop writes) lower.rs: main's test-only heap_handles count and Marvisak#1769's lds_bounds count both kept, in Lowered and where it is built. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Upstream main merged Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906 and Marvisak#1152 and took up what Marvisak#1769 (LDS bounds, Marvisak#1949) and Marvisak#1763 (typed UAV formats, Marvisak#2462) did; main's code is kept for those. - emit/lower.rs: ds_bpermute within each half (main's Marvisak#573, same as Marvisak#439's); LDS bounds as main's Marvisak#1949 (Marvisak#1769's test-only counter kept, its and_guard dropped); title-memory marks: main's straddling-write lookup (Marvisak#2484) with Marvisak#2167's current head (3cb308d, rebased on 63bcca4): guarded dirty atomics, raw_dword2, memory_null, synthetic_mark_dxil in lower/mark_tests.rs; the old Marvisak#2167 head taken out first. - emit/host.rs: main's shared WARP device and lock (Marvisak#244) with Marvisak#439's adapter list and Host::on (create_device takes an optional adapter). - descriptor/host.rs: main's Marvisak#2462 format checks; Marvisak#1763's tests kept. - gpu host.rs: main's multi-plane present with Marvisak#2310's crumbed copy. - pipeline.rs: Marvisak#2118/Marvisak#2311's builder and BVH checks with main's skip hashes (Marvisak#1320); draw.rs, shadow.rs, main.rs: both sides. - Tests main added since get Marvisak#439's Parts fields and emit's Target. - README: base 63bcca4; rows of PRs merged upstream, superseded or closed taken out, with a note. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The previous renderer (old upstream base 940d32f) is the first parent and is also kept as the branch renderer-2026-11-25-oldbase; the second parent is the rebuild: fork main (upstream main 63bcca4 + our pull requests) with the renderer stack merged on it: Marvisak#439 (on main: update/439-main's resolution), Marvisak#2309, Marvisak#2167, Marvisak#2118, Marvisak#2311, Marvisak#1722, Marvisak#1751, Marvisak#688, Marvisak#1872, Marvisak#2292, Marvisak#2310, Marvisak#2112 (opt-in), Marvisak#2230 (latch on by default), Marvisak#2389, Marvisak#2088 (small windows opt-in), Marvisak#2099's new head, and tonight's Marvisak#491 journal fixes. Merged upstream since: Marvisak#2143, Marvisak#2162, Marvisak#158, Marvisak#1906, Marvisak#1152; superseded by main: Marvisak#1769, Marvisak#1763, Marvisak#2366. The picture on this base still shows the overlay that plain upstream main shows too; that is being looked into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Impre-visible yes, please take |
main bounds every LDS access by the program's allocation (Marvisak#1949), and its test lds_out_of_bounds_reads_zero_and_drops_writes runs the translated program on a device, so it runs on Windows only. The lowering now counts the bounds it emits (in tests), and lds_accesses_are_bounded_by_the_allocation checks that a write, a read and a returning atomic each get one, on any host. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TsTmwWj9LVy4o3qDH52Jas Signed-off-by: Impre-visible <69050895+Impre-visible@users.noreply.github.com>
|
Rebuilt this branch on What remains is one test-only commit: a counter of the bounds the lowering emits, and Linux: 🤖 Generated with Claude Code |
38e1d55 to
c2ee29a
Compare
|
@Impre-visible thanks for rebuilding this on 63bcca4 and for checking against #1949. I ran c2ee29a on an RX 6750 XT (RDNA2, driver 32.0.21045.29003, Windows 11, Rust 1.98.1): For what it's worth, the counter test is useful on its own: the device test for #1949 only runs on Windows, and this one also checks the lowering off Windows. Whether it stays open is the maintainer's decision, and closing it as superseded is fine by me too. Unit tests only, no game files. |
What
Lower::dsincrates/victory-shader/src/emit/lower.rstook every LDS address as in bounds (its own comment called it a shortcut: "out-of-bounds console accesses read 0 and drop writes"). This gives LDS accesses that console behaviour:lds_dwords, unsigned);A small
and_guardhelper narrows a lane guard. One test,lds_accesses_are_bounded_by_the_allocation, lowers a write, a read and an atomic with a returned value and checks that each got its bound (a test-only counter besidenonuniform_handles).Why it matters
A title compute program can be written for one thread group and still be dispatched with several: its LDS addresses then come from the global thread id, and in every group but the first they lie far outside the allocation. On the console that is harmless. On the host the writes land in whatever group-shared variable sits next to the LDS array.
With a wave64-on-32-lane implementation that keeps its own synchronisation state in group-shared memory (#1433's console flow:
phase,arrived,finishednext tolds), those stray writes can corrupt that state, and its wait loops are not covered by the loop limit. On my machine this is what ended every run at world entry.Measured
Linux, Wine (GE-Proton11-6) + vkd3d-proton, GTX 1660 6 GB (32-lane waves), NVIDIA 620.73.04. Test tree: #1433 with #1492 merged by hand plus #1077 #1175 #523 #530 #1040 #1406 #542 #1056 #1392 #1516 #1388 #1189 #1523 (details in my comment on #1581).
Without this change, in that tree:
NVRM: Xid 109 ... CTX SWITCH TIMEOUT16 to 28 s before the title stops, GPU at 100 % for about 8 s first, VIctory then waiting forever on the submission's fence.32x1x1dispatch of a small program that uses LDS.VICTORY_SHADER_LOOP_LIMIT=64does not help, which fits a spin outside the program's own loops.With this change, same tree, nothing skipped, 3 runs:
So the immediate hang is gone; the world is not stable yet for other reasons.
Validity of what is emitted: on this branch (plus #226's two lines applied locally, without which main's SPIR-V fails on NVIDIA anyway), vkd3d-proton converted 1,484 modules in a run into the world and
spirv-valaccepts all of them. (My first attempt used the float predicateULTinstead ofIULTfor the bound, which the unit tests did not catch andspirv-valdid; that is fixed here.)Not tested
cargo test -p victory-shader --lib: 97 passed, 1 ignored. Builds forx86_64-pc-windows-msvcwith and without--features diagnostics.cargo clippy: not run here.🤖 Generated with Claude Code