Shaders: LDS accesses outside the program's allocation read 0 and drop their writes #1769

Open
github-bot wants to merge 1 commit from github-bot/gh-1769 into main AGit
Owner

@⁠Impre-visible on GitHub · 2026-11-24 22:15 UTC · original
Impre-visible:fix/lds-out-of-bounds → main · +27 −0 · 2 files · 1 commits · open

What

Lower::ds in crates/victory-shader/src/emit/lower.rs took 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:

  • each access compares its dword index with the program's allocation (lds_dwords, unsigned);
  • outside it, a read gives 0, a store or an atomic is skipped, and the value an atomic returns is 0 for an active lane (an inactive lane keeps its register, as before);
  • the element address is clamped to element 0 when outside, so nothing is ever addressed past the array.

A small and_guard helper 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 beside nonuniform_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, finished next to lds), 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:

  • 9 of 9 runs that reached the world: kernel NVRM: Xid 109 ... CTX SWITCH TIMEOUT 16 to 28 s before the title stops, GPU at 100 % for about 8 s first, VIctory then waiting forever on the submission's fence.
  • A bounded first wait named the stuck submission: one list with 12 compute dispatches. Skipping pipelines (diagnostic only): all 12 skipped, no Xid in 7 minutes; with the first 6, 9 or 11 skipped the Xid 109 stays, so it is the last one, a 32x1x1 dispatch of a small program that uses LDS. VICTORY_SHADER_LOOP_LIMIT=64 does not help, which fits a spin outside the program's own loops.

With this change, same tree, nothing skipped, 3 runs:

run Xid 109 within 30 s of world entry what happened
1 no 6 minutes in the world, no Xid, reached a frame where the final image shows a lit 3D scene (first time on this machine); ended by my time limit
2 no 3 min 17 s in the world, then one Xid 109 (a later, different stall; not identified yet)
3 no no Xid at all; the title stopped on its own after 5 min 50 s of game time (the #1323 stop)

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-val accepts all of them. (My first attempt used the float predicate ULT instead of IULT for the bound, which the unit tests did not catch and spirv-val did; that is fixed here.)

Not tested

  • Windows and AMD: not run. cargo test -p victory-shader --lib: 97 passed, 1 ignored. Builds for x86_64-pc-windows-msvc with and without --features diagnostics.
  • The execution result itself (that an out-of-bounds read returns 0 on a host) is not covered by a GPU test; the unit test checks the lowering only.
  • I did not verify how NVIDIA lays out group-shared variables; the corruption path is inferred from the emitted module and from the A/B above, not observed directly.
  • Byte and halfword LDS accesses are still unsupported, as before.
  • cargo clippy: not run here.

🤖 Generated with Claude Code

**@⁠Impre-visible** on GitHub · 2026-11-24 22:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769) `Impre-visible:fix/lds-out-of-bounds` → `main` · +27 −0 · 2 files · 1 commits · open ## What `Lower::ds` in `crates/victory-shader/src/emit/lower.rs` took 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: - each access compares its dword index with the program's allocation (`lds_dwords`, unsigned); - outside it, a read gives 0, a store or an atomic is skipped, and the value an atomic returns is 0 for an active lane (an inactive lane keeps its register, as before); - the element address is clamped to element 0 when outside, so nothing is ever addressed past the array. A small `and_guard` helper 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 beside `nonuniform_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`, `finished` next to `lds`), 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: - 9 of 9 runs that reached the world: kernel `NVRM: Xid 109 ... CTX SWITCH TIMEOUT` 16 to 28 s before the title stops, GPU at 100 % for about 8 s first, VIctory then waiting forever on the submission's fence. - A bounded first wait named the stuck submission: one list with 12 compute dispatches. Skipping pipelines (diagnostic only): all 12 skipped, no Xid in 7 minutes; with the first 6, 9 or 11 skipped the Xid 109 stays, so it is the last one, a `32x1x1` dispatch of a small program that uses LDS. `VICTORY_SHADER_LOOP_LIMIT=64` does not help, which fits a spin outside the program's own loops. With this change, same tree, nothing skipped, 3 runs: | run | Xid 109 within 30 s of world entry | what happened | |---|---|---| | 1 | no | 6 minutes in the world, no Xid, reached a frame where the final image shows a lit 3D scene (first time on this machine); ended by my time limit | | 2 | no | 3 min 17 s in the world, then one Xid 109 (a later, different stall; not identified yet) | | 3 | no | no Xid at all; the title stopped on its own after 5 min 50 s of game time (the #1323 stop) | 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-val` accepts all of them. (My first attempt used the float predicate `ULT` instead of `IULT` for the bound, which the unit tests did not catch and `spirv-val` did; that is fixed here.) ## Not tested - Windows and AMD: not run. `cargo test -p victory-shader --lib`: 97 passed, 1 ignored. Builds for `x86_64-pc-windows-msvc` with and without `--features diagnostics`. - The execution result itself (that an out-of-bounds read returns 0 on a host) is not covered by a GPU test; the unit test checks the lowering only. - I did not verify how NVIDIA lays out group-shared variables; the corruption path is inferred from the emitted module and from the A/B above, not observed directly. - Byte and halfword LDS accesses are still unsupported, as before. - `cargo clippy`: not run here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On the console an LDS address past the allocation reads 0 and its write is
dropped. The lowering took every address as in bounds (a noted shortcut),
so on the host such an access lands in whatever group-shared variable sits
next to the LDS array.

