Stop scanning the whole shader on every descriptor-load lookup #88

Open
github-bot wants to merge 1 commit from github-bot/gh-88 into a-publier AGit
Owner

@⁠romainhedouin on GitHub · 2026-11-25 13:43 UTC · original
romainhedouin:perf/lower-block-lookups → a-publier · +120 −47 · 1 files · 1 commits · open

Descriptor loads asked every instruction of the shader whether it reads a value, several times per load, so cost grew with loads × program size. After 32 such scans, the readers come from a map built once per shader, and the loaded descriptor leaves are listed once, in order. The functions the original change touched no longer exist on a-publier; this fixes the scans that replaced them.

lower only, synthetic programs (Mac, release, medians) Before After
400 descriptor loads read for a size (twins) 24.0–26.2 ms 4.6 ms
200 such loads 6.9–7.5 ms 2.1 ms
3 such loads 65 µs 66–67 µs
2,000-instruction ALU program, one load 1.41 ms 1.41 ms

Tested: cargo test -p victory-shader --release passes on macOS, and the DXIL of all 17,316 lowerings it runs (the unit tests plus a temporary corpus with 700 descriptor-heavy programs, on both sides of the 32-scan threshold) hashed the same before and after; the Windows GPU tests and the game's shaders.rpf were not run.

🤖 Generated with Claude Code

**@⁠romainhedouin** on GitHub · 2026-11-25 13:43 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/88) `romainhedouin:perf/lower-block-lookups` → `a-publier` · +120 −47 · 1 files · 1 commits · open Descriptor loads asked every instruction of the shader whether it reads a value, several times per load, so cost grew with loads × program size. After 32 such scans, the readers come from a map built once per shader, and the loaded descriptor leaves are listed once, in order. The functions the original change touched no longer exist on `a-publier`; this fixes the scans that replaced them. | `lower` only, synthetic programs (Mac, release, medians) | Before | After | |---|---|---| | 400 descriptor loads read for a size (twins) | 24.0–26.2 ms | 4.6 ms | | 200 such loads | 6.9–7.5 ms | 2.1 ms | | 3 such loads | 65 µs | 66–67 µs | | 2,000-instruction ALU program, one load | 1.41 ms | 1.41 ms | Tested: `cargo test -p victory-shader --release` passes on macOS, and the DXIL of all 17,316 lowerings it runs (the unit tests plus a temporary corpus with 700 descriptor-heavy programs, on both sides of the 32-scan threshold) hashed the same before and after; the Windows GPU tests and the game's `shaders.rpf` were not run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:25 +00:00
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:35 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at 432e92a: cargo test -p victory-shader --lib --locked: 266 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:35 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/88#issuecomment-7168235301) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `432e92a`: `cargo test -p victory-shader --lib --locked`: **266 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Workspace tests only; not run in the title.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:47 UTC · original

Checked against the game's shaders.rpf on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (432e92a) applied to 01aadd1 and its own target dir. victory translate --validate --list --host-lanes 32-64 with a hash of every emitted program's DXIL (a local, uncommitted patch): all 25,623 emitted programs are byte for byte the same as on 01aadd1, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of 01aadd1 give the same hashes, so the comparison is deterministic. cargo test -p victory-shader --lib -- --test-threads=1: 266 passed, 0 failed, 6 ignored. Not run in the game.

(I did not time it: the machine was running other jobs, so the translate times are not comparable.)

**@⁠adrianmjim** on GitHub · 2026-11-25 17:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/88#issuecomment-7170003926) Checked against the game's `shaders.rpf` on an RX 7900 XT (Windows 11 build 26300, dxil.dll 10.0.26100.0), with this PR (`432e92a`) applied to `01aadd1` and its own target dir. `victory translate --validate --list --host-lanes 32-64` with a hash of every emitted program's DXIL (a local, uncommitted patch): **all 25,623 emitted programs are byte for byte the same as on `01aadd1`**, and the counts are unchanged (VS/PS 14,247/14,247, CS 2,682/2,682, MS 8,694 of 8,765). Two runs of `01aadd1` give the same hashes, so the comparison is deterministic. `cargo test -p victory-shader --lib -- --test-threads=1`: 266 passed, 0 failed, 6 ignored. Not run in the game. (I did not time it: the machine was running other jobs, so the translate times are not comparable.)
github-bot changed target branch from main to a-publier 2026-11-27 01:00:46 +00:00
github-bot force-pushed github-bot/gh-88 from 432e92af1d to 2811d41511 2026-11-27 01:00:46 +00:00 Compare
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/88/head:github-bot/gh-88'
git switch 'github-bot/gh-88'

Merge

Merge the changes and update on Forgejo.
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-88'
git switch 'github-bot/gh-88'
git rebase 'a-publier'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-88'
git switch 'github-bot/gh-88'
git rebase 'a-publier'
git switch 'a-publier'
git merge --no-ff 'github-bot/gh-88'
git switch 'a-publier'
git merge --squash 'github-bot/gh-88'
git switch 'a-publier'
git merge --ff-only 'github-bot/gh-88'
git switch 'a-publier'
git merge 'github-bot/gh-88'
git push origin 'a-publier'
This discussion has been locked. Commenting is limited to contributors.
No description provided.