play: the sampled-slot marks off by default (5-7 ms a frame on an RTX 3090) #4506

Open
Kenzim wants to merge 2 commits from upstream-pr/4506 into main
Kenzim commented 2026-11-30 21:31:49 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kenzim on 2026-11-30T21:31:49Z.


VICTORY_SAMPLED_MARKS=1 is a default of victory play. It adds, at every texture a shader picks from the view heap, a read of the marks' buffer, a compare and an atomic OR behind a waveIsFirstLane guard. This turns it off by default; VICTORY_SAMPLED_MARKS=1 has the marks again.

Measured (RTX 3090, native 2560x1440, no DLSS, ray tracing off, 2026-11-30)

marks on marks off
A recorded frame of the opening, replayed (victory replay --compare --shaders/--shaders-b, same picture) 62.8 ms on the card 52.1 ms
In the title, steady stretch 238-256 s after the world's first frame (~3440 draws) 47.6 ms a frame 40.4 ms
In the title, steady stretch 198-224 s (~1300 draws) 42.3 ms 37.0 ms
Card meter, the title's lists 52.2 ms 40.0 ms

One run each in the title after a warm-up; the two stretches are the same scenes second for second. A later run on main with the marks on again read 37.2 ms where the default (off) read 33 ms.

Where the time goes

839 of the frame's 1231 shaders carry the mark (22,093 atomicBinOp and 20,679 waveIsFirstLane calls over them). From per-pipeline times of the two shader sets, about 6.9 of 8.4 ms is in pipelines with a pixel stage:

  • a pixel program that gains an unordered view loses the automatic early depth test, so the G-buffer material programs shade occluded pixels in full: about 5.4 ms;
  • one that discards loses its early reject: about 2.3 ms;
  • the waveIsFirstLane guard: about 1.5 ms.

The read, compare and rare atomic themselves are cheap. (A version of the marks that forces early depth where that is safe and leaves the discarding programs unmarked measured about +1.4 ms against marks off; it is not in this change.)

What the marks fed

sampled::sampled_lately (the order of uploads of textures picked by index, and first uploads over the room line) and slot eviction by marks (VICTORY_SAMPLED_EVICT, already off by default). Without them every such slot counts as sampled lately.

Checked at the opening's scene cuts, marks on against off: the upload backlog and the volume uploaded in the 65 s after the first cut are alike (peak backlog 7,520-9,815 off against 10,466 on; 15.8-15.9 GB off against 15.5 GB on), so textures do not arrive later without them.

Not measured: cards with little memory, which may want the marks back together with eviction.

Launchers and the shader cache

VICTORY_SAMPLED_MARKS is part of the shader translation's key, so after this change every existing shader cache is translated once more (a preload does it ahead of play).

