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

Merged
brunofgmag merged 1 commit from upstream-pr/1880 into main 2026-11-29 02:13:36 +00:00
brunofgmag commented 2026-11-29 01:24:36 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by brunofgmag on 2026-11-29T01:24:36Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5546409056 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1880). Originally posted by [brunofgmag](https://github.com/brunofgmag) on 2026-11-29T01:24:36Z. --- `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.
kibagami-nc commented 2026-11-29 02:46:56 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-29T02:46:56Z.


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.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7249643526 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1880#issuecomment-7249643526). Originally posted by [kibagami-nc](https://github.com/kibagami-nc) on 2026-11-29T02:46:56Z. --- 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://github.com/trustno1-coder/VIctory-NVIDIA/pull/550#issuecomment-7232026583)): - **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://github.com/trustno1-coder/VIctory-NVIDIA/issues/721#issuecomment-7240458843)), 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.
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
trustno1-coder/VIctory-NVIDIA!1880
No description provided.