Shaders: a program's constant table starts after its instructions #1880

Manually merged
github merged 1 commit from github-bot/gh-1880 into gh-pr/1880/base 2026-11-29 02:17:40 +00:00 AGit
Owner

@⁠brunofgmag on GitHub · 2026-11-29 01:24 UTC · original
brunofgmag:pr/code-table-start → main · +61 −6 · 1 files · 1 commits · merged 2026-11-29 02:13 UTC

code_dword built a program's constant table from the lowest byte any load or descriptor named. A load at a computed offset names offset 0, so the table became the whole program, up to 64 KiB, and every thread held those instruction bytes as constants. A program's constants follow its instructions, so the table now starts where the instructions end. A load at a fixed offset below that still keeps the old start.

Upstream measured on an NVIDIA card that the driver reserved several GB of video memory as soon as pipelines were created, and the VRAM peak fell from 15.9 GB to 12.7 GB with this change.

Port of Marvisak/VIctory#2143 by desplmfao, with its test. The new test passes. The two tests that fail in victory-shader and the one clippy lint fail on main as well.

**@⁠brunofgmag** on GitHub · 2026-11-29 01:24 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1880) `brunofgmag:pr/code-table-start` → `main` · +61 −6 · 1 files · 1 commits · merged 2026-11-29 02:13 UTC `code_dword` built a program's constant table from the lowest byte any load or descriptor named. A load at a computed offset names offset 0, so the table became the whole program, up to 64 KiB, and every thread held those instruction bytes as constants. A program's constants follow its instructions, so the table now starts where the instructions end. A load at a fixed offset below that still keeps the old start. Upstream measured on an NVIDIA card that the driver reserved several GB of video memory as soon as pipelines were created, and the VRAM peak fell from 15.9 GB to 12.7 GB with this change. Port of Marvisak/VIctory#2143 by desplmfao, with its test. The new test passes. The two tests that fail in `victory-shader` and the one clippy lint fail on `main` as well.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 01:29:34 +00:00
github-bot changed target branch from main to gh-pr/1880/base 2026-11-29 02:17:38 +00:00
github manually merged commit 179497950d into gh-pr/1880/base 2026-11-29 02:17:40 +00:00
Author
Owner

@⁠kibagami-nc on GitHub · 2026-11-29 02:46 UTC · original

For the record, now that this is on by default: the same change was #550 here (both are ports of desplmfao's Marvisak/VIctory#2143). On 2026-11-28, @⁠Machad3x measured it in an A/B on an RTX 3080 Ti (comment):

  • Series X profile: with the change, the card time per frame went from 18-19 ms to 76-224 ms. The picture was the same, and the same batch with only this change reverted was back at 18-19 ms.
  • Series S profile: fast either way.

That is why #550 had it behind a switch, off by default. In its favour, it got an RTX 5090 under Proton past its Xid 13 (#721), on top of the VRAM figures above.

#550 is now only the way back, with the default left as merged here:

  • The switch: VICTORY_CODE_TABLE_AFTER=0 starts the table at the lowest offset any load names, as before.
  • The cache: the switch is in the shader cache's key, so turning it on or off translates again.

The A/B was on the main of two days ago, in a batch with other PRs, so it may not hold now. @⁠Machad3x, if you have a moment: one Series X run on current main, plus one with VICTORY_CODE_TABLE_AFTER=0 on #550's branch, would show whether the 3080 Ti cost is still there.

**@⁠kibagami-nc** on GitHub · 2026-11-29 02:46 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1880#issuecomment-7249643526) For the record, now that this is on by default: the same change was #550 here (both are ports of desplmfao's Marvisak/VIctory#2143). On 2026-11-28, @⁠Machad3x measured it in an A/B on an RTX 3080 Ti ([comment](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/pulls/550)): - **Series X profile:** with the change, the card time per frame went from 18-19 ms to 76-224 ms. The picture was the same, and the same batch with only this change reverted was back at 18-19 ms. - **Series S profile:** fast either way. That is why #550 had it behind a switch, off by default. In its favour, it got an RTX 5090 under Proton past its Xid 13 ([#721](https://git.gtahub.st/github/trustno1-coder--VIctory-NVIDIA/issues/721)), on top of the VRAM figures above. #550 is now only the way back, with the default left as merged here: - **The switch:** `VICTORY_CODE_TABLE_AFTER=0` starts the table at the lowest offset any load names, as before. - **The cache:** the switch is in the shader cache's key, so turning it on or off translates again. The A/B was on the main of two days ago, in a batch with other PRs, so it may not hold now. @⁠Machad3x, if you have a moment: one Series X run on current main, plus one with `VICTORY_CODE_TABLE_AFTER=0` on #550's branch, would show whether the 3080 Ti cost is still there.
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!1880
No description provided.