Shaders: a test that runs the LDS byte and half forms #1928

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

@⁠DiosET3RN0 on GitHub · 2026-11-29 03:07 UTC · original
DiosET3RN0:lds-subword-test → main · +96 −0 · 1 files · 1 commits · open

No issue. Follows #1920 (same file, same harness).

What it changes

The byte and half forms of the LDS instructions are lowered on a path of their own in ds (a write is two atomics, clear then set; a read shifts and extends; the _d16 reads merge into half of the old register). The tests in emit/lds.rs classify these forms, but none executes one.

This adds ds_bytes_and_halves_keep_their_neighbours_and_extend to emit/valu_tests.rs (+96 lines, the small ds_at encoder included; no change outside the test). It runs all 14 forms on the card: ds_write_b8/b16 and their _d16_hi forms, ds_read_u8/i8/u16/i16, and the six _d16/_d16_hi reads. Each form runs twice, with the place given by the address alone and with an offset in the instruction that is not a whole dword. It checks that a write leaves the bytes beside it, that a read extends by zero or by sign, and that a _d16 read fills one half of its register and keeps the other. The reference is a plain byte model in the test.

Naturally aligned places only, as the lowering takes them to be; what the console does with a half across two dwords is not in the tree, so the test does not go there.

How it was tested

  • GPU and profile: RTX 4060 8 GB, driver 621.24, Windows 11, Rust 1.98.1, on main 568c5e5. Unit test on the hardware adapter; no game run (no game files on this machine).
  • Before: no test executes these forms.
  • After: cargo test -p victory-shader --locked ds_bytes_and_halves: passes (28 programs, about 9 s on the card).
  • Controls, each reverted: with the sign extension of the read made a zero extension the test fails at ds_read_i8; with the write's keep mask left out it fails at ds_write_b8.
  • For shader changes, the wave sizes tested: 32 lanes (one thread with LDS declares WaveSize(32), which WARP refuses, so hardware only; on a machine without a hardware adapter the harness prints "not run").
  • cargo test passed for the crates it touches: yes, for this test; the whole victory-shader suite passed on this card at the same base for #1920 (396 passed).
  • Clippy: main stops at its own lower.rs:2356 (#1855); with that one lint allowed, cargo clippy -p victory-shader --all-targets --locked -- -D warnings reports nothing.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1920 (mine) appends at the end of valu_tests.rs, this one sits beside ds and merges with it cleanly; #1623 inserts after ds_min_max_f32_are_atomic_across_waves, a different place. No open PR tests these forms.

AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

**@⁠DiosET3RN0** on GitHub · 2026-11-29 03:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1928) `DiosET3RN0:lds-subword-test` → `main` · +96 −0 · 1 files · 1 commits · open No issue. Follows #1920 (same file, same harness). ## What it changes The byte and half forms of the LDS instructions are lowered on a path of their own in `ds` (a write is two atomics, clear then set; a read shifts and extends; the `_d16` reads merge into half of the old register). The tests in `emit/lds.rs` classify these forms, but none executes one. This adds `ds_bytes_and_halves_keep_their_neighbours_and_extend` to `emit/valu_tests.rs` (+96 lines, the small `ds_at` encoder included; no change outside the test). It runs all 14 forms on the card: `ds_write_b8`/`b16` and their `_d16_hi` forms, `ds_read_u8`/`i8`/`u16`/`i16`, and the six `_d16`/`_d16_hi` reads. Each form runs twice, with the place given by the address alone and with an offset in the instruction that is not a whole dword. It checks that a write leaves the bytes beside it, that a read extends by zero or by sign, and that a `_d16` read fills one half of its register and keeps the other. The reference is a plain byte model in the test. Naturally aligned places only, as the lowering takes them to be; what the console does with a half across two dwords is not in the tree, so the test does not go there. ## How it was tested - GPU and profile: RTX 4060 8 GB, driver 621.24, Windows 11, Rust 1.98.1, on `main` 568c5e5. Unit test on the hardware adapter; no game run (no game files on this machine). - Before: no test executes these forms. - After: `cargo test -p victory-shader --locked ds_bytes_and_halves`: passes (28 programs, about 9 s on the card). - Controls, each reverted: with the sign extension of the read made a zero extension the test fails at `ds_read_i8`; with the write's keep mask left out it fails at `ds_write_b8`. - For shader changes, the wave sizes tested: 32 lanes (one thread with LDS declares `WaveSize(32)`, which WARP refuses, so hardware only; on a machine without a hardware adapter the harness prints "not run"). - `cargo test` passed for the crates it touches: yes, for this test; the whole `victory-shader` suite passed on this card at the same base for #1920 (396 passed). - Clippy: `main` stops at its own `lower.rs:2356` (#1855); with that one lint allowed, `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` reports nothing. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1920 (mine) appends at the end of `valu_tests.rs`, this one sits beside `ds` and merges with it cleanly; #1623 inserts after `ds_min_max_f32_are_atomic_across_waves`, a different place. No open PR tests these forms. AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The tests in emit/lds.rs classify the byte and half forms of the LDS
instructions, but none executes one: ds_write_b8/b16 and their _d16_hi
forms, ds_read_u8/i8/u16/i16 and the _d16/_d16_hi reads.