A title program written for one thread group but dispatched with several
computes its LDS addresses from the global thread id: in every group but
the first they lie far outside the allocation. Each LDS access (read,
write, atomic) now compares its dword index with the allocation: outside
it a read gives 0, a store or atomic is skipped, and an atomic's returned
value is 0 for an active lane.

Test: lds_accesses_are_bounded_by_the_allocation.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsTmwWj9LVy4o3qDH52Jas
Signed-off-by: Impre-visible <[email protected]>
main added byte and halfword LDS reads and writes through the same dword
helper: they get the same bound (a read outside gives 0, the atomics of a
write outside are skipped).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsTmwWj9LVy4o3qDH52Jas
Signed-off-by: Impre-visible <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsTmwWj9LVy4o3qDH52Jas
Signed-off-by: Impre-visible <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:44:05 +00:00
github-bot force-pushed github-bot/gh-1769 from 38e1d553e3 to c2ee29ac05 2026-11-26 06:31:08 +00:00 Compare
Author
Owner

@⁠DesertGamer on GitHub · 2026-11-24 22:16 UTC · original

VIctory V2: community PRs, merged and tested

Open 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).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

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:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

**@⁠DesertGamer** on GitHub · 2026-11-24 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7146032085) ### VIctory V2: community PRs, merged and tested Open 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). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. 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: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
Author
Owner

@⁠rminzao on GitHub · 2026-11-24 23:09 UTC · original

Gap with the sub-dword LDS paths

Besides the rebase conflict already mentioned, the bound doesn't reach every LDS address:

  • Current main has byte/halfword LDS lowering (0b35b7f). Those read and write paths call dword(self, offset) and need the new inside result applied too. The PR body still calls those accesses "still unsupported", which is out of date.
  • #1795 adds lds_straddle, which builds the following dword (index + 1) directly instead of going through dword. With both PRs merged, a halfword at byte 3 of the last dword still reads or writes past the allocation, the corruption this PR is meant to stop. Whichever merges second needs an inside check on that second element.

The new test only counts calls to the closure, so it can't catch a wrong predicate (as with the ULT/IULT mix-up that slipped through). A test with an address just past the allocation, checking that it reads 0 and the write is dropped, would catch that.

Static review (AI-assisted), read against main at 70564ae; nothing was run on a GPU.

