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

Open
github-bot wants to merge 2 commits from github-bot/gh-4506 into main AGit
Owner

@⁠Kenzim on GitHub · 2026-11-30 21:31 UTC · original
Kenzim:sampled-marks-off → main · +29 −2 · 4 files · 2 commits · open

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.

**@⁠Kenzim** on GitHub · 2026-11-30 21:31 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506) `Kenzim:sampled-marks-off` → `main` · +29 −2 · 4 files · 2 commits · open `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.
`VICTORY_SAMPLED_MARKS=1` (a default of play) is a read of the marks' buffer, a
compare and an atomic OR at every texture a shader picks from the heap, behind a
`waveIsFirstLane` guard: 839 of a recorded frame's 1231 shaders carry it (22,093
atomicBinOp and 20,679 waveIsFirstLane calls over them).

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

- A recorded frame of the opening, replayed with two translations of its 1231
  containers in one process (`victory replay --compare --shaders/--shaders-b`):
  62.8 ms on the card with the marks, 52.1 ms without, the same picture.
- In the title, one run each after a warm-up, two steady stretches of the
  opening (the same scenes second for second): 47.6 -> 40.4 ms a frame and
  42.3 -> 37.0 ms; the card meter 52.2 -> 40.0 ms in the title's lists. The 1 %
  worst frames and the card's memory in use were alike.
- A later run on today's main with the marks on again read 37.2 ms where the
  default (off) read 33 ms in the same stretches.

Where the time goes (per-pipeline times of the two 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 (the G-buffer material programs then shade
occluded pixels in full: about 5.4 ms), and one that discards loses its early
reject (about 2.3 ms); the `waveIsFirstLane` guard is about 1.5 ms. The read,
compare and rare atomic themselves are cheap.

What the marks fed: `sampled::sampled_lately` (the order of uploads of textures
picked by index, first uploads over the room line) and slot eviction by marks
(`VICTORY_SAMPLED_EVICT`, already off). 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 textures uploaded in the 65 s after the first cut are
alike (peak backlog 7,520-9,815 off, 10,466 on; 15.8-15.9 GB off, 15.5 GB on),
so textures do not arrive later without them.

`VICTORY_SAMPLED_MARKS=1` has them again. Cards with little memory may want
them back with eviction; that was not measured here.

The 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 21:35:07 +00:00
Author
Owner

@⁠IRennie74 on GitHub · 2026-11-30 22:39 UTC · original

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.

**@⁠IRennie74** on GitHub · 2026-11-30 22:39 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506#issuecomment-7294125758) 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.
The script launcher set VICTORY_SAMPLED_MARKS=1 whenever the settings file did
not name it, beside BVH_MISS and NAN_SCRUB, so that it asks for the translation
`victory preload` made (#4067). With play's default now off, a run started from
play-nvidia.ps1 or PLAY_FRAMEGEN.cmd kept the marks (none of the card time
gained) and missed the cache play's own preload made (every shader translated
again in play).

The launcher now sets it to 0 unless the settings file names it, the same value
play passes, so both ask for one translation. Pointed out in review by
IRennie74.

The switch is part of the shader translation's key: after this change every
existing shader cache is translated once more.
github-bot force-pushed github-bot/gh-4506 from 434b10bec4 to 3857efe6bb 2026-12-01 10:58:53 +00:00 Compare
Author
Owner

@⁠Kenzim on GitHub · 2026-12-01 10:54 UTC · original

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.

**@⁠Kenzim** on GitHub · 2026-12-01 10:54 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4506#issuecomment-7308900995) 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 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/4507/head:github-bot/gh-4506'
git switch 'github-bot/gh-4506'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4506'
git switch 'github-bot/gh-4506'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4506'
git switch 'github-bot/gh-4506'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4506'
git switch 'main'
git merge --squash 'github-bot/gh-4506'
git switch 'main'
git merge --ff-only 'github-bot/gh-4506'
git switch 'main'
git merge 'github-bot/gh-4506'
git push origin 'main'
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!4507
No description provided.