Static samplers: a compute pipeline per sampler, so the driver meets them in one order under vkd3d-proton's descriptor heap too #562

Open
jensmonne wants to merge 1 commit from jensmonne/Darner:pr/static-samplers-heap into Main
Contributor

Contributor role (optional)

  • Fluxer ID: 1577631603876691968

What it changes

  • The problem on main: under Proton, starts whose driver cache should hold every pipeline compile them all again. In an empty driver cache, a start that compiled its ~5,000 pipelines (3.5 minutes until none were left) was followed by one that began with 6,686 being made and added another 110 MB to the cache.

samplers.rs makes every static sampler in one order at the start of each process, in root signatures of their own, because the NVIDIA driver keeps a pipeline's samplers by their places in its table, and its cache finds a pipeline again only where those places are the same. Under vkd3d-proton 3.2, which turns on VK_EXT_descriptor_heap by default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (pEmbeddedSampler in libs/vkd3d/state.c). The driver then meets them in the order the pipeline threads compile, which differs from run to run, and the root signatures made at the start fix nothing.

This gives each sampler's root signature a texture (t0) and a buffer (u0) and, beside it, a compute pipeline whose shader samples through the sampler (SampleLevel, or SampleCmpLevelZero for a comparing filter). They are made in the list's order where the root signatures are, under the same lock, and kept as long as the process, so the driver meets every sampler in the list's order again. The shader is compiled once, with hlsl::compile_for (cs_5_1). If it cannot be compiled or a pipeline is not made, that is logged and the sampler keeps only its root signature, as before. DARNER_SAMPLER_PSO=0 leaves the pipelines out. The README gets a row for it, below DARNER_SAMPLER_ORDER.