Each form runs as a compute program on the hardware adapter, once with
the place given by the address alone and once with an offset in the
instruction that is not a whole dword: a write leaves the bytes beside
it, a read extends by zero or by sign, and a _d16 read fills one half
of its register and keeps the other. Naturally aligned places only, as
the lowering takes them to be.

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 03:12:21 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-29 03:33 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_ -- --test-threads=1 passed (3 passed; 0 failed, including the new ds_bytes_and_halves_keep_their_neighbours_and_extend GPU execution test) with 0 warnings in valu_tests.rs.

Solid hardware execution test covering LDS byte/half writes, neighbor preservation, and sign/zero extension. LGTM.

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

**@⁠Dukestar69** on GitHub · 2026-11-29 03:33 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1928#pullrequestreview-6101253636) · **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_ -- --test-threads=1` passed (`3 passed; 0 failed`, including the new `ds_bytes_and_halves_keep_their_neighbours_and_extend` GPU execution test) with 0 warnings in `valu_tests.rs`. Solid hardware execution test covering LDS byte/half writes, neighbor preservation, and sign/zero extension. 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_bytes_and_halves_keep_their_neighbours_and_extend ... ok

It passes, and it printed no "skipped" line, so I take it that it ran on the card. That is an inference though: unlike the wave tests (#1929 prints "ran on the hardware device: ..."), this one prints nothing on success, so a pass with a hardware run and a pass on a machine that quietly skipped look almost the same in CI output. A one-line "ran on the hardware device" print at the end would settle it.

Reading the test: the 4 write and 10 read forms are covered at aligned places only, which its own comment says. The LDS forms matter to us because three of the ray-tracing structure builder's programs only translate with VICTORY_LDS_LAST_RESORT=1, so more coverage here is welcome.

🤖 Generated with Claude Code

**@⁠tupacfan04** on GitHub · 2026-11-29 06:25 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1928#issuecomment-7251849329) 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_bytes_and_halves_keep_their_neighbours_and_extend ... ok ``` It passes, and it printed no "skipped" line, so I take it that it ran on the card. That is an inference though: unlike the wave tests (#1929 prints "ran on the hardware device: ..."), this one prints nothing on success, so a pass with a hardware run and a pass on a machine that quietly skipped look almost the same in CI output. A one-line "ran on the hardware device" print at the end would settle it. Reading the test: the 4 write and 10 read forms are covered at aligned places only, which its own comment says. The LDS forms matter to us because three of the ray-tracing structure builder's programs only translate with `VICTORY_LDS_LAST_RESORT=1`, so more coverage here is welcome. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠upipibi on GitHub · 2026-11-29 23:07 UTC · original · edited 2026-11-29 23:08 UTC

Test report for #1928 (head cc8d533d), merged onto main 568c5e5d, on RTX 30. Synthetic tests only: no title run, no game files.

Setup: RTX 3070, driver 621.40, Windows 11 (10.0.26100), rustc 1.98.1. Every step logged the GPU and driver from nvidia-smi.

Key test: emit::valu_tests::ds_bytes_and_halves_keep_their_neighbours_and_extend

  • On the card: ok, 3/3 runs (10 to 14 s each).
  • With VICTORY_WARP=1: fails, 3/3, at valu_tests.rs:280: hardware: compute_pipeline failed: The parameter is incorrect. That is the harness failing to make its pipeline on WARP, before any LDS check. Other valu_tests fail the same way on WARP on main here, so I read it as the WARP baseline of this harness, not as something this test adds.

Negative control, and whether it really runs on the card: with the sign-extending shift of the signed byte/half reads in emit/lower.rs changed from arithmetic to logical (signed reads then extend by zero), the test fails on the card at valu_tests.rs:1709: hardware: ds 0x39 +0 at byte 0 of 0xa1b2c3d4, data 0x123485f6, left 212, right 4294967252. So a pass here is a run on the hardware device that compared results, not a quiet skip, which settles the question above for this card. A "ran on the hardware device" line on success would still help in CI output.

cargo test -p victory-shader --lib --locked

Tree Passed Failed Ignored
PR 396 0 8
Main 568c5e5d 395 0 8

The extra test is the PR's own.

Not tested: the PR on today's main, places that are not naturally aligned (the test does not go there), and any effect in a title.

Tested with the help of Claude Code (Claude Fable 5.2).

**@⁠upipibi** on GitHub · 2026-11-29 23:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1928#issuecomment-7264216623) · edited 2026-11-29 23:08 UTC Test report for #1928 (head cc8d533d), merged onto main 568c5e5d, on RTX 30. Synthetic tests only: no title run, no game files. **Setup:** RTX 3070, driver 621.40, Windows 11 (10.0.26100), rustc 1.98.1. Every step logged the GPU and driver from `nvidia-smi`. **Key test:** `emit::valu_tests::ds_bytes_and_halves_keep_their_neighbours_and_extend` - On the card: **ok**, 3/3 runs (10 to 14 s each). - With `VICTORY_WARP=1`: **fails**, 3/3, at `valu_tests.rs:280`: `hardware: compute_pipeline failed: The parameter is incorrect.` That is the harness failing to make its pipeline on WARP, before any LDS check. Other `valu_tests` fail the same way on WARP on main here, so I read it as the WARP baseline of this harness, not as something this test adds. **Negative control, and whether it really runs on the card:** with the sign-extending shift of the signed byte/half reads in `emit/lower.rs` changed from arithmetic to logical (signed reads then extend by zero), the test **fails** on the card at `valu_tests.rs:1709`: `hardware: ds 0x39 +0 at byte 0 of 0xa1b2c3d4, data 0x123485f6`, left 212, right 4294967252. So a pass here is a run on the hardware device that compared results, not a quiet skip, which settles the question above for this card. A "ran on the hardware device" line on success would still help in CI output. **`cargo test -p victory-shader --lib --locked`** | Tree | Passed | Failed | Ignored | |---|---|---|---| | PR | 396 | 0 | 8 | | Main 568c5e5d | 395 | 0 | 8 | The extra test is the PR's own. Not tested: the PR on today's main, places that are not naturally aligned (the test does not go there), and any effect in a title. *Tested with the help of Claude Code (Claude Fable 5.2).*
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/1928/head:github-bot/gh-1928'
git switch 'github-bot/gh-1928'

Merge

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