**@⁠rminzao** on GitHub · 2026-11-24 23:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7147074249) **Gap with the sub-dword LDS paths** Besides the rebase conflict already mentioned, the bound doesn't reach every LDS address: - Current `main` has byte/halfword LDS lowering (0b35b7f). Those read and write paths call `dword(self, offset)` and need the new `inside` result applied too. The PR body still calls those accesses "still unsupported", which is out of date. - #1795 adds `lds_straddle`, which builds the following dword (`index + 1`) directly instead of going through `dword`. With both PRs merged, a halfword at byte 3 of the last dword still reads or writes past the allocation, the corruption this PR is meant to stop. Whichever merges second needs an `inside` check on that second element. The new test only counts calls to the closure, so it can't catch a wrong predicate (as with the `ULT`/`IULT` mix-up that slipped through). A test with an address just past the allocation, checking that it reads 0 and the write is dropped, would catch that. _Static review (AI-assisted), read against `main` at 70564ae; nothing was run on a GPU._
Author
Owner

@⁠Impre-visible on GitHub · 2026-11-25 00:17 UTC · original

Merged today's main into this branch. main added byte and halfword LDS reads and writes through the same dword helper, so they now get the same bound: a read outside the allocation gives 0, the atomics of a write outside are skipped. cargo test -p victory-shader --lib: 120 passed, 1 ignored; builds for x86_64-pc-windows-msvc with and without --features diagnostics. The unit test still covers the dword forms only, and the merged result has not been run in the title yet.

🤖 Generated with Claude Code

**@⁠Impre-visible** on GitHub · 2026-11-25 00:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7148356800) Merged today's `main` into this branch. `main` added byte and halfword LDS reads and writes through the same `dword` helper, so they now get the same bound: a read outside the allocation gives 0, the atomics of a write outside are skipped. `cargo test -p victory-shader --lib`: 120 passed, 1 ignored; builds for `x86_64-pc-windows-msvc` with and without `--features diagnostics`. The unit test still covers the dword forms only, and the merged result has not been run in the title yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠jules47800 on GitHub · 2026-11-25 01:25 UTC · original

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: lds_out_of_bounds_reads_zero_and_drops_writes. It covers b32 write/read at +512 and +65532, ds_read_i8 at +600, ds_write_b8 at +513, ds_read2_b32 with offset1 800 bytes, ds_add_rtn_u32 at +512, a 32-bit wrap back inside (own - 16, offset 16), and a returning atomic under a partial EXEC.

Tree Result
main 42363ab + that test fails: hardware 306/340 inputs (the out-of-bounds write is kept and read back), WARP 0
this PR's head cd90d74 + that test passes on hardware and WARP
this PR merged into main 42363ab + that test cargo test -p victory-shader --lib: 248 passed, 0 failed, 3 ignored; both clippy configurations clean with -D warnings

#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 semantics_tests.rs, and the existing ds helper only needs its offset widened to u16 to encode offset1.

Not checked: the title (no game files here), and the lds_straddle path from #1795 raised above.

**@⁠jules47800** on GitHub · 2026-11-25 01:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7149525763) 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: `lds_out_of_bounds_reads_zero_and_drops_writes`. It covers b32 write/read at +512 and +65532, `ds_read_i8` at +600, `ds_write_b8` at +513, `ds_read2_b32` with offset1 800 bytes, `ds_add_rtn_u32` at +512, a 32-bit wrap back inside (own - 16, offset 16), and a returning atomic under a partial EXEC. | Tree | Result | |---|---| | main `42363ab` + that test | fails: hardware 306/340 inputs (the out-of-bounds write is kept and read back), WARP 0 | | this PR's head `cd90d74` + that test | passes on hardware and WARP | | this PR merged into main `42363ab` + that test | `cargo test -p victory-shader --lib`: 248 passed, 0 failed, 3 ignored; both clippy configurations clean with `-D warnings` | #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 `semantics_tests.rs`, and the existing `ds` helper only needs its `offset` widened to `u16` to encode offset1. Not checked: the title (no game files here), and the `lds_straddle` path from #1795 raised above.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 02:17 UTC · original · edited 2026-11-26 07:21 UTC

Automated triage for the maintainers.

Proposed close: already in main. Thanks for rebuilding the branch and saying so plainly. As you note, #1949 put the LDS bound into main. The dword helper in Lower::ds (crates/victory-shader/src/emit/lower.rs) compares the dword index with lds_dwords (IULT), reads 0 and drops writes outside the allocation. main also has the device test lds_out_of_bounds_reads_zero_and_drops_writes (emit/semantics_tests.rs), which checks the actual behaviour on hardware and WARP.

