Shaders: a test for LDS accesses outside the program's shared memory #1920

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

@⁠DiosET3RN0 on GitHub · 2026-11-29 02:37 UTC · original
DiosET3RN0:lds-bounds-test → main · +48 −0 · 1 files · 1 commits · open

Follows up on #118 (closed for conflicts; main has had its own LDS bounds since 64d4931, so this does not resend that change). No issue.

What it changes

The LDS bounds in ds (VICTORY_LDS_BOUNDS, on by default) have no test: nothing in the tree runs an LDS access outside the program's shared memory. This adds one, in emit/valu_tests.rs only (+48 lines, no change outside the test).

ds_outside_the_programs_lds_reads_zero_and_drops_writes: one compute program with 512 bytes of LDS writes, reads back and adds (ds_add_rtn_u32) at an address inside (bytes 4 and 508) and outside (512, 0x10000, 0xFFFFFFFC), and returns what it read plus the first and the last dword. Outside it must read 0, leave out the write and the add, and return 0 from the add.

The last dword is in the sum on purpose: a place outside is given as the last dword inside, so a write or an add that was not left out would land there and the first dword would not show it.

The test returns early with VICTORY_LDS_BOUNDS=0. It covers a plain compute program only, not the face programs that are exempt by default nor the mesh programs of #1816.

How it was tested

  • GPU and profile: RTX 4060 8 GB, driver 621.24, Windows 11, Rust 1.98.1. Unit tests on the hardware adapter; no game run (no game files on this machine).
  • Before: main (568c5e5) has no test of this.
  • After: cargo test -p victory-shader --locked --no-fail-fast: 396 passed, 0 failed, 8 ignored, the new test included.
  • Control: with inside made always true in ds (so nothing outside is left out), the new test fails at byte 0x200 with 128 instead of 200: the write landed on the last dword.
  • For shader changes, the wave sizes tested: 32 lanes (the card's; one thread, WaveSize(32), which WARP refuses, so hardware only).
  • cargo test passed for the crates it touches: yes.
  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings stops at main's own lower.rs:2356 (manual checked division, #1855); nothing in valu_tests.rs.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1816 and #1817 change the bound's limit and add no test; #1623, #1538, #978 and others append to valu_tests.rs elsewhere (this one appends at the end of the file).

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠DiosET3RN0** on GitHub · 2026-11-29 02:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1920) `DiosET3RN0:lds-bounds-test` → `main` · +48 −0 · 1 files · 1 commits · open Follows up on #118 (closed for conflicts; `main` has had its own LDS bounds since 64d4931, so this does not resend that change). No issue. ## What it changes The LDS bounds in `ds` (`VICTORY_LDS_BOUNDS`, on by default) have no test: nothing in the tree runs an LDS access outside the program's shared memory. This adds one, in `emit/valu_tests.rs` only (+48 lines, no change outside the test). `ds_outside_the_programs_lds_reads_zero_and_drops_writes`: one compute program with 512 bytes of LDS writes, reads back and adds (`ds_add_rtn_u32`) at an address inside (bytes 4 and 508) and outside (512, 0x10000, 0xFFFFFFFC), and returns what it read plus the first and the last dword. Outside it must read 0, leave out the write and the add, and return 0 from the add. The last dword is in the sum on purpose: a place outside is given as the last dword inside, so a write or an add that was not left out would land there and the first dword would not show it. The test returns early with `VICTORY_LDS_BOUNDS=0`. It covers a plain compute program only, not the face programs that are exempt by default nor the mesh programs of #1816. ## How it was tested - GPU and profile: RTX 4060 8 GB, driver 621.24, Windows 11, Rust 1.98.1. Unit tests on the hardware adapter; no game run (no game files on this machine). - Before: `main` (568c5e5) has no test of this. - After: `cargo test -p victory-shader --locked --no-fail-fast`: 396 passed, 0 failed, 8 ignored, the new test included. - Control: with `inside` made always true in `ds` (so nothing outside is left out), the new test fails at byte 0x200 with 128 instead of 200: the write landed on the last dword. - For shader changes, the wave sizes tested: 32 lanes (the card's; one thread, `WaveSize(32)`, which WARP refuses, so hardware only). - `cargo test` passed for the crates it touches: yes. - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` stops at `main`'s own `lower.rs:2356` (manual checked division, #1855); nothing in `valu_tests.rs`. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1816 and #1817 change the bound's `limit` and add no test; #1623, #1538, #978 and others append to `valu_tests.rs` elsewhere (this one appends at the end of the file). AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The bounds of 64d4931 (VICTORY_LDS_BOUNDS) had no test. One compute
program on the hardware adapter writes, reads back and adds at an
address inside (bytes 4 and 508) and outside (512, 0x10000,
0xFFFFFFFC) its 512 bytes, and sums what it read with the first and
the last dword. The last dword is looked at because a place outside is
given as it: a write or an add that was not left out would land there.

