Pipelines: static samplers are first made in the same order in every launch (the picture no longer depends on who filled the library) #1461

Open
KyleS98 wants to merge 1 commit from upstream-pr/1461 into main
KyleS98 commented 2026-11-27 11:43:10 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-27T11:43:10Z.


Fixes #1459 as far as I can test it: on an NVIDIA card the title's picture depended on which launches had filled the pipeline library.

What

A new crates/victory-gpu/src/pipeline/samplers.rs keeps the order in which the host first sees the different static samplers the same in every launch.

  • The static samplers a cache has seen are listed in static-samplers.txt beside the library, in the order they were first made (ten words a line: filter, three address modes, bias, maximum anisotropy, comparison function, border colour, first and last level).
  • Before a launch's first root signature each listed sampler is made again in that order, alone in a root signature that lives for the whole run.
  • A sampler not listed yet goes to the list's end; its own root signature is made under the same lock, before the root signature that asked for it, so the file's order is the host's.
  • A library with no list beside it was filled in whatever order its launches had. It is let go once (with a log line) and its pipelines are made again.
  • VICTORY_SAMPLER_ORDER=0 turns all of it off.
  • VICTORY_EXTRA_STATIC_SAMPLER=1 (diagnostics builds) makes one more static sampler, unlike the title's own, before the title's first root signature. With the order off that reproduces the issue on a filled library; with the order on it shows the issue gone.

The hook is one call in pipeline::host::root_signature, the only place the title's root signatures are made.

Why this, and what it rests on

What I measured is in #1459: 20 runs of 20 wrong with one more unlike static sampler made early, 0 of 12 without; one build with one set of switches wrong on a library that launches of another configuration had filled, right from an empty one.

What I concluded is a guess about the driver: it numbers a device's different static samplers in the order they are first made, a compiled pipeline names them by number, and a pipeline kept in the library keeps the numbers of the launch that compiled it. I cannot look inside the driver. The test below is what I have for it: with the order kept, the case that was wrong 20 times of 20 is right.

If the guess is wrong in a way this test does not show (numbers given by something other than first use, say), the list would not be enough and the sturdier way would be no static samplers in translated pipelines at all. I have not tried that.

Tested