What's left here is a test-only counter (lds_bounds) and a test that counts how many times the bound is emitted. It doesn't check what the bound does, which main's device test already covers. So there isn't enough left to merge.

This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label triage: proposed close.

CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 02:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7150530915) · edited 2026-11-26 07:21 UTC <!-- victory-triage v1 head=c2ee29ac053528e8cc26d2093dcc60e01e6443b9 verdict=proposed-close at=2026-11-26T07:21:38Z --> Automated triage for the maintainers. **Proposed close: already in `main`.** Thanks for rebuilding the branch and saying so plainly. As you note, #1949 put the LDS bound into `main`. The `dword` helper in `Lower::ds` (`crates/victory-shader/src/emit/lower.rs`) compares the dword index with `lds_dwords` (`IULT`), reads 0 and drops writes outside the allocation. `main` also has the device test `lds_out_of_bounds_reads_zero_and_drops_writes` (`emit/semantics_tests.rs`), which checks the actual behaviour on hardware and WARP. What's left here is a test-only counter (`lds_bounds`) and a test that counts how many times the bound is emitted. It doesn't check what the bound does, which `main`'s device test already covers. So there isn't enough left to merge. This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label `triage: proposed close`. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Impre-visible on GitHub · 2026-11-25 05:00 UTC · original

Merged the current main (940d32f) into this branch; it merges without conflict now. Builds for x86_64-pc-windows-msvc with and without --features diagnostics; cargo test -p victory-shader --lib: 145 passed, 2 ignored.

🤖 Generated with Claude Code

**@⁠Impre-visible** on GitHub · 2026-11-25 05:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7153368139) Merged the current `main` (940d32f) into this branch; it merges without conflict now. Builds for `x86_64-pc-windows-msvc` with and without `--features diagnostics`; `cargo test -p victory-shader --lib`: 145 passed, 2 ignored. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 05:45 UTC · original

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 38e1d55, cargo test -p victory-shader --locked: 245 passed, 3 failed, 3 ignored. The new lds_accesses_are_bounded_by_the_allocation passes on NVIDIA. The 3 failures are #1744's NVIDIA failures on main. Same as main on this hardware.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 05:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7154102012) 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 `38e1d55`, `cargo test -p victory-shader --locked`: 245 passed, 3 failed, 3 ignored. The new `lds_accesses_are_bounded_by_the_allocation` passes on NVIDIA. The 3 failures are #1744's NVIDIA failures on `main`. Same as `main` on this hardware. AI-assisted (Claude Code).
Author
Owner

@⁠Mericas77 on GitHub · 2026-11-25 12:25 UTC · original

NVIDIA counterpart of the RX 6600 XT check above: on an RTX 4070, main keeps the out-of-bounds LDS write too, and this PR drops it.

Setup: RTX 4070 (Ada, 32-lane waves), driver 621.01, Windows 11, Rust 1.100.0. main at 940d32f and this PR at 38e1d55, each with #1870's lds_out_of_bounds_reads_zero_and_drops_writes added. Synthetic programs only, no game files.

cargo test -p victory-shader --locked --lib lds_ -- --test-threads=1, 3 runs each, same result every run:

Tree Result
main 940d32f + the test fails. Probe 1 (b32 at +512): 306/340 inputs differ on hardware, 0 on WARP. ds_read_b32 [own + 512] reads back b, so the write landed. Probes 2 and 3 (b8 at +513, read2 at +800, ds_add_rtn_u32 at +512, 32-bit wrap, partial EXEC) show 0 differences.
this PR + the test passes on hardware and WARP. lds_accesses_are_bounded_by_the_allocation and lds_bytes_and_halves_match_the_hardware also pass.

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 (cargo test -p victory-shader --locked --lib -- --test-threads=1): main 244 passed, 4 failed, 3 ignored; this PR 246 passed, 3 failed, 3 ignored. The 3 left are the known NVIDIA failures from #1744 (a_heap_buffer_read_by_element_takes_the_views_stride, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, gathers_at_a_level_match_the_hardware). None of them is about LDS.

AI-assisted.

