Shaders: DS ops in a program without LDS read 0 and drop writes #1501

Closed
github-bot wants to merge 1 commit from gh-pr/1501/head into gh-pr/1501/base
Owner

@⁠ruvenesh on GitHub · 2026-11-24 18:33 UTC · original
ruvenesh:up/ds-without-lds → main · +181 −3 · 3 files · 1 commits · closed without merging

When a compute or mesh program allocates no LDS, its ds_read*, ds_write* and modelled ds_* atomics now translate instead of failing the whole shader.

  • Reads and returning atomics write 0 to every destination VGPR. read2/read2st64 and b64 to b128 write their full register count, through the same guarded write as the normal path.
  • Writes and non-returning atomics are no-ops, and no LDS array is created.
  • Byte and half accesses, and atomics the lowering does not model, still refuse exactly as they do with LDS.
  • Other stages keep the existing refusal, since their LDS carries ring data this does not model.

Why: on the console an out-of-bounds LDS access reads 0 and drops its write (the rule the in-bounds path's comment already states). A program that allocates no LDS has every access out of bounds, so refusing it was stricter than the hardware.

Tests:

  • emit::ds_without_lds_tests (any host): lowers ds_write/ds_read, read2_b32, read_b128, add_rtn_u32 and add_u32 with and without LDS. Checks that ds_read_u8 and ds_add_f32 still refuse with their usual reasons.
  • valu_tests::ds_ops_without_lds_read_zero_and_drop_writes (Windows, needs an SM 6.6 device or WARP): sets a nonzero address, writes a value there and reads it back, then asserts 0. It passed under vkd3d-proton on an RTX 3060.
  • cargo clippy --workspace --all-targets --locked -- -D warnings (with and without --all-features) and cargo xtask policy pass.
  • Title runs (Proton, RTX 3060): on main, one compute shader is refused with "LDS the program does not allocate". With this change it translates, on main and on a stack of open PRs. Nothing new shows up: the watchdog exit and Xid 109 seen on main appear the same with and without this change, and the stack runs have neither.

Note: #292 also edits Lower::ds. lower.rs merges cleanly with it; only the appended tests in valu_tests.rs would need both kept.

Note: with #189 (Wave64 emulation), s.lds_dwords also counts emulation scratch, so the check here must test the title's own allocation (title_lds_dwords). Whichever lands second needs that one-word change. I've run that combination in the title and can rebase either way.

🤖 Generated with Claude Code

**@⁠ruvenesh** on GitHub · 2026-11-24 18:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1501) `ruvenesh:up/ds-without-lds` → `main` · +181 −3 · 3 files · 1 commits · closed without merging When a compute or mesh program allocates no LDS, its `ds_read*`, `ds_write*` and modelled `ds_*` atomics now translate instead of failing the whole shader. - Reads and returning atomics write 0 to every destination VGPR. read2/read2st64 and b64 to b128 write their full register count, through the same guarded write as the normal path. - Writes and non-returning atomics are no-ops, and no LDS array is created. - Byte and half accesses, and atomics the lowering does not model, still refuse exactly as they do with LDS. - Other stages keep the existing refusal, since their LDS carries ring data this does not model. Why: on the console an out-of-bounds LDS access reads 0 and drops its write (the rule the in-bounds path's comment already states). A program that allocates no LDS has every access out of bounds, so refusing it was stricter than the hardware. Tests: - `emit::ds_without_lds_tests` (any host): lowers ds_write/ds_read, read2_b32, read_b128, add_rtn_u32 and add_u32 with and without LDS. Checks that ds_read_u8 and ds_add_f32 still refuse with their usual reasons. - `valu_tests::ds_ops_without_lds_read_zero_and_drop_writes` (Windows, needs an SM 6.6 device or WARP): sets a nonzero address, writes a value there and reads it back, then asserts 0. It passed under vkd3d-proton on an RTX 3060. - `cargo clippy --workspace --all-targets --locked -- -D warnings` (with and without `--all-features`) and `cargo xtask policy` pass. - Title runs (Proton, RTX 3060): on main, one compute shader is refused with "LDS the program does not allocate". With this change it translates, on main and on a stack of open PRs. Nothing new shows up: the watchdog exit and Xid 109 seen on main appear the same with and without this change, and the stack runs have neither. Note: #292 also edits `Lower::ds`. `lower.rs` merges cleanly with it; only the appended tests in `valu_tests.rs` would need both kept. Note: with #189 (Wave64 emulation), `s.lds_dwords` also counts emulation scratch, so the check here must test the title's own allocation (`title_lds_dwords`). Whichever lands second needs that one-word change. I've run that combination in the title and can rebase either way. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
On the console an out-of-bounds LDS access reads 0 and drops its write. A
compute or mesh program that allocates no LDS has every access out of
bounds, so instead of refusing the whole shader, its ds_read* (including
read2/read2st64 and b64 to b128) and returning atomics write 0 to every
destination VGPR, and writes and non-returning atomics do nothing. The LDS
array is not created. Byte and half accesses and atomics the lowering does
not model still refuse, as they do with LDS. Other stages keep refusing:
their LDS carries ring data this does not model.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:08 +00:00
github-bot closed this pull request 2026-11-26 04:34:08 +00:00
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 18:48 UTC · original

Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at 5b390ef. cargo test -p victory-shader --lib -- --test-threads=1 --nocapture gives 123 passed, 0 failed, 1 ignored. The new ds_without_lds_tests pass, and no hardware test was skipped; the only skips are the four diff_tests that need the console compiler. Limiting this to compute and mesh, which size their own LDS, and keeping the refusal for stages whose LDS carries ring data seems the right scope.

**@⁠marquezinii** on GitHub · 2026-11-24 18:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7141171437) Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at `5b390ef`. `cargo test -p victory-shader --lib -- --test-threads=1 --nocapture` gives 123 passed, 0 failed, 1 ignored. The new `ds_without_lds_tests` pass, and no hardware test was skipped; the only skips are the four `diff_tests` that need the console compiler. Limiting this to compute and mesh, which size their own LDS, and keeping the refusal for stages whose LDS carries ring data seems the right scope.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 20:13 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: no count change against main.