Unit: three tests in the module (a sampler's line; a list's order and a line cut short; on the host device, a new sampler goes to the file's end and a second start reads the same order back). Clippy is clean with and without diagnostics.

In the game: RTX 3090 Ti, driver 616.92, Windows 11 26200, --console series-s, this branch with #798 merged in (so that this profile's world shows), a cache folder of its own, 360 to 400 s a launch, hands off, the prologue's cell.

launch switches picture
1: no library, no list right: dark hair, an evenly dark wall, the print on the shirt. The list holds the title's 23 samplers
2 VICTORY_EXTRA_STATIC_SAMPLER=1 right. The extra sampler is the list's line 24
3 right
4: control, on a copy of that library VICTORY_SAMPLER_ORDER=0 VICTORY_EXTRA_STATIC_SAMPLER=1 wrong: bright yellow hair, as in the issue

No exception in any of the four.

Limits

  • One card, one driver. I have no AMD or Intel card to say whether they number samplers this way or need none of this; the list costs them a few empty root signatures at start.
  • The first launch after this lands makes every pipeline again, because the old library is let go. On a cold library that is minutes of dropped draws, as after any driver change.
  • Two launches at once on one cache folder could write the list in two orders. I have not guarded against that.
  • Frame rate: not compared. The call is one lock per root signature made (about 2,000 in a run to the cell), none per frame.

AI-assisted (Claude Code, Claude Fable 5.2); runs and grabs on my machine; no game data in the change.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5526037753 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1461). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-27T11:43:10Z. --- Fixes #1459 as far as I can test it: on an NVIDIA card the title's picture depended on which launches had filled the pipeline library. ## What A new `crates/victory-gpu/src/pipeline/samplers.rs` keeps the order in which the host first sees the different static samplers the same in every launch. - The static samplers a cache has seen are listed in `static-samplers.txt` beside the library, in the order they were first made (ten words a line: filter, three address modes, bias, maximum anisotropy, comparison function, border colour, first and last level). - Before a launch's first root signature each listed sampler is made again in that order, alone in a root signature that lives for the whole run. - A sampler not listed yet goes to the list's end; its own root signature is made under the same lock, before the root signature that asked for it, so the file's order is the host's. - A library with no list beside it was filled in whatever order its launches had. It is let go once (with a log line) and its pipelines are made again. - `VICTORY_SAMPLER_ORDER=0` turns all of it off. - `VICTORY_EXTRA_STATIC_SAMPLER=1` (diagnostics builds) makes one more static sampler, unlike the title's own, before the title's first root signature. With the order off that reproduces the issue on a filled library; with the order on it shows the issue gone. The hook is one call in `pipeline::host::root_signature`, the only place the title's root signatures are made. ## Why this, and what it rests on What I measured is in #1459: 20 runs of 20 wrong with one more unlike static sampler made early, 0 of 12 without; one build with one set of switches wrong on a library that launches of another configuration had filled, right from an empty one. What I concluded is a guess about the driver: it numbers a device's different static samplers in the order they are first made, a compiled pipeline names them by number, and a pipeline kept in the library keeps the numbers of the launch that compiled it. I cannot look inside the driver. The test below is what I have for it: with the order kept, the case that was wrong 20 times of 20 is right. If the guess is wrong in a way this test does not show (numbers given by something other than first use, say), the list would not be enough and the sturdier way would be no static samplers in translated pipelines at all. I have not tried that. ## Tested Unit: three tests in the module (a sampler's line; a list's order and a line cut short; on the host device, a new sampler goes to the file's end and a second start reads the same order back). Clippy is clean with and without `diagnostics`. In the game: RTX 3090 Ti, driver 616.92, Windows 11 26200, `--console series-s`, this branch with #798 merged in (so that this profile's world shows), a cache folder of its own, 360 to 400 s a launch, hands off, the prologue's cell. | launch | switches | picture | |---|---|---| | 1: no library, no list | | right: dark hair, an evenly dark wall, the print on the shirt. The list holds the title's 23 samplers | | 2 | `VICTORY_EXTRA_STATIC_SAMPLER=1` | right. The extra sampler is the list's line 24 | | 3 | | right | | 4: control, on a copy of that library | `VICTORY_SAMPLER_ORDER=0 VICTORY_EXTRA_STATIC_SAMPLER=1` | wrong: bright yellow hair, as in the issue | No exception in any of the four. ## Limits - One card, one driver. I have no AMD or Intel card to say whether they number samplers this way or need none of this; the list costs them a few empty root signatures at start. - The first launch after this lands makes every pipeline again, because the old library is let go. On a cold library that is minutes of dropped draws, as after any driver change. - Two launches at once on one cache folder could write the list in two orders. I have not guarded against that. - Frame rate: not compared. The call is one lock per root signature made (about 2,000 in a run to the cell), none per frame. AI-assisted (Claude Code, Claude Fable 5.2); runs and grabs on my machine; no game data in the change.
Filip722 commented 2026-11-27 11:54:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by Filip722 on 2026-11-27T11:54:05Z.


I tested the static-sampler ordering mechanism in the NVIDIA fork's standalone SM 6.6 3D LUT probe on an RTX 5060 Laptop GPU (8 GiB), Bazzite 44, driver 615.78.08, GE-Proton11-14, and vkd3d-proton 3.2.0 (cae8353ed7959c4+). The synthetic shaders and sampler settings were kept. The fixture used signed DXC and the null/zero native library call from #885. I disabled vkd3d's internal shader disk cache and used the same immutable explicit library blob in the load arms.

Three fresh processes stored a pipeline, loaded it, and loaded it after creating ten unrelated static samplers. Both load arms logged that the native library supplied the pipeline. All 64 RGB readbacks matched across the three arms at the printed precision, with maximum error 0.0003 against linear interpolation. This covers the synthetic ordering mechanism on that Proton stack. The reported Windows title result uses a different driver path and workload.