scripts/play-nvidia.ps1 set the switch to 1 whenever the settings file did not name it, to ask for the translation victory preload makes (#4067). It now sets 0 in that case, the value victory play passes, so a run started from the script (or PLAY_FRAMEGEN.cmd) gets the same translation and the same gain. Thanks to @IRennie74 for catching this in review.

Also in this change

The shader census (VICTORY_SHADER_CENSUS, victory translate) had one count for all wave and quad operations. Its line now ends with calls= and each dx.op function called with its count, which is what showed the marks.

Checks

cargo check --locked -p victory --features diagnostics passes on this branch. cargo xtask policy reports only crates/victory-shader/src/native.rs, which is main's and not touched here.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5574135301 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506). Originally posted by [Kenzim](https://github.com/Kenzim) on 2026-11-30T21:31:49Z. --- `VICTORY_SAMPLED_MARKS=1` is a default of `victory play`. It adds, at every texture a shader picks from the view heap, a read of the marks' buffer, a compare and an atomic OR behind a `waveIsFirstLane` guard. This turns it off by default; `VICTORY_SAMPLED_MARKS=1` has the marks again. ## Measured (RTX 3090, native 2560x1440, no DLSS, ray tracing off, 2026-11-30) | | marks on | marks off | |---|---|---| | A recorded frame of the opening, replayed (`victory replay --compare --shaders/--shaders-b`, same picture) | 62.8 ms on the card | 52.1 ms | | In the title, steady stretch 238-256 s after the world's first frame (~3440 draws) | 47.6 ms a frame | 40.4 ms | | In the title, steady stretch 198-224 s (~1300 draws) | 42.3 ms | 37.0 ms | | Card meter, the title's lists | 52.2 ms | 40.0 ms | One run each in the title after a warm-up; the two stretches are the same scenes second for second. A later run on main with the marks on again read 37.2 ms where the default (off) read 33 ms. ## Where the time goes 839 of the frame's 1231 shaders carry the mark (22,093 `atomicBinOp` and 20,679 `waveIsFirstLane` calls over them). From per-pipeline times of the two shader sets, about 6.9 of 8.4 ms is in pipelines with a pixel stage: - a pixel program that gains an unordered view loses the automatic early depth test, so the G-buffer material programs shade occluded pixels in full: about 5.4 ms; - one that discards loses its early reject: about 2.3 ms; - the `waveIsFirstLane` guard: about 1.5 ms. The read, compare and rare atomic themselves are cheap. (A version of the marks that forces early depth where that is safe and leaves the discarding programs unmarked measured about +1.4 ms against marks off; it is not in this change.) ## What the marks fed `sampled::sampled_lately` (the order of uploads of textures picked by index, and first uploads over the room line) and slot eviction by marks (`VICTORY_SAMPLED_EVICT`, already off by default). Without them every such slot counts as sampled lately. Checked at the opening's scene cuts, marks on against off: the upload backlog and the volume uploaded in the 65 s after the first cut are alike (peak backlog 7,520-9,815 off against 10,466 on; 15.8-15.9 GB off against 15.5 GB on), so textures do not arrive later without them. Not measured: cards with little memory, which may want the marks back together with eviction. ## Launchers and the shader cache `VICTORY_SAMPLED_MARKS` is part of the shader translation's key, so after this change every existing shader cache is translated once more (a preload does it ahead of play). `scripts/play-nvidia.ps1` set the switch to `1` whenever the settings file did not name it, to ask for the translation `victory preload` makes (#4067). It now sets `0` in that case, the value `victory play` passes, so a run started from the script (or `PLAY_FRAMEGEN.cmd`) gets the same translation and the same gain. Thanks to @IRennie74 for catching this in review. ## Also in this change The shader census (`VICTORY_SHADER_CENSUS`, `victory translate`) had one count for all wave and quad operations. Its line now ends with `calls=` and each `dx.op` function called with its count, which is what showed the marks. ## Checks `cargo check --locked -p victory --features diagnostics` passes on this branch. `cargo xtask policy` reports only `crates/victory-shader/src/native.rs`, which is main's and not touched here.
IRennie74 commented 2026-11-30 22:39:03 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by IRennie74 on 2026-11-30T22:39:03Z.


The script launcher still turns the marks on: scripts/play-nvidia.ps1:392 (on main) sets VICTORY_SAMPLED_MARKS=1 whenever the settings file does not name it, beside BVH_MISS and NAN_SCRUB, because the switch is part of the shader translation key (#4067). With only play.rs changed:

  • runs started from play-nvidia.ps1 / PLAY_FRAMEGEN.cmd keep the marks, so they get none of the card time this measures;
  • victory play's own preload now translates with the marks off while a script-launched run asks for them on, so that preloaded cache is not hit and shaders are translated again in play: the stutter #4067 fixed.

Dropping 'VICTORY_SAMPLED_MARKS' from that line (or giving it '0' there) keeps the two in step. A line in the description that the flip changes the translation key would also help: every existing shader cache is translated once more after updating.

On a smaller PC this may matter in the busiest frames: on a Ryzen 5 5600X with an RTX 3060 (Series S, 960x540, DLSS Performance) the card is 34-38 ms of a 55 ms frame standing, but 57-62 ms in frames of 5,000+ draws, where it is the wall. We can A/B it there with the launcher line fixed.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7294125758 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506#issuecomment-7294125758). Originally posted by [IRennie74](https://github.com/IRennie74) on 2026-11-30T22:39:03Z. --- The script launcher still turns the marks on: `scripts/play-nvidia.ps1:392` (on main) sets `VICTORY_SAMPLED_MARKS=1` whenever the settings file does not name it, beside `BVH_MISS` and `NAN_SCRUB`, because the switch is part of the shader translation key (#4067). With only `play.rs` changed: - runs started from `play-nvidia.ps1` / `PLAY_FRAMEGEN.cmd` keep the marks, so they get none of the card time this measures; - `victory play`'s own preload now translates with the marks off while a script-launched run asks for them on, so that preloaded cache is not hit and shaders are translated again in play: the stutter #4067 fixed. Dropping `'VICTORY_SAMPLED_MARKS'` from that line (or giving it `'0'` there) keeps the two in step. A line in the description that the flip changes the translation key would also help: every existing shader cache is translated once more after updating. On a smaller PC this may matter in the busiest frames: on a Ryzen 5 5600X with an RTX 3060 (Series S, 960x540, DLSS Performance) the card is 34-38 ms of a 55 ms frame standing, but 57-62 ms in frames of 5,000+ draws, where it is the wall. We can A/B it there with the launcher line fixed.
Kenzim commented 2026-12-01 10:54:38 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Kenzim on 2026-12-01T10:54:38Z.


Thanks for catching this. It is fixed in the second commit (now 3857efe6): scripts/play-nvidia.ps1 sets VICTORY_SAMPLED_MARKS=0 unless the settings file names it, the same value victory play passes. A launcher run and play's own preload now ask for one translation, and the launcher gets the gain too. The description now says that the switch is part of the translation key, so every existing shader cache is translated once more after updating.

I have also rebased the branch onto main (5fabb46e). It had been cut from the v2026.11.30.03 release line (#4152), which is why it showed 34 files and a conflict. It is now these two commits, four files.

An A/B on the 5600X / 3060 would be very welcome, especially the frames with 5,000+ draws where the card is the limit. With the launcher line fixed, VICTORY_SAMPLED_MARKS=1 in the settings file brings the marks back for the other side.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7308900995 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506#issuecomment-7308900995). Originally posted by [Kenzim](https://github.com/Kenzim) on 2026-12-01T10:54:38Z. --- Thanks for catching this. It is fixed in the second commit (now `3857efe6`): `scripts/play-nvidia.ps1` sets `VICTORY_SAMPLED_MARKS=0` unless the settings file names it, the same value `victory play` passes. A launcher run and play's own preload now ask for one translation, and the launcher gets the gain too. The description now says that the switch is part of the translation key, so every existing shader cache is translated once more after updating. I have also rebased the branch onto `main` (5fabb46e). It had been cut from the v2026.11.30.03 release line (#4152), which is why it showed 34 files and a conflict. It is now these two commits, four files. An A/B on the 5600X / 3060 would be very welcome, especially the frames with 5,000+ draws where the card is the limit. With the launcher line fixed, `VICTORY_SAMPLED_MARKS=1` in the settings file brings the marks back for the other side.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/4506:upstream-pr/4506'
git switch 'upstream-pr/4506'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/4506'
git switch 'upstream-pr/4506'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/4506'
git switch 'upstream-pr/4506'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/4506'
git switch 'main'
git merge --squash 'upstream-pr/4506'
git switch 'main'
git merge --ff-only 'upstream-pr/4506'
git switch 'main'
git merge 'upstream-pr/4506'
git push origin 'main'
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!4506
No description provided.