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

Closed
ruvenesh wants to merge 1 commit from upstream-pr/1501 into main
ruvenesh commented 2026-11-24 18:33:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ruvenesh on 2026-11-24T18:33:11Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588743632 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1501). Originally posted by [ruvenesh](https://github.com/ruvenesh) on 2026-11-24T18:33:11Z. --- 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)
marquezinii commented 2026-11-24 19:04:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by marquezinii on 2026-11-24T18:48:08Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141171437 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7141171437). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T18:48:08Z. --- 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.
sinan-cmyk commented 2026-11-24 21:03:24 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T20:13:12Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143208052 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7143208052). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T20:13:12Z. --- ### 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).
upstream-sync closed this pull request 2026-11-25 02:04:23 +00:00
ruvenesh commented 2026-11-25 02:06:05 +00:00 (Migrated from github.com)

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


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149585600 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7149585600). Originally posted by [ruvenesh](https://github.com/ruvenesh) on 2026-11-25T01:28:25Z. --- 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.
Marvisak commented 2026-11-25 02:06:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7149613203 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1501#issuecomment-7149613203). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T01:29:53Z. --- <!-- 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

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