How it was tested

  • Tested revision: 2b049a1 (this branch, on main c8258f9) for the commands below; 29ae0b6 adds only the README row (cargo xtask policy again: 576 files ok). The game runs used d730e29, the same commit without the new test, and f72d350, the same change on f3840d7 (v2026.12.03.02).

  • Commands and results (cross-built on Linux with cargo xwin, target x86_64-pc-windows-msvc, rustc 1.98.1; tests run under Proton Experimental 11.0-20261123b's Wine with its vkd3d-proton and DXVK DLLs):

    • cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.
    • cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings: clean.
    • cargo xtask policy: "asset policy: 576 files ok".
    • darner-gpu lib tests filtered to pipeline::samplers, under Wine on the RTX 5080: 2 passed, twice. The new each_sampler_gets_a_pipeline_that_samples_through_it makes the root signature and the pipeline for a linear and for a comparing sampler; with DARNER_SAMPLER_PSO=0 it fails ("no pipeline for ..."), as it should.
    • Filtered to pipeline::library: 33 passed, 1 failed (a_rebuilt_library_holds_the_pipelines_it_was_given); the same on main c8258f9.
  • Changes a default: yes, for every setup: 29 small compute pipelines (one per static sampler in the list here) are made at the start of each process. Under Proton with the descriptor heap on, this is what makes the driver's cache work across starts.

  • A/B result: RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b (vkd3d-proton with VK_EXT_descriptor_heap on, its default), each pair in an empty driver cache folder, the same save and scripted walk. "Start A" ran until no pipeline was left to make; "start B" followed it.

    A (without this change) B (with it)
    start B: pipelines being made at its first frame line 6,686 0 (twice: f72d350, d730e29)
    start B: driver cache growth +110 MB +0 MB
    full walk (about 6 minutes in the world), median fps 26.6 28.3
    full walk, 10th percentile fps 23.9 24.6
    full walk, seconds below 5 fps 7 0
    full walk, time until no pipeline was left to make 1 min 43 s 0

    One run each for the full walks. The "without" walk used a driver cache filled by many earlier starts, the "with" walk one filled by a single start; the frame-rate difference comes mostly from the start no longer compiling. After a fresh darner warm (16,029 pipelines) with this change, the next start had nothing to make.
    For comparison, the same walks with VKD3D_CONFIG=no_descriptor_heap (which also fixes the cache, as the samplers then come with the root signatures): median 26.7 and 26.0, 10th percentile 20.3 and 21.1, 0 s below 5 fps, nothing to make at the start.

  • Gates run on that revision: 1 and 2 (the two clippy commands above). Gate 3 (cargo test --workspace) was not run: only the filtered tests above, under Wine.

  • Gameplay: as above; RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b, Series X profile, 2560x1440, DLSS Super Resolution at the quality scale, frame generation off, ray tracing off, uncapped, plus my local Linux patches that are not part of this PR (64 MB pipeline worker stacks, a guard for driver compiler crashes, refusing pipelines in warm-bad.txt (#365), two input helpers for scripted runs).

  • Shader wave sizes tested: not applicable (no translator change).

  • Hardware dependence: tested only on NVIDIA under Proton. On Windows the root signatures already give the driver the samplers; there the pipelines are 29 more compute pipelines at the start, whose cost I have not measured. Whether other drivers keep embedded samplers by place I do not know.

  • Coverage gaps: not run on Windows, not on AMD or Intel. Gate 3 was not run in full. One run per full walk.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only).
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: none of the 183 open pull requests changes crates/darner-gpu/src/pipeline/samplers.rs. #298 (an RTX 5090 hang under Proton) lists no_descriptor_heap among the vkd3d settings its reporter tried; a different problem.
  • Replaces or overlaps: none found (searched open and closed issues and pull requests for static sampler, descriptor heap, descriptor_heap, no_descriptor_heap, compiled again, recompile).
## Contributor role (optional) - Fluxer ID: 1577631603876691968 ## What it changes - The problem on main: under Proton, starts whose driver cache should hold every pipeline compile them all again. In an empty driver cache, a start that compiled its ~5,000 pipelines (3.5 minutes until none were left) was followed by one that began with 6,686 being made and added another 110 MB to the cache. `samplers.rs` makes every static sampler in one order at the start of each process, in root signatures of their own, because the NVIDIA driver keeps a pipeline's samplers by their places in its table, and its cache finds a pipeline again only where those places are the same. Under vkd3d-proton 3.2, which turns on `VK_EXT_descriptor_heap` by default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (`pEmbeddedSampler` in `libs/vkd3d/state.c`). The driver then meets them in the order the pipeline threads compile, which differs from run to run, and the root signatures made at the start fix nothing. This gives each sampler's root signature a texture (t0) and a buffer (u0) and, beside it, a compute pipeline whose shader samples through the sampler (`SampleLevel`, or `SampleCmpLevelZero` for a comparing filter). They are made in the list's order where the root signatures are, under the same lock, and kept as long as the process, so the driver meets every sampler in the list's order again. The shader is compiled once, with `hlsl::compile_for` (`cs_5_1`). If it cannot be compiled or a pipeline is not made, that is logged and the sampler keeps only its root signature, as before. `DARNER_SAMPLER_PSO=0` leaves the pipelines out. The README gets a row for it, below `DARNER_SAMPLER_ORDER`. ## How it was tested - Tested revision: 2b049a1 (this branch, on main c8258f9) for the commands below; 29ae0b6 adds only the README row (`cargo xtask policy` again: 576 files ok). The game runs used d730e29, the same commit without the new test, and f72d350, the same change on f3840d7 (v2026.12.03.02). - Commands and results (cross-built on Linux with `cargo xwin`, target `x86_64-pc-windows-msvc`, rustc 1.98.1; tests run under Proton Experimental 11.0-20261123b's Wine with its vkd3d-proton and DXVK DLLs): - `cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings`: clean. - `cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings`: clean. - `cargo xtask policy`: "asset policy: 576 files ok". - `darner-gpu` lib tests filtered to `pipeline::samplers`, under Wine on the RTX 5080: 2 passed, twice. The new `each_sampler_gets_a_pipeline_that_samples_through_it` makes the root signature and the pipeline for a linear and for a comparing sampler; with `DARNER_SAMPLER_PSO=0` it fails ("no pipeline for ..."), as it should. - Filtered to `pipeline::library`: 33 passed, 1 failed (`a_rebuilt_library_holds_the_pipelines_it_was_given`); the same on main c8258f9. - Changes a default: yes, for every setup: 29 small compute pipelines (one per static sampler in the list here) are made at the start of each process. Under Proton with the descriptor heap on, this is what makes the driver's cache work across starts. - A/B result: RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b (vkd3d-proton with `VK_EXT_descriptor_heap` on, its default), each pair in an empty driver cache folder, the same save and scripted walk. "Start A" ran until no pipeline was left to make; "start B" followed it. | | A (without this change) | B (with it) | |---|---|---| | start B: pipelines being made at its first frame line | 6,686 | 0 (twice: f72d350, d730e29) | | start B: driver cache growth | +110 MB | +0 MB | | full walk (about 6 minutes in the world), median fps | 26.6 | 28.3 | | full walk, 10th percentile fps | 23.9 | 24.6 | | full walk, seconds below 5 fps | 7 | 0 | | full walk, time until no pipeline was left to make | 1 min 43 s | 0 | One run each for the full walks. The "without" walk used a driver cache filled by many earlier starts, the "with" walk one filled by a single start; the frame-rate difference comes mostly from the start no longer compiling. After a fresh `darner warm` (16,029 pipelines) with this change, the next start had nothing to make. For comparison, the same walks with `VKD3D_CONFIG=no_descriptor_heap` (which also fixes the cache, as the samplers then come with the root signatures): median 26.7 and 26.0, 10th percentile 20.3 and 21.1, 0 s below 5 fps, nothing to make at the start. - Gates run on that revision: 1 and 2 (the two clippy commands above). Gate 3 (`cargo test --workspace`) was not run: only the filtered tests above, under Wine. - Gameplay: as above; RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b, Series X profile, 2560x1440, DLSS Super Resolution at the quality scale, frame generation off, ray tracing off, uncapped, plus my local Linux patches that are not part of this PR (64 MB pipeline worker stacks, a guard for driver compiler crashes, refusing pipelines in `warm-bad.txt` (#365), two input helpers for scripted runs). - Shader wave sizes tested: not applicable (no translator change). - Hardware dependence: tested only on NVIDIA under Proton. On Windows the root signatures already give the driver the samplers; there the pipelines are 29 more compute pipelines at the start, whose cost I have not measured. Whether other drivers keep embedded samplers by place I do not know. - Coverage gaps: not run on Windows, not on AMD or Intel. Gate 3 was not run in full. One run per full walk. ## Checklist - [x] I ran this change in the game, or say below why it can't be (docs, tests only). - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: none of the 183 open pull requests changes `crates/darner-gpu/src/pipeline/samplers.rs`. #298 (an RTX 5090 hang under Proton) lists `no_descriptor_heap` among the vkd3d settings its reporter tried; a different problem. - Replaces or overlaps: none found (searched open and closed issues and pull requests for static sampler, descriptor heap, descriptor_heap, no_descriptor_heap, compiled again, recompile).
Contributor

One measurement detail for the native Windows cost at 29ae0b6c. host.rs:2314 calls samplers::prime before DARNER_DRIVER_CACHE=0 is applied (host.rs:2334–2349). A fresh Darner directory by itself also has no samplers to prime. An A/B using that switch and a completely empty directory would therefore miss the intended cold-priming measurement.

For the incremental cost with the driver cache left in its normal state, a small control would be plain darner warm in new processes on the same adapter and the same PR executable. Give each isolated DARNER_CACHE_DIR an identical synthetic pipelines/static-samplers.txt and no known pipelines, keep DARNER_SAMPLER_ORDER=1, and vary only DARNER_SAMPLER_PSO=0/1. warm opens the host for the fingerprint even with zero known title pipelines. Time the priming section, and count successful PSOs separately from accepted root signatures since the fallback can keep the latter. This also separates the per-process preparation from the Proton cache-hit benefit already measured here. I confirmed the call order by source review and have no Windows timing for this head.

Reviewed with Codex and Claude Code.

One measurement detail for the native Windows cost at `29ae0b6c`. `host.rs:2314` calls `samplers::prime` before `DARNER_DRIVER_CACHE=0` is applied (`host.rs:2334–2349`). A fresh Darner directory by itself also has no samplers to prime. An A/B using that switch and a completely empty directory would therefore miss the intended cold-priming measurement. For the incremental cost with the driver cache left in its normal state, a small control would be plain `darner warm` in new processes on the same adapter and the same PR executable. Give each isolated `DARNER_CACHE_DIR` an identical synthetic `pipelines/static-samplers.txt` and no known pipelines, keep `DARNER_SAMPLER_ORDER=1`, and vary only `DARNER_SAMPLER_PSO=0/1`. `warm` opens the host for the fingerprint even with zero known title pipelines. Time the priming section, and count successful PSOs separately from accepted root signatures since the fallback can keep the latter. This also separates the per-process preparation from the Proton cache-hit benefit already measured here. I confirmed the call order by source review and have no Windows timing for this head. Reviewed with Codex and Claude Code.
Author
Contributor

Thanks, I ran that control, on Proton only (no Windows here).

Setup: 29ae0b6 plus two local timing lines (around sync in prime, and around the shaders' compile), not part of this PR. Each run is a new darner warm process with its own empty DARNER_CACHE_DIR holding only the same pipelines/static-samplers.txt (29 samplers) and no known pipelines, DARNER_SAMPLER_ORDER=1, and only DARNER_SAMPLER_PSO changed, alternating 0 and 1. RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b (vkd3d-proton with VK_EXT_descriptor_heap on).

priming (sync in prime) DARNER_SAMPLER_PSO=0 DARNER_SAMPLER_PSO=1
NVIDIA disk cache filled, 6 runs each 0.62-0.72 ms 113.8-118.9 ms
NVIDIA disk cache empty every run, 4 runs each 0.59-0.81 ms 115.1-118.2 ms
vkd3d-proton's shader cache on as well, 5 runs each 0.61-0.75 ms 110.9-116.2 ms
root signatures accepted / pipelines made 29 / 0 29 / 29 (every run)

Of the ~115 ms, compiling the two shaders takes 1.6-2.0 ms (once per process, 4 runs); the rest is the 29 CreateComputePipelineState calls, about 3.9 ms each under vkd3d-proton, and neither the driver's disk cache nor vkd3d-proton's own cache shortens them. So on Proton the change costs about 115 ms once per process that opens the device; Darner's own start takes far longer, and a start that finds the driver cache saves minutes of compiling. I still have no Windows timing for this head.

Thanks, I ran that control, on Proton only (no Windows here). Setup: 29ae0b6 plus two local timing lines (around `sync` in `prime`, and around the shaders' compile), not part of this PR. Each run is a new `darner warm` process with its own empty `DARNER_CACHE_DIR` holding only the same `pipelines/static-samplers.txt` (29 samplers) and no known pipelines, `DARNER_SAMPLER_ORDER=1`, and only `DARNER_SAMPLER_PSO` changed, alternating 0 and 1. RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b (vkd3d-proton with `VK_EXT_descriptor_heap` on). | priming (`sync` in `prime`) | `DARNER_SAMPLER_PSO=0` | `DARNER_SAMPLER_PSO=1` | |---|---|---| | NVIDIA disk cache filled, 6 runs each | 0.62-0.72 ms | 113.8-118.9 ms | | NVIDIA disk cache empty every run, 4 runs each | 0.59-0.81 ms | 115.1-118.2 ms | | vkd3d-proton's shader cache on as well, 5 runs each | 0.61-0.75 ms | 110.9-116.2 ms | | root signatures accepted / pipelines made | 29 / 0 | 29 / 29 (every run) | Of the ~115 ms, compiling the two shaders takes 1.6-2.0 ms (once per process, 4 runs); the rest is the 29 `CreateComputePipelineState` calls, about 3.9 ms each under vkd3d-proton, and neither the driver's disk cache nor vkd3d-proton's own cache shortens them. So on Proton the change costs about 115 ms once per process that opens the device; Darner's own start takes far longer, and a start that finds the driver cache saves minutes of compiling. I still have no Windows timing for this head.
Contributor

Native Windows sampler cost at 29ae0b6 on an RTX 4060 (621.40). The synthetic fixture timed the existing sync(device, &[]) in samplers::prime on a new D3D12 device process with a fresh temporary list of 29 samplers. Each run checked the physical adapter and that all 29 signatures were accepted.

DARNER_SAMPLER_PSO PSOs created Processes Median Range
0 0 8 2.12 ms 1.77–5.24 ms
1 29 8 16.64 ms 13.51–20.28 ms

I alternated A/B/B/A and then B/A/A/B in fresh processes, with the normal driver cache left in place. The initial warm-up pair outside the table was 9.43/158.13 ms. This is the initialization region in an unoptimized native build with a project-owned test list.

cargo test --locked --offline -p darner-gpu --lib pipeline::samplers::tests::native_sampler_prime_cost -- --exact --ignored --nocapture

Native Windows sampler cost at `29ae0b6` on an RTX 4060 (621.40). The [synthetic fixture](https://git.gtahub.st/tyr0nsur/Darner/commit/b8a775d7fa93c03c32fb875e3e01603d36764d07) timed the existing `sync(device, &[])` in `samplers::prime` on a new D3D12 device process with a fresh temporary list of 29 samplers. Each run checked the physical adapter and that all 29 signatures were accepted. | `DARNER_SAMPLER_PSO` | PSOs created | Processes | Median | Range | |---|---:|---:|---:|---:| | `0` | 0 | 8 | 2.12 ms | 1.77–5.24 ms | | `1` | 29 | 8 | 16.64 ms | 13.51–20.28 ms | I alternated A/B/B/A and then B/A/A/B in fresh processes, with the normal driver cache left in place. The initial warm-up pair outside the table was 9.43/158.13 ms. This is the initialization region in an unoptimized native build with a project-owned test list. `cargo test --locked --offline -p darner-gpu --lib pipeline::samplers::tests::native_sampler_prime_cost -- --exact --ignored --nocapture`
TrustNo1 changed title from [pr-fix][shaders][NVIDIA][linux-proton] Static samplers: a compute pipeline per sampler, so the driver meets them in one order under vkd3d-proton's descriptor heap too to Static samplers: a compute pipeline per sampler, so the driver meets them in one order under vkd3d-proton's descriptor heap too 2026-12-06 03:27:03 +00:00
Owner

Test needed — commit 29ae0b6c; what to check:

  • The problem on main: under Proton, starts whose driver cache should hold every pipeline compile them all again. In an empty driver cache, a start that compiled its ~5,000 pipelines (3.5 minutes until none were left) was followed by one that began with 6,686 being made and added another 110 MB to the cache.

samplers.rs makes every static sampler in one order at the start of each process, in root signatures of their own, because the NVIDIA driver keeps a pipeline's samplers by their places in its table, and its cache finds a pipeline again only where those places are the same. Under vkd3d-proton 3.2, which turns on VK_EXT_descriptor_heap by default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (pEmbeddedSampler in libs/vkd3d/state.c). The driver then meets them in the order the pipeline threads compile, which differs from run to run, and the root signatures made at the start fix nothing.

This gives each sampler's root signature a texture (t0) and a buffer (u0) and, beside it, a compute pipeline whose shader samples through the sampler (SampleLevel, or SampleCmpLevelZero for a c

Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture.

Reply testing to take this run; it's free again after 24 h with no results.

**Test needed** — commit `29ae0b6c`; what to check: - The problem on main: under Proton, starts whose driver cache should hold every pipeline compile them all again. In an empty driver cache, a start that compiled its ~5,000 pipelines (3.5 minutes until none were left) was followed by one that began with 6,686 being made and added another 110 MB to the cache. `samplers.rs` makes every static sampler in one order at the start of each process, in root signatures of their own, because the NVIDIA driver keeps a pipeline's samplers by their places in its table, and its cache finds a pipeline again only where those places are the same. Under vkd3d-proton 3.2, which turns on `VK_EXT_descriptor_heap` by default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (`pEmbeddedSampler` in `libs/vkd3d/state.c`). The driver then meets them in the order the pipeline threads compile, which differs from run to run, and the root signatures made at the start fix nothing. This gives each sampler's root signature a texture (t0) and a buffer (u0) and, beside it, a compute pipeline whose shader samples through the sampler (`SampleLevel`, or `SampleCmpLevelZero` for a c Evidence to post: card + driver, settings, commit tested, before/after (switch off vs on, two runs each), fps median and p99, and one line saying you looked at the picture. Reply `testing` to take this run; it's free again after 24 h with no results.
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 'pr/static-samplers-heap:jensmonne-pr/static-samplers-heap'
git switch 'jensmonne-pr/static-samplers-heap'

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 'jensmonne-pr/static-samplers-heap'
git switch 'jensmonne-pr/static-samplers-heap'
git rebase 'Main'
git switch 'Main'
git merge --ff-only 'jensmonne-pr/static-samplers-heap'
git switch 'jensmonne-pr/static-samplers-heap'
git rebase 'Main'
git switch 'Main'
git merge --no-ff 'jensmonne-pr/static-samplers-heap'
git switch 'Main'
git merge --squash 'jensmonne-pr/static-samplers-heap'
git switch 'Main'
git merge --ff-only 'jensmonne-pr/static-samplers-heap'
git switch 'Main'
git merge 'jensmonne-pr/static-samplers-heap'
git push origin 'Main'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
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
TrustNo1/Darner!562
No description provided.