One migration interaction on Proton is independently reproducible. When an unlisted old cache is discarded, creating the new native library needs the null/zero call from #885 on this vkd3d build. The empty-slice call rejects it at creation.

Assisted by Codex (GPT-6.2-Sol High).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7217605578 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1461#issuecomment-7217605578). Originally posted by [Filip722](https://github.com/Filip722) on 2026-11-27T11:54:05Z. --- I tested the static-sampler ordering mechanism in the NVIDIA fork's standalone SM 6.6 3D LUT probe on an RTX 5060 Laptop GPU (8 GiB), Bazzite 44, driver 615.78.08, GE-Proton11-14, and vkd3d-proton 3.2.0 (`cae8353ed7959c4+`). The synthetic shaders and sampler settings were kept. The fixture used signed DXC and the null/zero native library call from #885. I disabled vkd3d's internal shader disk cache and used the same immutable explicit library blob in the load arms. Three fresh processes stored a pipeline, loaded it, and loaded it after creating ten unrelated static samplers. Both load arms logged that the native library supplied the pipeline. All 64 RGB readbacks matched across the three arms at the printed precision, with maximum error 0.0003 against linear interpolation. This covers the synthetic ordering mechanism on that Proton stack. The reported Windows title result uses a different driver path and workload. One migration interaction on Proton is independently reproducible. When an unlisted old cache is discarded, creating the new native library needs the null/zero call from #885 on this vkd3d build. The empty-slice call rejects it at creation. Assisted by Codex (GPT-6.2-Sol High).
KyleS98 commented 2026-11-27 12:35:07 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by KyleS98 on 2026-11-27T12:35:07Z.


@Filip722 thank you, that is an arm I could not run. So on Proton with vkd3d-proton a stored pipeline does not pick up the order of the static samplers made before it is loaded: 64 of 64 readbacks equal after ten unrelated samplers. The fault in #1459 is then one of NVIDIA's Windows driver behind the native pipeline library, as far as the two results go together, and on your stack this change only costs the list's few root signatures at start.

On the migration: main makes its library from an empty slice whenever there is no file (open with no bytes: "no host pipeline library yet; starting an empty one"), so a first launch on a fresh cache folder meets the same refusal on that vkd3d build with or without this PR. What this PR adds is that an existing cache is put into that state once. Your #885 covers both.

If the maintainers would rather not let a library go on stacks where the order does no harm, the discard can go behind a switch of its own or be left out under Wine. I have not done either, because I have no such stack to test it on.

AI-assisted (Claude Code, Claude Fable 5.2).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7218425204 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1461#issuecomment-7218425204). Originally posted by [KyleS98](https://github.com/KyleS98) on 2026-11-27T12:35:07Z. --- @Filip722 thank you, that is an arm I could not run. So on Proton with vkd3d-proton a stored pipeline does not pick up the order of the static samplers made before it is loaded: 64 of 64 readbacks equal after ten unrelated samplers. The fault in #1459 is then one of NVIDIA's Windows driver behind the native pipeline library, as far as the two results go together, and on your stack this change only costs the list's few root signatures at start. On the migration: `main` makes its library from an empty slice whenever there is no file (`open` with no bytes: "no host pipeline library yet; starting an empty one"), so a first launch on a fresh cache folder meets the same refusal on that vkd3d build with or without this PR. What this PR adds is that an existing cache is put into that state once. Your #885 covers both. If the maintainers would rather not let a library go on stacks where the order does no harm, the discard can go behind a switch of its own or be left out under Wine. I have not done either, because I have no such stack to test it on. AI-assisted (Claude Code, Claude Fable 5.2).
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/1461:upstream-pr/1461'
git switch 'upstream-pr/1461'

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/1461'
git switch 'upstream-pr/1461'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1461'
git switch 'upstream-pr/1461'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1461'
git switch 'main'
git merge --squash 'upstream-pr/1461'
git switch 'main'
git merge --ff-only 'upstream-pr/1461'
git switch 'main'
git merge 'upstream-pr/1461'
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
fxceless/victory-fork!1461
No description provided.