**@⁠Mericas77** on GitHub · 2026-11-25 12:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7162352807) NVIDIA counterpart of the RX 6600 XT check above: on an RTX 4070, `main` keeps the out-of-bounds LDS write too, and this PR drops it. Setup: RTX 4070 (Ada, 32-lane waves), driver 621.01, Windows 11, Rust 1.100.0. `main` at `940d32f` and this PR at `38e1d55`, each with #1870's `lds_out_of_bounds_reads_zero_and_drops_writes` added. Synthetic programs only, no game files. `cargo test -p victory-shader --locked --lib lds_ -- --test-threads=1`, 3 runs each, same result every run: | Tree | Result | |---|---| | `main` 940d32f + the test | fails. Probe 1 (b32 at +512): 306/340 inputs differ on hardware, 0 on WARP. `ds_read_b32 [own + 512]` reads back `b`, so the write landed. Probes 2 and 3 (b8 at +513, read2 at +800, `ds_add_rtn_u32` at +512, 32-bit wrap, partial EXEC) show 0 differences. | | this PR + the test | passes on hardware and WARP. `lds_accesses_are_bounded_by_the_allocation` and `lds_bytes_and_halves_match_the_hardware` also pass. | 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 (`cargo test -p victory-shader --locked --lib -- --test-threads=1`): `main` 244 passed, 4 failed, 3 ignored; this PR 246 passed, 3 failed, 3 ignored. The 3 left are the known NVIDIA failures from #1744 (`a_heap_buffer_read_by_element_takes_the_views_stride`, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `gathers_at_a_level_match_the_hardware`). None of them is about LDS. AI-assisted.
Author
Owner

@⁠Impre-visible on GitHub · 2026-11-25 12:27 UTC · original

@⁠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 main keeps the out-of-bounds write on NVIDIA as well (306/340, same as the two AMD cards) and that this branch drops it.

Summary of the independent checks so far, for the maintainers:

Card main + #1870's test this PR + #1870's test
RX 6750 XT (from #1870) 306/340 differ not run there
RX 6600 XT fails passes
RTX 4070 fails, 306/340 passes, hardware and WARP

The hardware test that proves it is the one from #1870 (lds_out_of_bounds_reads_zero_and_drops_writes), written by @⁠wwwwwwww3333333, not by me. I have not copied it into this branch because it is their work. If they agree, I will add it here with their authorship kept (a Co-authored-by commit), or the maintainers can take the lowering from either place and the test from #1870; both changes bound the same accesses the same way.

🤖 Generated with Claude Code

**@⁠Impre-visible** on GitHub · 2026-11-25 12:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7162409852) @⁠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 `main` keeps the out-of-bounds write on NVIDIA as well (306/340, same as the two AMD cards) and that this branch drops it. Summary of the independent checks so far, for the maintainers: | Card | `main` + #1870's test | this PR + #1870's test | |---|---|---| | RX 6750 XT (from #1870) | 306/340 differ | not run there | | RX 6600 XT | fails | passes | | RTX 4070 | fails, 306/340 | passes, hardware and WARP | The hardware test that proves it is the one from #1870 (`lds_out_of_bounds_reads_zero_and_drops_writes`), written by @⁠wwwwwwww3333333, not by me. I have not copied it into this branch because it is their work. If they agree, I will add it here with their authorship kept (a `Co-authored-by` commit), or the maintainers can take the lowering from either place and the test from #1870; both changes bound the same accesses the same way. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠qtLkz on GitHub · 2026-11-25 13:14 UTC · original

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 940d32f (clean merge).

cargo test -p victory-shader --lib --locked -- --nocapture --test-threads=1

  • emit::lower::tests::lds_accesses_are_bounded_by_the_allocation ... ok
  • Whole victory-shader lib, including the hardware + WARP dispatch tests: 245 passed, 3 failed, 3 ignored. The 3 failures (two stride_tests, synthetic_tests::gathers_at_a_level_match_the_hardware) are the same as on plain main on this card (#2317, fixed by #2315 + #2322). Nothing new from this PR.

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).