Skipped with VICTORY_LDS_BOUNDS=0. No change outside the test.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 02:39:19 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 03:34 UTC · original · approved these changes

Tested locally merged onto main (568c5e5).

  • Merge: Clean merge in crates/victory-shader/src/emit/valu_tests.rs.
  • Tests (RTX 5090):
    • cargo test -p victory-shader --lib emit::valu_tests::ds_outside_the_programs_lds_reads_zero_and_drops_writes passed (1 passed; 0 failed in 0.40s).
    • cargo test -p victory-shader --lib emit::tests:: passed (23 passed; 0 failed; 1 ignored).

Clean GPU regression test verifying out-of-bounds LDS reads return zero and writes are dropped. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-29 03:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1920#pullrequestreview-6101255136) · **approved these changes** Tested locally merged onto `main` (`568c5e5`). - **Merge**: Clean merge in `crates/victory-shader/src/emit/valu_tests.rs`. - **Tests (RTX 5090)**: - `cargo test -p victory-shader --lib emit::valu_tests::ds_outside_the_programs_lds_reads_zero_and_drops_writes` passed (`1 passed; 0 failed` in 0.40s). - `cargo test -p victory-shader --lib emit::tests::` passed (`23 passed; 0 failed; 1 ignored`). Clean GPU regression test verifying out-of-bounds LDS reads return zero and writes are dropped. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠tupacfan04 on GitHub · 2026-11-29 06:25 UTC · original

Ran this on an RTX 5070 12 GB (driver 621.40, 32-lane waves, Windows 11), cherry-picked onto main e1f2eb6 plus #1939:

test emit::valu_tests::ds_outside_the_programs_lds_reads_zero_and_drops_writes ... ok

Passes here. The expected values check out when worked by hand (inside the memory, the last dword, and outside it), and guarding the last dword against a clamped write is a good catch.

Same note as on #1928: it prints nothing on success, so "ran on the card" is inferred from the missing "skipped" line. A final "ran on the hardware device" print would make that certain. It is also skipped under VICTORY_LDS_BOUNDS=0, which is fine but worth a word in the description.

🤖 Generated with Claude Code

**@⁠tupacfan04** on GitHub · 2026-11-29 06:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1920#issuecomment-7251849560) Ran this on an RTX 5070 12 GB (driver 621.40, 32-lane waves, Windows 11), cherry-picked onto main `e1f2eb6` plus #1939: ``` test emit::valu_tests::ds_outside_the_programs_lds_reads_zero_and_drops_writes ... ok ``` Passes here. The expected values check out when worked by hand (inside the memory, the last dword, and outside it), and guarding the last dword against a clamped write is a good catch. Same note as on #1928: it prints nothing on success, so "ran on the card" is inferred from the missing "skipped" line. A final "ran on the hardware device" print would make that certain. It is also skipped under `VICTORY_LDS_BOUNDS=0`, which is fine but worth a word in the description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/valu_tests.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1920'
git switch 'github-bot/gh-1920'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1920'
git switch 'github-bot/gh-1920'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1920'
git switch 'main'
git merge --squash 'github-bot/gh-1920'
git switch 'main'
git merge --ff-only 'github-bot/gh-1920'
git switch 'main'
git merge 'github-bot/gh-1920'
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/trustno1-coder--VIctory-NVIDIA!1920
No description provided.