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

Open
Impre-visible wants to merge 1 commit from upstream-pr/1769 into main
Impre-visible commented 2026-11-24 22:15:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Impre-visible on 2026-11-24T22:15:15Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:5481231012 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769). Originally posted by [Impre-visible](https://github.com/Impre-visible) on 2026-11-24T22:15:15Z. --- ## 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)
catminou4 commented 2026-11-24 22:18:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T22:18:51Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048300510 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#pullrequestreview-6048300510). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T22:18:51Z. **Review:** COMMENTED --- 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.
DesertGamer commented 2026-11-24 23:05:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T22:16:47Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146032085 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7146032085). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T22:16:47Z. --- ### 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.*
rminzao commented 2026-11-25 00:06:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by rminzao on 2026-11-24T23:09:13Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147074249 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7147074249). Originally posted by [rminzao](https://github.com/rminzao) on 2026-11-24T23:09:13Z. --- **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._
Impre-visible commented 2026-11-25 01:07:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Impre-visible on 2026-11-25T00:17:35Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148356800 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7148356800). Originally posted by [Impre-visible](https://github.com/Impre-visible) on 2026-11-25T00:17:35Z. --- 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)
jules47800 commented 2026-11-25 02:06:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by jules47800 on 2026-11-25T01:25:10Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149525763 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7149525763). Originally posted by [jules47800](https://github.com/jules47800) on 2026-11-25T01:25:10Z. --- 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.
Marvisak commented 2026-11-25 03:03:22 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T02:17:01Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7150530915 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7150530915). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T02:17:01Z. --- <!-- 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)_
Impre-visible commented 2026-11-25 05:06:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Impre-visible on 2026-11-25T05:00:51Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7153368139 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7153368139). Originally posted by [Impre-visible](https://github.com/Impre-visible) on 2026-11-25T05:00:51Z. --- 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)
upipibi commented 2026-11-25 06:02:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T05:45:00Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154102012 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7154102012). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-25T05:45:00Z. --- 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).
Mericas77 commented 2026-11-25 13:02:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Mericas77 on 2026-11-25T12:25:27Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162352807 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7162352807). Originally posted by [Mericas77](https://github.com/Mericas77) on 2026-11-25T12:25:27Z. --- 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.
Impre-visible commented 2026-11-25 13:02:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Impre-visible on 2026-11-25T12:27:58Z.


@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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7162409852 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7162409852). Originally posted by [Impre-visible](https://github.com/Impre-visible) on 2026-11-25T12:27:58Z. --- @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)
qtLkz commented 2026-11-25 14:07:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by qtLkz on 2026-11-25T13:14:41Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7163496113 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7163496113). Originally posted by [qtLkz](https://github.com/qtLkz) on 2026-11-25T13:14:41Z. --- 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).
wwwwwwww3333333 commented 2026-11-26 06:03:48 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T05:48:28Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183822912 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7183822912). Originally posted by [wwwwwwww3333333](https://github.com/wwwwwwww3333333) on 2026-11-26T05:48:28Z. --- @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.
Impre-visible commented 2026-11-26 06:03:50 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Impre-visible on 2026-11-26T05:54:08Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7183907999 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7183907999). Originally posted by [Impre-visible](https://github.com/Impre-visible) on 2026-11-26T05:54:08Z. --- 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)
wwwwwwww3333333 commented 2026-11-26 09:06:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by wwwwwwww3333333 on 2026-11-26T08:46:56Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7187011566 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7187011566). Originally posted by [wwwwwwww3333333](https://github.com/wwwwwwww3333333) on 2026-11-26T08:46:56Z. --- @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.
cloph-dsp commented 2026-11-27 03:32:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-27T03:32:01Z.


Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR, CARGO_BUILD_JOBS=2, no game data).

  • PR head c2ee29a, merge base 63bcca4.
  • cargo test --locked -p victory-shader --lib -- emit::lower::tests::lds_accesses_are_bounded_by_the_allocation --exact --test-threads=1 --quiet -> test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out.
  • git diff --check 63bcca4 HEAD -> exit 0.
  • Negative control: the new test name is absent from 63bcca4 (git grep -c ... crates/victory-shader/src/emit/lower.rs -> exit 1).

Note: the bare test name matches 0 tests; the module-qualified name is required. Only the named synthetic lowering test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only lowering test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209064121 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1769#issuecomment-7209064121). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-27T03:32:01Z. --- Independent CPU-only verification on Windows (Rust 1.100.0/MSVC, worktree-local `CARGO_TARGET_DIR`, `CARGO_BUILD_JOBS=2`, no game data). - PR head `c2ee29a`, merge base `63bcca4`. - `cargo test --locked -p victory-shader --lib -- emit::lower::tests::lds_accesses_are_bounded_by_the_allocation --exact --test-threads=1 --quiet` -> `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 305 filtered out`. - `git diff --check 63bcca4 HEAD` -> exit 0. - Negative control: the new test name is absent from `63bcca4` (`git grep -c ... crates/victory-shader/src/emit/lower.rs` -> exit 1). Note: the bare test name matches 0 tests; the module-qualified name is required. Only the named synthetic lowering test was replayed; the full crate suite was not run. GPU/driver: N/A (CPU-only lowering test). AI-assisted (Hy4 flash). No game data, assets, extracted shaders or DRM involved.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1769:upstream-pr/1769'
git switch 'upstream-pr/1769'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/1769'
git switch 'upstream-pr/1769'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1769'
git switch 'upstream-pr/1769'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1769'
git switch 'main'
git merge --squash 'upstream-pr/1769'
git switch 'main'
git merge --ff-only 'upstream-pr/1769'
git switch 'main'
git merge 'upstream-pr/1769'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1768
No description provided.