Shaders: the code table starts after the instructions (RTX 5090 Xid 13, GBs of VRAM on other NVIDIA cards) #550

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

@⁠kibagami-nc on GitHub · 2026-11-28 00:39 UTC · original
kibagami-nc:fix/code-table-after-instructions → main · +50 −6 · 2 files · 1 commits · open

The problem

code_dword (crates/victory-shader/src/emit/lower.rs) turns the program's code into a constant table, starting at the lowest offset any load or descriptor names. A load at a computed offset names offset 0, so the table is the whole program: 4,160 to 4,596 dwords (16 to 18 KiB) in the lighting computes reached at world entry.

NVIDIA's compiler keeps up to 16 KiB of such arrays in constant memory and copies a larger one into every thread's local memory:

  • on an RTX 5090 (GB202) those programs fault: Xid 13, writes to unmapped addresses (fxceless/victory-fork#861);
  • on other cards the driver reserves gigabytes of video memory for it (reported on an RTX 5080 in Marvisak/VIctory#2143).

The change

A program's constants follow its instructions, and a load at a computed offset reads them. So the table now starts where the instructions end, unless a load at a fixed offset reads below that. A computed index below the start is clamped, like one past the end, as before.

Upstream logged 1,149 code-table reads in 114 programs. None of them falls below the new start, and the tables that were 3,200 to 4,600 dwords are now 154 to 177.

This is a port of desplmfao's fix (Marvisak/VIctory#2143, commits 524e2834 and a68ae559), as carried to fxceless/victory-fork#1006. The regression test is in emit's own test module, with code_table_start made pub(super) for it.

The shader cache key (env!("VICTORY_TRANSLATOR")) follows the translator's source, so translations cached with the old tables are made again.

Tests

  • The code-table tests pass (3).
  • cargo test -p victory-shader: 290 passed, 4 ignored.

cargo clippy --workspace -- -D warnings already stops on lints main has (see #425, #265 and #86). This change adds no warning.

No game files, dumps or extracted data are included.

**@⁠kibagami-nc** on GitHub · 2026-11-28 00:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/550) `kibagami-nc:fix/code-table-after-instructions` → `main` · +50 −6 · 2 files · 1 commits · open ## The problem `code_dword` (`crates/victory-shader/src/emit/lower.rs`) turns the program's code into a constant table, starting at the lowest offset any load or descriptor names. A load at a computed offset names offset 0, so the table is the whole program: 4,160 to 4,596 dwords (16 to 18 KiB) in the lighting computes reached at world entry. NVIDIA's compiler keeps up to 16 KiB of such arrays in constant memory and copies a larger one into every thread's local memory: - on an RTX 5090 (GB202) those programs fault: Xid 13, writes to unmapped addresses (fxceless/victory-fork#861); - on other cards the driver reserves gigabytes of video memory for it (reported on an RTX 5080 in Marvisak/VIctory#2143). ## The change A program's constants follow its instructions, and a load at a computed offset reads them. So the table now starts where the instructions end, unless a load at a fixed offset reads below that. A computed index below the start is clamped, like one past the end, as before. Upstream logged 1,149 code-table reads in 114 programs. None of them falls below the new start, and the tables that were 3,200 to 4,600 dwords are now 154 to 177. This is a port of desplmfao's fix (Marvisak/VIctory#2143, commits 524e2834 and a68ae559), as carried to fxceless/victory-fork#1006. The regression test is in emit's own test module, with `code_table_start` made `pub(super)` for it. The shader cache key (`env!("VICTORY_TRANSLATOR")`) follows the translator's source, so translations cached with the old tables are made again. ## Tests - The code-table tests pass (3). - `cargo test -p victory-shader`: 290 passed, 4 ignored. `cargo clippy --workspace -- -D warnings` already stops on lints `main` has (see #425, #265 and #86). This change adds no warning. No game files, dumps or extracted data are included.
The table code_dword reads was the program's code from the lowest offset
any load or descriptor names, and a load at a computed offset names
offset 0: the table was the whole program. Under vkd3d-proton that
constant array becomes a private one; NVIDIA's compiler keeps up to
16 KiB of such arrays in constant memory and copies a larger one into
every thread's local memory. On the RTX 5090 (GB202) the lighting
computes with 16-18 KiB tables fault (Xid 13, writes to unmapped
addresses); on other cards they make the driver reserve GBs of VRAM.

The program's constants follow its instructions, and a load at a
computed offset reads them, so the table now starts where the
instructions end, unless a load at a fixed offset reads below that.

Port of desplmfao's fix (Marvisak/VIctory#2143, 524e2834 and a68ae559),
as carried to fxceless/victory-fork#1006. The regression test is in
emit's own test module, with code_table_start pub(super) for it.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 00:41:19 +00:00
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/550/head:github-bot/gh-550'
git switch 'github-bot/gh-550'

Merge

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