Offline. I merged head 5b390ef onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,724 with this PR.

One program moves from "LDS the program does not allocate" to "an LDS operation".

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 123, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 20:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7143208052) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count change against `main`.** **Offline.** I merged head 5b390ef onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,724 with this PR. One program moves from "LDS the program does not allocate" to "an LDS operation". **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 123, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

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

Closing this. The one program in the title it unblocked (a compute shader refused at a single DS instruction) turns out to stop at a ds_bpermute_b32, which uses the DS crossbar and not LDS memory. #573 lowers that instruction before the LDS-size check, so #573 alone translates it and this change adds nothing for the title. That matches @⁠sinan-cmyk's measurement (no count change). Thanks to @⁠marquezinii and @⁠sinan-cmyk for testing.

**@⁠ruvenesh** on GitHub · 2026-11-25 01:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7149585600) Closing this. The one program in the title it unblocked (a compute shader refused at a single DS instruction) turns out to stop at a `ds_bpermute_b32`, which uses the DS crossbar and not LDS memory. #573 lowers that instruction before the LDS-size check, so #573 alone translates it and this change adds nothing for the title. That matches @⁠sinan-cmyk's measurement (no count change). Thanks to @⁠marquezinii and @⁠sinan-cmyk for testing.
Author
Owner

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

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-shader/src/emit/lower.rs, crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 01:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7149613203) <!-- victory-triage v1 head=5b390eff2c0422a8598160df51fe374b6ece9a1b verdict=needs-rebase at=2026-11-25T01:29:53Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-shader/src/emit/lower.rs`, `crates/victory-shader/src/emit/valu_tests.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_

Pull request closed

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!1501
No description provided.