Shaders: the constant table after the instructions can be turned off (VICTORY_CODE_TABLE_AFTER=0) #550
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/550"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T00:39:45Z.
Rebuilt on main (
568c5e5d), after #1880. #1880 (brunofgmag) merged the change this PR carried, on by default: a program's constant table starts after its instructions. Both are ports of desplmfao's Marvisak/VIctory#2143. So this PR is now only the way back:VICTORY_CODE_TABLE_AFTER=0starts the table at the lowest offset any load or descriptor names, as before #1880.KEYEDinshader_cache.rs, now 34 entries), so turning it on or off translates again. #807's test that every translator switch is keyed passes.Why a way back
@Machad3x measured the change in an A/B on an RTX 3080 Ti (comment below, 2026-11-28). Setup: 1440p, DLSS Quality, title ray tracing on, 240 s runs into the prison cell.
That was on the main of 2026-11-28, in a batch with other PRs, so it may not hold on today's main. With the switch, anyone who sees a slow card time can check in one run, without a rebuild.
On the other side, the change got DuckersMcQuack's RTX 5090 under Proton past its Xid 13 (#721). Upstream also measured the VRAM peak fall from 15.9 GB to 12.7 GB on an NVIDIA card (#1880).
One candidate for the extra card time: a computed load below the new start reads the table's last dword (the clamp in
code_dword) instead of the code's bytes. A program that uses such a value as a count would loop longer.Change
crates/victory-shader/src/emit/lower.rs:code_table_after()reads the switch.code_dwordtakes main'scode_table_startwhen the switch is on, andlowestwhen it's off.This PR's earlier copy of the
code_table_starttest is gone: main has the same test (the_code_table_starts_after_the_instructions) from #1880.Tests
cargo test -p victory-shader --locked: 395 passed, 8 ignored, on568c5e5d.cargo test -p victory-gpu --locked --lib shader_cache: 4 passed, includingevery_switch_of_the_translator_is_in_the_key.cargo clippy -p victory-shader -p victory-gpu --all-targets: nothing in the changed lines.Tested by others (earlier form, switch on)
VICTORY_CODE_TABLE_AFTER=1. The picture stayed black, which is #721's other problem.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Machad3x on 2026-11-28T01:57:07Z.
Tested in a batch on an RTX 3080 Ti + Ryzen 7 5700X, 1440p, DLSS Quality, title ray tracing on (VICTORY_BVH_BUILDER=1), 240 s runs into the prison cell scene. Batch: #552, #550, #548, #547, #544.
Regression with this PR on the Series X profile: the card time per frame went from 18-19 ms to 76-224 ms (frame 67-70 ms to 153-308 ms). The picture looked the same. A/B: the same batch with only this PR reverted is back to 18-19 ms. The Series S profile with this PR stayed fast (1-5 ms card time), so the cost seems to depend on the resolution or the shaders used at the Series X settings.
One thing a review noticed: a load at a computed offset that reaches into the instructions now reads the clamped last dword instead of the instruction bytes. If a shader uses such a value as a loop count or a size, that could explain the extra card time.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-28T02:07:19Z.
Thanks @Machad3x for the A/B, that settles it.
With
1ae101bthe shorter table is a switch,VICTORY_CODE_TABLE_AFTER=1, off by default (the same name and default as dkdknight's port). Without it the translation is the same as onmain, so your batch should be back to 18-19 ms on the Series X profile. The switch is in the shader cache's key, so turning it on or off translates again.It stays for the cards the whole-program table hurts (Xid 13 on an RTX 5090, gigabytes of video memory reserved on an RTX 5080). If you find a moment, a Series X run with the switch on and the frame line would tell which part of the frame takes the extra time.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-29T08:27:55Z.
Thank you! An earlier version of this pull request was merged into main with its original commits and is part of v2026.11.29.01, where you are credited. GitHub does not show it as merged because new commits were pushed here after that merge. It stays open so those newer commits can be looked at next.
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by kibagami-nc on 2026-11-29T20:34:53Z.
Closed by GitHub because the branch now points at
a15140a9, which main already has: that earlier head of this PR came in with last night's merges.So main is back to the opt-in form:
VICTORY_CODE_TABLE_AFTER=1turns it on.The later head (
a86b0512, an opt-out on top of #1880's default) no longer applies, so there's nothing left to merge here.For the cards that need it, the switch has to be set:
The v2026.11.29.0x releases have it off by default.
Pull request closed