Static samplers: a compute pipeline per sampler, so the driver meets them in one order under vkd3d-proton's descriptor heap too #562
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
hle
input
INTEL
lighting
linux-proton
memory
MULDER
needs-info
needs-logs
needs-rebase
NVIDIA
performance
post-merge
pr-diagnostics
pr-docs
pre-merge
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
relevance
high
relevance
low
relevance
medium
relevance
very-high
rendering
report
roadmap-proposal
saves
series-s
shaders
startup
status
blocked-by-rework
status
needs-test-report
status
needs-triage
status
ready-for-review
status
stale
status
superseded
status
wip
tools
ui
upstream
wontfix
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
TrustNo1/Darner!562
Loading…
Reference in a new issue
No description provided.
Delete branch "jensmonne/Darner:pr/static-samplers-heap"
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?
Contributor role (optional)
What it changes
samplers.rsmakes 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 onVK_EXT_descriptor_heapby default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (pEmbeddedSamplerinlibs/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, orSampleCmpLevelZerofor 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, withhlsl::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=0leaves the pipelines out. The README gets a row for it, belowDARNER_SAMPLER_ORDER.How it was tested
Tested revision: 2b049a1 (this branch, on main
c8258f9) for the commands below;29ae0b6adds only the README row (cargo xtask policyagain: 576 files ok). The game runs used d730e29, the same commit without the new test, and f72d350, the same change onf3840d7(v2026.12.03.02).Commands and results (cross-built on Linux with
cargo xwin, targetx86_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-gpulib tests filtered topipeline::samplers, under Wine on the RTX 5080: 2 passed, twice. The neweach_sampler_gets_a_pipeline_that_samples_through_itmakes the root signature and the pipeline for a linear and for a comparing sampler; withDARNER_SAMPLER_PSO=0it fails ("no pipeline for ..."), as it should.pipeline::library: 33 passed, 1 failed (a_rebuilt_library_holds_the_pipelines_it_was_given); the same on mainc8258f9.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_heapon, 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.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
main.docs/asset-policy.md.Checked for overlap
crates/darner-gpu/src/pipeline/samplers.rs. #298 (an RTX 5090 hang under Proton) listsno_descriptor_heapamong the vkd3d settings its reporter tried; a different problem.One measurement detail for the native Windows cost at
29ae0b6c.host.rs:2314callssamplers::primebeforeDARNER_DRIVER_CACHE=0is 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 warmin new processes on the same adapter and the same PR executable. Give each isolatedDARNER_CACHE_DIRan identical syntheticpipelines/static-samplers.txtand no known pipelines, keepDARNER_SAMPLER_ORDER=1, and vary onlyDARNER_SAMPLER_PSO=0/1.warmopens 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.
Thanks, I ran that control, on Proton only (no Windows here).
Setup:
29ae0b6plus two local timing lines (aroundsyncinprime, and around the shaders' compile), not part of this PR. Each run is a newdarner warmprocess with its own emptyDARNER_CACHE_DIRholding only the samepipelines/static-samplers.txt(29 samplers) and no known pipelines,DARNER_SAMPLER_ORDER=1, and onlyDARNER_SAMPLER_PSOchanged, alternating 0 and 1. RTX 5080, NVIDIA 620.73, Proton Experimental 11.0-20261123b (vkd3d-proton withVK_EXT_descriptor_heapon).syncinprime)DARNER_SAMPLER_PSO=0DARNER_SAMPLER_PSO=1Of the ~115 ms, compiling the two shaders takes 1.6-2.0 ms (once per process, 4 runs); the rest is the 29
CreateComputePipelineStatecalls, 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.Native Windows sampler cost at
29ae0b6on an RTX 4060 (621.40). The synthetic fixture timed the existingsync(device, &[])insamplers::primeon 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_PSO01I 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[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 tooto Static samplers: a compute pipeline per sampler, so the driver meets them in one order under vkd3d-proton's descriptor heap tooTest needed — commit
29ae0b6c; what to check:samplers.rsmakes 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 onVK_EXT_descriptor_heapby default, a root signature gives the driver no sampler: vkd3d-proton passes the static samplers as embedded samplers of each pipeline made with it (pEmbeddedSamplerinlibs/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, orSampleCmpLevelZerofor a cEvidence 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
testingto take this run; it's free again after 24 h with no results.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.