**@⁠qtLkz** on GitHub · 2026-11-25 13:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7163496113) 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 `940d32f` (clean merge). `cargo test -p victory-shader --lib --locked -- --nocapture --test-threads=1` - `emit::lower::tests::lds_accesses_are_bounded_by_the_allocation ... ok` - Whole victory-shader lib, including the hardware + WARP dispatch tests: 245 passed, 3 failed, 3 ignored. The 3 failures (two `stride_tests`, `synthetic_tests::gathers_at_a_level_match_the_hardware`) are the same as on plain main on this card (#2317, fixed by #2315 + #2322). Nothing new from this PR. 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).
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 05:48 UTC · original

@⁠Impre-visible yes, please take lds_out_of_bounds_reads_zero_and_drops_writes from #1870 into this PR. A Co-authored-by line is fine, and thanks for asking. Keeping the lowering and the test in one place makes it easier to review.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 05:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7183822912) @⁠Impre-visible yes, please take `lds_out_of_bounds_reads_zero_and_drops_writes` from #1870 into this PR. A Co-authored-by line is fine, and thanks for asking. Keeping the lowering and the test in one place makes it easier to review.
Author
Owner

@⁠Impre-visible on GitHub · 2026-11-26 05:54 UTC · original

Rebuilt this branch on main 63bcca4. The conflict was in the LDS lowering. #1949 (the patch from #1870, thanks @⁠wwwwwwww3333333) already bounds every LDS access the same way, so I kept main's lowering and dropped ours. Main also already has lds_out_of_bounds_reads_zero_and_drops_writes, so nothing was left to bring over from #1870.

What remains is one test-only commit: a counter of the bounds the lowering emits, and lds_accesses_are_bounded_by_the_allocation, which runs on any host (the device test is Windows-only). If that isn't wanted, this PR can close as superseded by #1949.

Linux: cargo test -p victory-shader --lib, 173 passed, 2 ignored (with main's Windows-only validator calls fenced locally, not committed). Windows target: both CI clippy runs pass.

🤖 Generated with Claude Code

**@⁠Impre-visible** on GitHub · 2026-11-26 05:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7183907999) Rebuilt this branch on `main` 63bcca4. The conflict was in the LDS lowering. #1949 (the patch from #1870, thanks @⁠wwwwwwww3333333) already bounds every LDS access the same way, so I kept main's lowering and dropped ours. Main also already has `lds_out_of_bounds_reads_zero_and_drops_writes`, so nothing was left to bring over from #1870. What remains is one test-only commit: a counter of the bounds the lowering emits, and `lds_accesses_are_bounded_by_the_allocation`, which runs on any host (the device test is Windows-only). If that isn't wanted, this PR can close as superseded by #1949. Linux: `cargo test -p victory-shader --lib`, 173 passed, 2 ignored (with main's Windows-only validator calls fenced locally, not committed). Windows target: both CI clippy runs pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 22:18 UTC · original · reviewed

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.

**@⁠catminou4** on GitHub · 2026-11-24 22:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#pullrequestreview-6048300510) · **reviewed** 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.
Author
Owner

@⁠wwwwwwww3333333 on GitHub · 2026-11-26 08:46 UTC · original

@⁠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): lds_accesses_are_bounded_by_the_allocation and lds_out_of_bounds_reads_zero_and_drops_writes both pass, and the whole victory-shader suite is 303 passed, 0 failed, 3 ignored (main on this machine: 302 passed, 0 failed).

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.

**@⁠wwwwwwww3333333** on GitHub · 2026-11-26 08:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7187011566) @⁠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): `lds_accesses_are_bounded_by_the_allocation` and `lds_out_of_bounds_reads_zero_and_drops_writes` both pass, and the whole `victory-shader` suite is 303 passed, 0 failed, 3 ignored (main on this machine: 302 passed, 0 failed). 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.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1769/head:github-bot/gh-1769'
git switch 'github-bot/gh-1769'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1769'
git switch 'github-bot/gh-1769'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1769'
git switch 'github-bot/gh-1769'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1769'
git switch 'main'
git merge --squash 'github-bot/gh-1769'
git switch 'main'
git merge --ff-only 'github-bot/gh-1769'
git switch 'main'
git merge 'github-bot/gh-1769'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1769
No description provided.